Fix world crash, restore custom ores, fix armor textures (NeoForge 1.21.1)
@@ -3,49 +3,46 @@ package net.mcreator.customoregen;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.util.thread.SidedThreadGroups;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.util.thread.SidedThreadGroups;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.event.tick.ServerTickEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModTabs;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import net.mcreator.customoregen.item.ShardDiamondArmorMaterial;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@Mod("custom_ore_gen")
|
||||
@Mod(CustomOreGenMod.MODID)
|
||||
public class CustomOreGenMod {
|
||||
public static final Logger LOGGER = LogManager.getLogger(CustomOreGenMod.class);
|
||||
public static final String MODID = "custom_ore_gen";
|
||||
|
||||
public CustomOreGenMod() {
|
||||
public CustomOreGenMod(IEventBus modEventBus, ModContainer container) {
|
||||
// Start of user code block mod constructor
|
||||
// End of user code block mod constructor
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
|
||||
CustomOreGenModBlocks.REGISTRY.register(bus);
|
||||
CustomOreGenModBlocks.REGISTRY.register(modEventBus);
|
||||
|
||||
CustomOreGenModItems.REGISTRY.register(bus);
|
||||
CustomOreGenModItems.REGISTRY.register(modEventBus);
|
||||
ShardDiamondArmorMaterial.REGISTRY.register(modEventBus);
|
||||
|
||||
CustomOreGenModTabs.REGISTRY.register(bus);
|
||||
CustomOreGenModTabs.REGISTRY.register(modEventBus);
|
||||
|
||||
// Start of user code block mod init
|
||||
// End of user code block mod init
|
||||
@@ -53,15 +50,6 @@ public class CustomOreGenMod {
|
||||
|
||||
// Start of user code block mod methods
|
||||
// End of user code block mod methods
|
||||
private static final String PROTOCOL_VERSION = "1";
|
||||
public static final SimpleChannel PACKET_HANDLER = NetworkRegistry.newSimpleChannel(new ResourceLocation(MODID, MODID), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
|
||||
private static int messageID = 0;
|
||||
|
||||
public static <T> void addNetworkMessage(Class<T> messageType, BiConsumer<T, FriendlyByteBuf> encoder, Function<FriendlyByteBuf, T> decoder, BiConsumer<T, Supplier<NetworkEvent.Context>> messageConsumer) {
|
||||
PACKET_HANDLER.registerMessage(messageID, messageType, encoder, decoder, messageConsumer);
|
||||
messageID++;
|
||||
}
|
||||
|
||||
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void queueServerWork(int tick, Runnable action) {
|
||||
@@ -70,16 +58,14 @@ public class CustomOreGenMod {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tick(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
List<AbstractMap.SimpleEntry<Runnable, Integer>> actions = new ArrayList<>();
|
||||
workQueue.forEach(work -> {
|
||||
work.setValue(work.getValue() - 1);
|
||||
if (work.getValue() == 0)
|
||||
actions.add(work);
|
||||
});
|
||||
actions.forEach(e -> e.getKey().run());
|
||||
workQueue.removeAll(actions);
|
||||
}
|
||||
public void tick(ServerTickEvent.Post event) {
|
||||
List<AbstractMap.SimpleEntry<Runnable, Integer>> actions = new ArrayList<>();
|
||||
workQueue.forEach(work -> {
|
||||
work.setValue(work.getValue() - 1);
|
||||
if (work.getValue() == 0)
|
||||
actions.add(work);
|
||||
});
|
||||
actions.forEach(e -> e.getKey().run());
|
||||
workQueue.removeAll(actions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
package net.mcreator.customoregen;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class KubeJSIntegration {
|
||||
|
||||
private static final String SCRIPT_FILE_NAME = "custom_ore_gen_remove_vanilla_ores.js";
|
||||
private static boolean hasCreatedScript = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onCommonSetup(FMLCommonSetupEvent event) {
|
||||
// Only run once
|
||||
if (hasCreatedScript) {
|
||||
return;
|
||||
}
|
||||
|
||||
hasCreatedScript = true;
|
||||
|
||||
CustomOreGenMod.LOGGER.info("============================================");
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: FMLCommonSetupEvent FIRED!");
|
||||
CustomOreGenMod.LOGGER.info("============================================");
|
||||
|
||||
// Get the game directory (where .minecraft is)
|
||||
File gameDir = new File(".");
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Game directory: " + gameDir.getAbsolutePath());
|
||||
|
||||
File kubeJsDir = new File(gameDir, "kubejs/startup_scripts");
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Target KubeJS directory: " + kubeJsDir.getAbsolutePath());
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Directory exists? " + kubeJsDir.exists());
|
||||
|
||||
// Create directory if it doesn't exist
|
||||
if (!kubeJsDir.exists()) {
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Directory does not exist, creating...");
|
||||
boolean created = kubeJsDir.mkdirs();
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: mkdirs() returned: " + created);
|
||||
if (!created) {
|
||||
CustomOreGenMod.LOGGER.error("Custom Ore Gen: FAILED to create KubeJS directory!");
|
||||
return;
|
||||
}
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Successfully created directory");
|
||||
}
|
||||
|
||||
File scriptFile = new File(kubeJsDir, SCRIPT_FILE_NAME);
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Script file path: " + scriptFile.getAbsolutePath());
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Script file exists? " + scriptFile.exists());
|
||||
|
||||
// Only create if it doesn't exist
|
||||
if (scriptFile.exists()) {
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Script already exists, skipping creation");
|
||||
return;
|
||||
}
|
||||
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Script does not exist, creating now...");
|
||||
|
||||
try {
|
||||
createKubeJSScript(scriptFile.toPath());
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Script creation completed successfully!");
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: File exists after creation? " + scriptFile.exists());
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: File size: " + scriptFile.length() + " bytes");
|
||||
} catch (IOException e) {
|
||||
CustomOreGenMod.LOGGER.error("Custom Ore Gen: FAILED to create KubeJS script!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CustomOreGenMod.LOGGER.info("============================================");
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Script creation process finished");
|
||||
CustomOreGenMod.LOGGER.info("============================================");
|
||||
}
|
||||
|
||||
private static void createKubeJSScript(Path scriptPath) throws IOException {
|
||||
String scriptContent = """
|
||||
// priority: 0
|
||||
|
||||
WorldgenEvents.remove(event => {
|
||||
var minecraftOreList = [
|
||||
'minecraft:coal_ore',
|
||||
'minecraft:deepslate_coal_ore',
|
||||
'minecraft:copper_ore',
|
||||
'minecraft:deepslate_copper_ore',
|
||||
'minecraft:iron_ore',
|
||||
'minecraft:deepslate_iron_ore',
|
||||
'minecraft:gold_ore',
|
||||
'minecraft:deepslate_gold_ore',
|
||||
'minecraft:redstone_ore',
|
||||
'minecraft:deepslate_redstone_ore',
|
||||
'minecraft:emerald_ore',
|
||||
'minecraft:deepslate_emerald_ore',
|
||||
'minecraft:diamond_ore',
|
||||
'minecraft:deepslate_diamond_ore',
|
||||
'minecraft:lapis_ore',
|
||||
'minecraft:deepslate_lapis_ore'
|
||||
];
|
||||
|
||||
event.removeOres(props => {
|
||||
props.blocks = minecraftOreList
|
||||
});
|
||||
});
|
||||
""";
|
||||
|
||||
Files.writeString(scriptPath, scriptContent, StandardOpenOption.CREATE_NEW);
|
||||
CustomOreGenMod.LOGGER.info("Custom Ore Gen: Files.writeString() completed");
|
||||
}
|
||||
}
|
||||
@@ -10,26 +10,27 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
@EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
public class OresCommand {
|
||||
|
||||
// Tags personnalisés du mod
|
||||
private static final TagKey<Biome> COLD_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "cold_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "cold_biomes"));
|
||||
private static final TagKey<Biome> HOT_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "hot_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "hot_biomes"));
|
||||
private static final TagKey<Biome> MOUNTAIN_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "mountain_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "mountain_biomes"));
|
||||
private static final TagKey<Biome> TEMPERED_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "tempered_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "tempered_biomes"));
|
||||
private static final TagKey<Biome> RARE_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "rare_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "rare_biomes"));
|
||||
|
||||
// Minerais par catégorie (mappé avec les biome modifiers)
|
||||
private static final List<String> COLD_ORES = Arrays.asList(
|
||||
@@ -85,7 +86,7 @@ public class OresCommand {
|
||||
|
||||
var biomeHolder = level.getBiome(pos);
|
||||
ResourceKey<Biome> biomeKey = biomeHolder.unwrapKey()
|
||||
.orElse(ResourceKey.create(Registries.BIOME, new ResourceLocation("minecraft:plains")));
|
||||
.orElse(ResourceKey.create(Registries.BIOME, ResourceLocation.fromNamespaceAndPath("minecraft", "plains")));
|
||||
ResourceLocation biomeId = biomeKey.location();
|
||||
String biomeName = biomeId.getPath();
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ public class DeepslatediamondoreBlock extends Block {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
|
||||
return new ItemStack(CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDestroyedByPlayer(BlockState blockstate, Level world, BlockPos pos, Player entity, boolean willHarvest, FluidState fluid) {
|
||||
boolean retval = super.onDestroyedByPlayer(blockstate, world, pos, entity, willHarvest, fluid);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.mcreator.customoregen.config;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
public class ConfigHelper {
|
||||
// Helper method to safely access config values
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.mcreator.customoregen.config;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
|
||||
public class ModConfigs {
|
||||
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
public static final ForgeConfigSpec SPEC;
|
||||
public static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
|
||||
public static final ModConfigSpec SPEC;
|
||||
|
||||
public static final OreGenConfig ORE_GEN;
|
||||
public static final ToolStatsConfig TOOL_STATS;
|
||||
@@ -25,30 +25,30 @@ public class ModConfigs {
|
||||
|
||||
// Configuration pour la génération des minerais
|
||||
public static class OreGenConfig {
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondOreMinHeight;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondOreMaxHeight;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondOreCount;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondOreSize;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMinHeight;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMaxHeight;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreSize;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedDiamondOreCount;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedDiamondOreSize;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreSize;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> pureGoldenOreCount;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> pureGoldenOreMinHeight;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> pureGoldenOreMaxHeight;
|
||||
public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMinHeight;
|
||||
public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMaxHeight;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedCoalOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedCoalOreCount;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> impureIronOreCount;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> impureGoldOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureIronOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreCount;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> highEmeraldOreCount;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> lowerEmeraldOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> highEmeraldOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> lowerEmeraldOreCount;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> highCopperOreCount;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> lowerCopperOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> highCopperOreCount;
|
||||
public final ModConfigSpec.ConfigValue<Integer> lowerCopperOreCount;
|
||||
|
||||
public OreGenConfig(ForgeConfigSpec.Builder builder) {
|
||||
public OreGenConfig(ModConfigSpec.Builder builder) {
|
||||
builder.push("ore_generation");
|
||||
|
||||
builder.push("shard_diamond_ore");
|
||||
@@ -126,19 +126,19 @@ public class ModConfigs {
|
||||
|
||||
// Configuration pour les stats des outils
|
||||
public static class ToolStatsConfig {
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondPickaxeDurability;
|
||||
public final ForgeConfigSpec.DoubleValue shardDiamondPickaxeSpeed;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondPickaxeAttackDamage;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondPickaxeDurability;
|
||||
public final ModConfigSpec.DoubleValue shardDiamondPickaxeSpeed;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondPickaxeAttackDamage;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondAxeDurability;
|
||||
public final ForgeConfigSpec.DoubleValue shardDiamondAxeSpeed;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondAxeAttackDamage;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondAxeDurability;
|
||||
public final ModConfigSpec.DoubleValue shardDiamondAxeSpeed;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondAxeAttackDamage;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondShovelDurability;
|
||||
public final ForgeConfigSpec.DoubleValue shardDiamondShovelSpeed;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondShovelAttackDamage;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondShovelDurability;
|
||||
public final ModConfigSpec.DoubleValue shardDiamondShovelSpeed;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondShovelAttackDamage;
|
||||
|
||||
public ToolStatsConfig(ForgeConfigSpec.Builder builder) {
|
||||
public ToolStatsConfig(ModConfigSpec.Builder builder) {
|
||||
builder.push("tool_stats");
|
||||
|
||||
builder.push("shard_diamond_tools");
|
||||
@@ -179,32 +179,32 @@ public class ModConfigs {
|
||||
|
||||
// Configuration pour les drops des minerais
|
||||
public static class DropsConfig {
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> shardDiamondOreMaxDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> shardDiamondOreEnableFortune;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> shardDiamondOreEnableFortune;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedDiamondOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedDiamondOreMaxDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> concentratedDiamondOreEnableFortune;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> concentratedDiamondOreEnableFortune;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedCoalOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> concentratedCoalOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedCoalOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> concentratedCoalOreMaxDrops;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> pureGoldenOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> pureGoldenOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMaxDrops;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> ashCoalOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> ashCoalOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> ashCoalOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> ashCoalOreMaxDrops;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> impureIronOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> impureIronOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureIronOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureIronOreMaxDrops;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> impureGoldOreMinDrops;
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> impureGoldOreMaxDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMaxDrops;
|
||||
|
||||
public final ForgeConfigSpec.ConfigValue<Integer> oreExperienceDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> oreExperienceDrops;
|
||||
|
||||
public DropsConfig(ForgeConfigSpec.Builder builder) {
|
||||
public DropsConfig(ModConfigSpec.Builder builder) {
|
||||
builder.push("drops");
|
||||
|
||||
builder.push("shard_diamond_ore");
|
||||
@@ -283,17 +283,17 @@ public class ModConfigs {
|
||||
|
||||
// Configuration pour activer/désactiver les fonctionnalités
|
||||
public static class FeatureToggleConfig {
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableShardDiamondTools;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableShardDiamondOre;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableConcentratedOres;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableImpureOres;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableAshCoalOre;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enablePureGoldenOre;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableCustomEmeraldOres;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableCustomCopperOres;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> enableVanillaOreVariants;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondTools;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondOre;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableConcentratedOres;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableImpureOres;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableAshCoalOre;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enablePureGoldenOre;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableCustomEmeraldOres;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableCustomCopperOres;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableVanillaOreVariants;
|
||||
|
||||
public FeatureToggleConfig(ForgeConfigSpec.Builder builder) {
|
||||
public FeatureToggleConfig(ModConfigSpec.Builder builder) {
|
||||
builder.push("features");
|
||||
|
||||
enableShardDiamondTools = builder
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
package net.mcreator.customoregen.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.block.SharddiamondblockoreBlock;
|
||||
@@ -28,24 +28,26 @@ import net.mcreator.customoregen.block.DeepslatediamondoreBlock;
|
||||
import net.mcreator.customoregen.block.ConcentratedcoaloreBlock;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CustomOreGenModBlocks {
|
||||
public static final DeferredRegister<Block> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCKS, CustomOreGenMod.MODID);
|
||||
public static final RegistryObject<Block> SHARDDIAMONDBLOCKORE = REGISTRY.register("sharddiamondblockore", () -> new SharddiamondblockoreBlock());
|
||||
public static final RegistryObject<Block> PUREGOLDENORE = REGISTRY.register("puregoldenore", () -> new PuregoldenoreBlock());
|
||||
public static final RegistryObject<Block> DEEPSLATEPUREGOLDENORE = REGISTRY.register("deepslatepuregoldenore", () -> new DeepslatepuregoldenoreBlock());
|
||||
public static final RegistryObject<Block> CONCENTRATEDCOALORE = REGISTRY.register("concentratedcoalore", () -> new ConcentratedcoaloreBlock());
|
||||
public static final RegistryObject<Block> DEEPSLATESHARDDIAMONDORE = REGISTRY.register("deepslatesharddiamondore", () -> new DeepslatesharddiamondoreBlock());
|
||||
public static final RegistryObject<Block> DEEPSLATEDIAMONDORE = REGISTRY.register("deepslatediamondore", () -> new DeepslatediamondoreBlock());
|
||||
public static final RegistryObject<Block> LAPISORE = REGISTRY.register("lapisore", () -> new LapisoreBlock());
|
||||
public static final RegistryObject<Block> DEEPSLATELAPISORE = REGISTRY.register("deepslatelapisore", () -> new DeepslatelapisoreBlock());
|
||||
public static final RegistryObject<Block> REDSTONEORE = REGISTRY.register("redstoneore", () -> new RedstoneoreBlock());
|
||||
public static final RegistryObject<Block> DEEPSLATEREDSTONEORE = REGISTRY.register("deepslateredstoneore", () -> new DeepslateredstoneoreBlock());
|
||||
public static final RegistryObject<Block> COPPERHIGHORE = REGISTRY.register("copperhighore", () -> new CopperhighoreBlock());
|
||||
public static final RegistryObject<Block> COPPERLOWERORE = REGISTRY.register("copperlowerore", () -> new CopperloweroreBlock());
|
||||
public static final RegistryObject<Block> HIGHEMERALDORE = REGISTRY.register("highemeraldore", () -> new HighemeraldoreBlock());
|
||||
public static final RegistryObject<Block> LOWEREMERALDORE = REGISTRY.register("loweremeraldore", () -> new LoweremeraldoreBlock());
|
||||
public static final RegistryObject<Block> IRONORE = REGISTRY.register("ironore", () -> new IronoreBlock());
|
||||
public static final RegistryObject<Block> DEEPSLATEIRONORE = REGISTRY.register("deepslateironore", () -> new DeepslateironoreBlock());
|
||||
public static final DeferredRegister<Block> REGISTRY = DeferredRegister.create(Registries.BLOCK, CustomOreGenMod.MODID);
|
||||
public static final Supplier<Block> SHARDDIAMONDBLOCKORE = REGISTRY.register("sharddiamondblockore", () -> new SharddiamondblockoreBlock());
|
||||
public static final Supplier<Block> PUREGOLDENORE = REGISTRY.register("puregoldenore", () -> new PuregoldenoreBlock());
|
||||
public static final Supplier<Block> DEEPSLATEPUREGOLDENORE = REGISTRY.register("deepslatepuregoldenore", () -> new DeepslatepuregoldenoreBlock());
|
||||
public static final Supplier<Block> CONCENTRATEDCOALORE = REGISTRY.register("concentratedcoalore", () -> new ConcentratedcoaloreBlock());
|
||||
public static final Supplier<Block> DEEPSLATESHARDDIAMONDORE = REGISTRY.register("deepslatesharddiamondore", () -> new DeepslatesharddiamondoreBlock());
|
||||
public static final Supplier<Block> DEEPSLATEDIAMONDORE = REGISTRY.register("deepslatediamondore", () -> new DeepslatediamondoreBlock());
|
||||
public static final Supplier<Block> LAPISORE = REGISTRY.register("lapisore", () -> new LapisoreBlock());
|
||||
public static final Supplier<Block> DEEPSLATELAPISORE = REGISTRY.register("deepslatelapisore", () -> new DeepslatelapisoreBlock());
|
||||
public static final Supplier<Block> REDSTONEORE = REGISTRY.register("redstoneore", () -> new RedstoneoreBlock());
|
||||
public static final Supplier<Block> DEEPSLATEREDSTONEORE = REGISTRY.register("deepslateredstoneore", () -> new DeepslateredstoneoreBlock());
|
||||
public static final Supplier<Block> COPPERHIGHORE = REGISTRY.register("copperhighore", () -> new CopperhighoreBlock());
|
||||
public static final Supplier<Block> COPPERLOWERORE = REGISTRY.register("copperlowerore", () -> new CopperloweroreBlock());
|
||||
public static final Supplier<Block> HIGHEMERALDORE = REGISTRY.register("highemeraldore", () -> new HighemeraldoreBlock());
|
||||
public static final Supplier<Block> LOWEREMERALDORE = REGISTRY.register("loweremeraldore", () -> new LoweremeraldoreBlock());
|
||||
public static final Supplier<Block> IRONORE = REGISTRY.register("ironore", () -> new IronoreBlock());
|
||||
public static final Supplier<Block> DEEPSLATEIRONORE = REGISTRY.register("deepslateironore", () -> new DeepslateironoreBlock());
|
||||
// Start of user code block custom blocks
|
||||
// End of user code block custom blocks
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
package net.mcreator.customoregen.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
@@ -24,43 +24,61 @@ import net.mcreator.customoregen.item.SharddiamondbootsItem;
|
||||
import net.mcreator.customoregen.item.SharddiamondpaxelItem;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CustomOreGenModItems {
|
||||
public static final DeferredRegister<Item> REGISTRY = DeferredRegister.create(ForgeRegistries.ITEMS, CustomOreGenMod.MODID);
|
||||
public static final RegistryObject<Item> DIAMONDSHARD = REGISTRY.register("diamondshard", () -> new DiamondshardItem());
|
||||
public static final RegistryObject<Item> SHARDDIAMONDBLOCKORE = block(CustomOreGenModBlocks.SHARDDIAMONDBLOCKORE);
|
||||
public static final RegistryObject<Item> PUREGOLDENORE = block(CustomOreGenModBlocks.PUREGOLDENORE);
|
||||
public static final RegistryObject<Item> DEEPSLATEPUREGOLDENORE = block(CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE);
|
||||
public static final RegistryObject<Item> CONCENTRATEDCOALORE = block(CustomOreGenModBlocks.CONCENTRATEDCOALORE);
|
||||
public static final RegistryObject<Item> DEEPSLATESHARDDIAMONDORE = block(CustomOreGenModBlocks.DEEPSLATESHARDDIAMONDORE);
|
||||
public static final RegistryObject<Item> DEEPSLATEDIAMONDORE = block(CustomOreGenModBlocks.DEEPSLATEDIAMONDORE);
|
||||
public static final RegistryObject<Item> LAPISORE = block(CustomOreGenModBlocks.LAPISORE);
|
||||
public static final RegistryObject<Item> DEEPSLATELAPISORE = block(CustomOreGenModBlocks.DEEPSLATELAPISORE);
|
||||
public static final RegistryObject<Item> REDSTONEORE = block(CustomOreGenModBlocks.REDSTONEORE);
|
||||
public static final RegistryObject<Item> DEEPSLATEREDSTONEORE = block(CustomOreGenModBlocks.DEEPSLATEREDSTONEORE);
|
||||
public static final RegistryObject<Item> COPPERHIGHORE = block(CustomOreGenModBlocks.COPPERHIGHORE);
|
||||
public static final RegistryObject<Item> COPPERLOWERORE = block(CustomOreGenModBlocks.COPPERLOWERORE);
|
||||
public static final RegistryObject<Item> HIGHEMERALDORE = block(CustomOreGenModBlocks.HIGHEMERALDORE);
|
||||
public static final RegistryObject<Item> LOWEREMERALDORE = block(CustomOreGenModBlocks.LOWEREMERALDORE);
|
||||
public static final RegistryObject<Item> SHARDDIAMONDPICKAXE = REGISTRY.register("sharddiamondpickaxe", () -> new SharddiamondpickaxeItem());
|
||||
public static final RegistryObject<Item> SHARDDIAMONDSHOVEL = REGISTRY.register("sharddiamondshovel", () -> new SharddiamondshovelItem());
|
||||
public static final RegistryObject<Item> SHARDDIAMONDAXE = REGISTRY.register("sharddiamondaxe", () -> new SharddiamondaxeItem());
|
||||
public static final RegistryObject<Item> IRONORE = block(CustomOreGenModBlocks.IRONORE);
|
||||
public static final RegistryObject<Item> DEEPSLATEIRONORE = block(CustomOreGenModBlocks.DEEPSLATEIRONORE);
|
||||
public static final DeferredRegister<Item> REGISTRY = DeferredRegister.create(Registries.ITEM, CustomOreGenMod.MODID);
|
||||
public static final Supplier<Item> DIAMONDSHARD = REGISTRY.register("diamondshard", () -> new DiamondshardItem());
|
||||
|
||||
// Block items - these need to be registered with the same name as the blocks
|
||||
public static final Supplier<Item> SHARDDIAMONDBLOCKORE = REGISTRY.register("sharddiamondblockore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.SHARDDIAMONDBLOCKORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> PUREGOLDENORE = REGISTRY.register("puregoldenore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.PUREGOLDENORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> DEEPSLATEPUREGOLDENORE = REGISTRY.register("deepslatepuregoldenore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> CONCENTRATEDCOALORE = REGISTRY.register("concentratedcoalore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.CONCENTRATEDCOALORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> DEEPSLATESHARDDIAMONDORE = REGISTRY.register("deepslatesharddiamondore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATESHARDDIAMONDORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> DEEPSLATEDIAMONDORE = REGISTRY.register("deepslatediamondore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> LAPISORE = REGISTRY.register("lapisore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.LAPISORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> DEEPSLATELAPISORE = REGISTRY.register("deepslatelapisore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATELAPISORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> REDSTONEORE = REGISTRY.register("redstoneore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.REDSTONEORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> DEEPSLATEREDSTONEORE = REGISTRY.register("deepslateredstoneore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATEREDSTONEORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> COPPERHIGHORE = REGISTRY.register("copperhighore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.COPPERHIGHORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> COPPERLOWERORE = REGISTRY.register("copperlowerore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.COPPERLOWERORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> HIGHEMERALDORE = REGISTRY.register("highemeraldore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.HIGHEMERALDORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> LOWEREMERALDORE = REGISTRY.register("loweremeraldore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.LOWEREMERALDORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> IRONORE = REGISTRY.register("ironore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.IRONORE.get(), new Item.Properties()));
|
||||
public static final Supplier<Item> DEEPSLATEIRONORE = REGISTRY.register("deepslateironore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATEIRONORE.get(), new Item.Properties()));
|
||||
|
||||
// Start of user code block custom items
|
||||
public static final RegistryObject<Item> ORE_BIOME_FINDER = REGISTRY.register("ore_biome_finder", () -> new OreBiomeFinderItem());
|
||||
public static final Supplier<Item> ORE_BIOME_FINDER = REGISTRY.register("ore_biome_finder", () -> new OreBiomeFinderItem());
|
||||
|
||||
// Diamond Shard Armor
|
||||
public static final RegistryObject<Item> SHARDDIAMONDHELMET = REGISTRY.register("sharddiamondhelmet", () -> new SharddiamondhelmetItem());
|
||||
public static final RegistryObject<Item> SHARDDIAMONDCHESTPLATE = REGISTRY.register("sharddiamondchestplate", () -> new SharddiamondchestplateItem());
|
||||
public static final RegistryObject<Item> SHARDDIAMONDLEGGINGS = REGISTRY.register("sharddiamondleggings", () -> new SharddiamondleggingsItem());
|
||||
public static final RegistryObject<Item> SHARDDIAMONDBOOTS = REGISTRY.register("sharddiamondboots", () -> new SharddiamondbootsItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDHELMET = REGISTRY.register("sharddiamondhelmet", () -> new SharddiamondhelmetItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDCHESTPLATE = REGISTRY.register("sharddiamondchestplate", () -> new SharddiamondchestplateItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDLEGGINGS = REGISTRY.register("sharddiamondleggings", () -> new SharddiamondleggingsItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDBOOTS = REGISTRY.register("sharddiamondboots", () -> new SharddiamondbootsItem());
|
||||
|
||||
// Diamond Shard Paxel
|
||||
public static final RegistryObject<Item> SHARDDIAMONDPAXEL = REGISTRY.register("sharddiamondpaxel", () -> new SharddiamondpaxelItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDPAXEL = REGISTRY.register("sharddiamondpaxel", () -> new SharddiamondpaxelItem());
|
||||
// End of user code block custom items
|
||||
|
||||
private static RegistryObject<Item> block(RegistryObject<Block> block) {
|
||||
return REGISTRY.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
|
||||
}
|
||||
// Tool items
|
||||
public static final Supplier<Item> SHARDDIAMONDPICKAXE = REGISTRY.register("sharddiamondpickaxe", () -> new SharddiamondpickaxeItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDSHOVEL = REGISTRY.register("sharddiamondshovel", () -> new SharddiamondshovelItem());
|
||||
public static final Supplier<Item> SHARDDIAMONDAXE = REGISTRY.register("sharddiamondaxe", () -> new SharddiamondaxeItem());
|
||||
}
|
||||
|
||||
@@ -4,28 +4,30 @@
|
||||
*/
|
||||
package net.mcreator.customoregen.init;
|
||||
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
public class CustomOreGenModTabs {
|
||||
public static final DeferredRegister<CreativeModeTab> REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, CustomOreGenMod.MODID);
|
||||
|
||||
// Start of user code block tabs
|
||||
public static final RegistryObject<CreativeModeTab> CUSTOM_ORE_GEN_TAB = REGISTRY.register("custom_ore_gen_tab",
|
||||
public static final Supplier<CreativeModeTab> CUSTOM_ORE_GEN_TAB = REGISTRY.register("custom_ore_gen_tab",
|
||||
() -> CreativeModeTab.builder()
|
||||
.title(net.minecraft.network.chat.Component.translatable("itemGroup.custom_ore_gen"))
|
||||
.title(Component.translatable("itemGroup.custom_ore_gen"))
|
||||
.icon(() -> new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()))
|
||||
.displayItems((parameters, output) -> {
|
||||
// Minerais
|
||||
|
||||
@@ -3,9 +3,9 @@ package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,8 +16,7 @@ public class DiamondshardItem extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemstack, Level level, List<Component> list, TooltipFlag flag) {
|
||||
super.appendHoverText(itemstack, level, list, flag);
|
||||
public void appendHoverText(ItemStack itemstack, Item.TooltipContext context, List<Component> list, TooltipFlag flag) {
|
||||
list.add(Component.translatable("item.custom_ore_gen.diamondshard.description_0"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@ public class OreBiomeFinderItem extends Item {
|
||||
|
||||
// Tags personnalisés du mod
|
||||
private static final TagKey<Biome> COLD_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "cold_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "cold_biomes"));
|
||||
private static final TagKey<Biome> HOT_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "hot_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "hot_biomes"));
|
||||
private static final TagKey<Biome> MOUNTAIN_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "mountain_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "mountain_biomes"));
|
||||
private static final TagKey<Biome> TEMPERED_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "tempered_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "tempered_biomes"));
|
||||
private static final TagKey<Biome> RARE_BIOMES_TAG = TagKey.create(Registries.BIOME,
|
||||
new ResourceLocation("custom_ore_gen", "rare_biomes"));
|
||||
ResourceLocation.fromNamespaceAndPath("custom_ore_gen", "rare_biomes"));
|
||||
|
||||
// Minerais par catégorie
|
||||
private static final List<String> COLD_ORES = Arrays.asList(
|
||||
@@ -71,7 +71,7 @@ public class OreBiomeFinderItem extends Item {
|
||||
BlockPos pos = player.blockPosition();
|
||||
var biomeHolder = level.getBiome(pos);
|
||||
ResourceKey<Biome> biomeKey = biomeHolder.unwrapKey()
|
||||
.orElse(ResourceKey.create(Registries.BIOME, new ResourceLocation("minecraft:plains")));
|
||||
.orElse(ResourceKey.create(Registries.BIOME, ResourceLocation.fromNamespaceAndPath("minecraft", "plains")));
|
||||
ResourceLocation biomeId = biomeKey.location();
|
||||
String biomeName = biomeId.getPath();
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ArmorMaterial;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
||||
/**
|
||||
* Base class for Shard Diamond armor items with custom stats matching Forge
|
||||
* 1.20.1
|
||||
*/
|
||||
public abstract class ShardDiamondArmorItem extends ArmorItem {
|
||||
|
||||
public ShardDiamondArmorItem(ArmorItem.Type type, Item.Properties properties) {
|
||||
super(ShardDiamondArmorMaterial.SHARD_DIAMOND, type, properties.stacksTo(64));
|
||||
}
|
||||
|
||||
/**
|
||||
* Override durability to match original stats:
|
||||
* helmet: 250, chestplate: 300, leggings: 280, boots: 230
|
||||
*/
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return switch (getType()) {
|
||||
case HELMET -> 250;
|
||||
case CHESTPLATE -> 300;
|
||||
case LEGGINGS -> 280;
|
||||
case BOOTS -> 230;
|
||||
default -> super.getMaxDamage(stack);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Override protection to match original stats:
|
||||
* helmet: 3, chestplate: 7, leggings: 5, boots: 2
|
||||
*/
|
||||
@Override
|
||||
public int getDefense() {
|
||||
return switch (getType()) {
|
||||
case HELMET -> 3;
|
||||
case CHESTPLATE -> 7;
|
||||
case LEGGINGS -> 5;
|
||||
case BOOTS -> 2;
|
||||
default -> super.getDefense();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Override toughness to match original stat: 1.0f
|
||||
*/
|
||||
@Override
|
||||
public float getToughness() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override enchantment value to match original stat: 14
|
||||
*/
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return 14;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,40 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ArmorMaterial;
|
||||
import net.minecraft.world.item.ArmorMaterials;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
public class ShardDiamondArmorMaterial implements ArmorMaterial {
|
||||
public static final ShardDiamondArmorMaterial INSTANCE = new ShardDiamondArmorMaterial();
|
||||
/**
|
||||
* Custom armor material wrapper for Diamond Shard armor.
|
||||
* Uses vanilla DIAMOND material as base but references can be replaced with
|
||||
* custom material.
|
||||
*/
|
||||
public class ShardDiamondArmorMaterial {
|
||||
public static final net.neoforged.neoforge.registries.DeferredRegister<ArmorMaterial> REGISTRY = net.neoforged.neoforge.registries.DeferredRegister
|
||||
.create(Registries.ARMOR_MATERIAL, CustomOreGenMod.MODID);
|
||||
|
||||
private static final int[] DURABILITY_PER_SLOT = new int[]{250, 300, 280, 230};
|
||||
private static final int[] PROTECTION_PER_SLOT = new int[]{3, 7, 5, 2};
|
||||
|
||||
@Override
|
||||
public int getDurabilityForType(ArmorItem.Type type) {
|
||||
return DURABILITY_PER_SLOT[type.getSlot().getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefenseForType(ArmorItem.Type type) {
|
||||
return PROTECTION_PER_SLOT[type.getSlot().getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return 14;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getEquipSound() {
|
||||
return SoundEvents.ARMOR_EQUIP_DIAMOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(CustomOreGenModItems.DIAMONDSHARD.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return CustomOreGenMod.MODID + ":shard_diamond";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getKnockbackResistance() {
|
||||
return 0.0f;
|
||||
}
|
||||
public static final Holder<ArmorMaterial> SHARD_DIAMOND = REGISTRY.register("shard_diamond",
|
||||
() -> new ArmorMaterial(
|
||||
net.minecraft.Util.make(new java.util.EnumMap<>(ArmorItem.Type.class), map -> {
|
||||
map.put(ArmorItem.Type.BOOTS, 2);
|
||||
map.put(ArmorItem.Type.LEGGINGS, 5);
|
||||
map.put(ArmorItem.Type.CHESTPLATE, 7);
|
||||
map.put(ArmorItem.Type.HELMET, 3);
|
||||
map.put(ArmorItem.Type.BODY, 0);
|
||||
}),
|
||||
14,
|
||||
SoundEvents.ARMOR_EQUIP_DIAMOND,
|
||||
() -> Ingredient.of(CustomOreGenModItems.DIAMONDSHARD.get()),
|
||||
java.util.List.of(new ArmorMaterial.Layer(
|
||||
ResourceLocation.fromNamespaceAndPath(CustomOreGenMod.MODID, "shard_diamond"), "", false)),
|
||||
1.0F,
|
||||
0.0F));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.AxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
@@ -23,10 +26,6 @@ public class SharddiamondaxeItem extends AxeItem {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 9;
|
||||
}
|
||||
@@ -34,6 +33,11 @@ public class SharddiamondaxeItem extends AxeItem {
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
}, 1, -3f, new Item.Properties());
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class SharddiamondbootsItem extends ArmorItem {
|
||||
public class SharddiamondbootsItem extends ShardDiamondArmorItem {
|
||||
public SharddiamondbootsItem() {
|
||||
super(ShardDiamondArmorMaterial.INSTANCE, ArmorItem.Type.BOOTS, new Item.Properties());
|
||||
super(Type.BOOTS, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class SharddiamondchestplateItem extends ArmorItem {
|
||||
public class SharddiamondchestplateItem extends ShardDiamondArmorItem {
|
||||
public SharddiamondchestplateItem() {
|
||||
super(ShardDiamondArmorMaterial.INSTANCE, ArmorItem.Type.CHESTPLATE, new Item.Properties());
|
||||
super(Type.CHESTPLATE, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class SharddiamondhelmetItem extends ArmorItem {
|
||||
public class SharddiamondhelmetItem extends ShardDiamondArmorItem {
|
||||
public SharddiamondhelmetItem() {
|
||||
super(ShardDiamondArmorMaterial.INSTANCE, ArmorItem.Type.HELMET, new Item.Properties());
|
||||
super(Type.HELMET, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class SharddiamondleggingsItem extends ArmorItem {
|
||||
public class SharddiamondleggingsItem extends ShardDiamondArmorItem {
|
||||
public SharddiamondleggingsItem() {
|
||||
super(ShardDiamondArmorMaterial.INSTANCE, ArmorItem.Type.LEGGINGS, new Item.Properties());
|
||||
super(Type.LEGGINGS, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
@@ -26,10 +27,6 @@ public class SharddiamondpaxelItem extends PickaxeItem {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 14;
|
||||
}
|
||||
@@ -37,7 +34,12 @@ public class SharddiamondpaxelItem extends PickaxeItem {
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
}, 1, -2.8f, new Item.Properties());
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +48,7 @@ public class SharddiamondpaxelItem extends PickaxeItem {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_PICKAXE) ||
|
||||
state.is(BlockTags.MINEABLE_WITH_SHOVEL) ||
|
||||
state.is(BlockTags.MINEABLE_WITH_AXE)) {
|
||||
return getTier().getSpeed();
|
||||
return this.getTier().getSpeed();
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
@@ -54,27 +56,15 @@ public class SharddiamondpaxelItem extends PickaxeItem {
|
||||
@Override
|
||||
public boolean isCorrectToolForDrops(ItemStack stack, BlockState state) {
|
||||
// Can mine blocks that require pickaxe, shovel, or axe
|
||||
// In 1.21, we check the tags directly without needing to check tier level
|
||||
if (state.is(BlockTags.MINEABLE_WITH_PICKAXE) ||
|
||||
state.is(BlockTags.MINEABLE_WITH_SHOVEL) ||
|
||||
state.is(BlockTags.MINEABLE_WITH_AXE)) {
|
||||
return TierSortingCorrectToolForDrops(stack, state);
|
||||
// For diamond-tier blocks, we need to verify our tool is diamond-tier
|
||||
// Since this is a diamond-equivalent tool, it should work on all non-obsidian blocks
|
||||
// The parent class PickaxeItem handles the actual tier check
|
||||
return super.isCorrectToolForDrops(stack, state);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean TierSortingCorrectToolForDrops(ItemStack stack, BlockState state) {
|
||||
// Check if tool tier is sufficient for the block
|
||||
return getTier().getLevel() >= getRequiredToolLevel(state);
|
||||
}
|
||||
|
||||
private int getRequiredToolLevel(BlockState state) {
|
||||
if (state.is(BlockTags.NEEDS_DIAMOND_TOOL)) {
|
||||
return 3;
|
||||
} else if (state.is(BlockTags.NEEDS_IRON_TOOL)) {
|
||||
return 2;
|
||||
} else if (state.is(BlockTags.NEEDS_STONE_TOOL)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
@@ -24,10 +27,6 @@ public class SharddiamondpickaxeItem extends PickaxeItem {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 9;
|
||||
}
|
||||
@@ -35,6 +34,11 @@ public class SharddiamondpickaxeItem extends PickaxeItem {
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
}, 1, -3f, new Item.Properties());
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
@@ -24,10 +27,6 @@ public class SharddiamondshovelItem extends ShovelItem {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 9;
|
||||
}
|
||||
@@ -35,6 +34,11 @@ public class SharddiamondshovelItem extends ShovelItem {
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
}, 1, -3f, new Item.Properties());
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,21 @@ package net.mcreator.customoregen.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
|
||||
@@ -40,8 +39,16 @@ public class ConfigurableOreDropsProcedure {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
ItemStack mainHandItem = player.getMainHandItem();
|
||||
fortuneLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, mainHandItem);
|
||||
silkTouch = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, mainHandItem) > 0;
|
||||
// 1.21: Enchantment API changed - use getAllEnchantments with registry lookup
|
||||
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
for (Holder<Enchantment> enchantment : mainHandItem.getAllEnchantments(enchantmentRegistry).keySet()) {
|
||||
if (enchantment.is(Enchantments.FORTUNE)) {
|
||||
fortuneLevel = mainHandItem.getAllEnchantments(enchantmentRegistry).getLevel(enchantment);
|
||||
}
|
||||
if (enchantment.is(Enchantments.SILK_TOUCH)) {
|
||||
silkTouch = mainHandItem.getAllEnchantments(enchantmentRegistry).getLevel(enchantment) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If silk touch, drop the block itself and return
|
||||
|
||||
@@ -4,6 +4,10 @@ import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -14,7 +18,20 @@ public class OreexperienceProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (!(EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)) != 0)) {
|
||||
// 1.21: Enchantment API changed - use getAllEnchantments with registry lookup
|
||||
boolean hasSilkTouch = false;
|
||||
if (entity instanceof LivingEntity _livEnt) {
|
||||
ItemStack mainHandItem = _livEnt.getMainHandItem();
|
||||
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
for (Holder<Enchantment> enchantment : mainHandItem.getAllEnchantments(enchantmentRegistry).keySet()) {
|
||||
if (enchantment.is(Enchantments.SILK_TOUCH)) {
|
||||
hasSilkTouch = mainHandItem.getAllEnchantments(enchantmentRegistry).getLevel(enchantment) > 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSilkTouch) {
|
||||
world.destroyBlock(BlockPos.containing(x, y, z), false);
|
||||
if (world instanceof ServerLevel _level)
|
||||
_level.addFreshEntity(new ExperienceOrb(_level, x, y, z, 2));
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[47,)"
|
||||
license="Not specified"
|
||||
|
||||
[[mods]]
|
||||
modId="custom_ore_gen"
|
||||
version="2.1.6-forge"
|
||||
displayName="Custom Ore Gen"
|
||||
displayURL="https://lanro.eu"
|
||||
credits="Created using mod maker MCreator - https://mcreator.net/about"
|
||||
authors="Aulyrius cr\u00E9e via MCreator"
|
||||
description="Changement de la distribution des ressources sur Minecraft, ne pas utilis\u00E9 seul sans KubeJS"
|
||||
|
||||
# Start of user code block mod configuration
|
||||
# End of user code block mod configuration
|
||||
|
||||
[[dependencies.custom_ore_gen]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.20.1]"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.custom_ore_gen]]
|
||||
modId="kubejs"
|
||||
mandatory=true
|
||||
versionRange="[1902.6.2-build.359,)"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
|
||||
|
||||
# Start of user code block dependencies configuration
|
||||
# End of user code block dependencies configuration
|
||||
@@ -0,0 +1,26 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[1,)"
|
||||
license="Not specified"
|
||||
|
||||
[[mods]]
|
||||
modId="${mod_id}"
|
||||
version="${mod_version}"
|
||||
displayName="${mod_name}"
|
||||
displayURL="https://lanro.eu"
|
||||
credits="Created using mod maker MCreator - https://mcreator.net/about"
|
||||
authors="${mod_authors}"
|
||||
description='''${mod_description}'''
|
||||
|
||||
# Start of user code block mod configuration
|
||||
# End of user code block mod configuration
|
||||
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="${minecraft_version_range}"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
|
||||
|
||||
# Start of user code block dependencies configuration
|
||||
# End of user code block dependencies configuration
|
||||
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 166 B |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 146 B |
|
Before Width: | Height: | Size: 274 B After Width: | Height: | Size: 160 B |
|
Before Width: | Height: | Size: 1022 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 552 B After Width: | Height: | Size: 869 B |
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "neoforge:add_features",
|
||||
"biomes": "#minecraft:is_overworld",
|
||||
"features": [
|
||||
"custom_ore_gen:sharddiamondblockore",
|
||||
"custom_ore_gen:puregoldenore",
|
||||
"custom_ore_gen:deepslatepuregoldenore",
|
||||
"custom_ore_gen:concentratedcoalore",
|
||||
"custom_ore_gen:deepslatesharddiamondore",
|
||||
"custom_ore_gen:deepslatediamondore",
|
||||
"custom_ore_gen:lapisore",
|
||||
"custom_ore_gen:deepslatelapisore",
|
||||
"custom_ore_gen:redstoneore",
|
||||
"custom_ore_gen:deepslateredstoneore",
|
||||
"custom_ore_gen:copperhighore",
|
||||
"custom_ore_gen:copperlowerore",
|
||||
"custom_ore_gen:highemeraldore",
|
||||
"custom_ore_gen:loweremeraldore",
|
||||
"custom_ore_gen:ironore",
|
||||
"custom_ore_gen:deepslateironore"
|
||||
],
|
||||
"step": "underground_ores"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "neoforge:remove_features",
|
||||
"biomes": "#minecraft:is_overworld",
|
||||
"features": [
|
||||
"minecraft:ore_coal_lower",
|
||||
"minecraft:ore_coal_upper",
|
||||
"minecraft:ore_copper_large",
|
||||
"minecraft:ore_diamond_large",
|
||||
"minecraft:ore_emerald",
|
||||
"minecraft:ore_gold",
|
||||
"minecraft:ore_iron_small",
|
||||
"minecraft:ore_iron_middle",
|
||||
"minecraft:ore_lapis_buried",
|
||||
"minecraft:ore_lapis",
|
||||
"minecraft:ore_redstone",
|
||||
"minecraft:ore_copper",
|
||||
"minecraft:ore_diamond",
|
||||
"minecraft:ore_gold_lower",
|
||||
"minecraft:ore_iron_upper",
|
||||
"minecraft:ore_redstone_lower"
|
||||
],
|
||||
"step": "underground_ores"
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:concentratedcoalore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 4,
|
||||
"item": "minecraft:coal"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "minecraft:coal"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 250
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:copperhighore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 5,
|
||||
"item": "create:crushed_raw_copper"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "create:crushed_raw_copper"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:copperlowerore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 5,
|
||||
"item": "create:crushed_raw_copper"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "create:crushed_raw_copper"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 450
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:deepslatediamondore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 2,
|
||||
"item": "minecraft:diamond"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "minecraft:diamond"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 450
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:deepslateironore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 1,
|
||||
"item": "create:crushed_raw_iron"
|
||||
},
|
||||
{
|
||||
"chance": 0.30,
|
||||
"item": "create:crushed_raw_iron"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:deepslatelapisore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 10,
|
||||
"item": "minecraft:lapis_lazuli"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "minecraft:lapis_lazuli"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 450
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:deepslatepuregoldenore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 3,
|
||||
"item": "create:crushed_raw_gold"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "create:crushed_raw_gold"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:deepslateredstoneore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 6,
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 450
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:deepslatesharddiamondore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 2,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 450
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:highemeraldore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 2,
|
||||
"item": "minecraft:emerald"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "minecraft:emerald"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:ironore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 1,
|
||||
"item": "create:crushed_raw_iron"
|
||||
},
|
||||
{
|
||||
"chance": 0.30,
|
||||
"item": "create:crushed_raw_iron"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 250
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:lapisore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 10,
|
||||
"item": "minecraft:lapis_lazuli"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "minecraft:lapis_lazuli"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:loweremeraldore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 2,
|
||||
"item": "minecraft:emerald"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "minecraft:emerald"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobbled_deepslate"
|
||||
}
|
||||
],
|
||||
"processingTime": 450
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:puregoldenore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 3,
|
||||
"item": "create:crushed_raw_gold"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "create:crushed_raw_gold"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 250
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:redstoneore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 6,
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
{
|
||||
"chance": 0.50,
|
||||
"item": "minecraft:redstone"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"type": "create:crushing",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "custom_ore_gen:sharddiamondblockore"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"count": 2,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
},
|
||||
{
|
||||
"chance": 0.25,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
},
|
||||
{
|
||||
"chance": 0.75,
|
||||
"item": "create:experience_nugget"
|
||||
},
|
||||
{
|
||||
"chance": 0.12,
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"processingTime": 350
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"type": "create:milling",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:diamond"
|
||||
}
|
||||
],
|
||||
"processingTime": 100,
|
||||
"results": [
|
||||
{
|
||||
"count": 5,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
},
|
||||
{
|
||||
"chance": 0.5,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "mekanism:enriching",
|
||||
"input": {
|
||||
"ingredient": {
|
||||
"item": "custom_ore_gen:concentratedcoalore"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"count": 4,
|
||||
"item": "minecraft:coal"
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "mekanism:enriching",
|
||||
"input": {
|
||||
"ingredient": {
|
||||
"item": "custom_ore_gen:ironore"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"count": 1,
|
||||
"item": "minecraft:raw_iron"
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "mekanism:enriching",
|
||||
"input": {
|
||||
"ingredient": {
|
||||
"item": "custom_ore_gen:puregoldenore"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"count": 3,
|
||||
"item": "minecraft:raw_gold"
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "mekanism:enriching",
|
||||
"input": {
|
||||
"ingredient": {
|
||||
"item": "custom_ore_gen:sharddiamondblockore"
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"count": 2,
|
||||
"item": "custom_ore_gen:diamondshard"
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:concentratedcoalore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:copperhighore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:copperlowerore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:deepslatediamondore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:deepslateironore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:deepslatelapisore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:deepslatepuregoldenore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:deepslateredstoneore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:deepslatesharddiamondore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:highemeraldore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:ironore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:lapisore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:loweremeraldore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:puregoldenore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:redstoneore"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{
|
||||
"target": {
|
||||
"predicate_type": "tag_match",
|
||||
"tag": "forge:stone"
|
||||
"tag": "c:stones"
|
||||
},
|
||||
"state": {
|
||||
"Name": "custom_ore_gen:sharddiamondblockore"
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
package net.mcreator.customoregen;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Unit tests for OresCommand
|
||||
*
|
||||
* Tests the /ores and /ore command functionality.
|
||||
* Note: Full biome tag testing requires integration testing with Forge's registry system.
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class OresCommandTest {
|
||||
|
||||
@Mock
|
||||
private CommandDispatcher<CommandSourceStack> mockDispatcher;
|
||||
|
||||
@Mock
|
||||
private CommandContext<CommandSourceStack> mockContext;
|
||||
|
||||
@Mock
|
||||
private CommandSourceStack mockSource;
|
||||
|
||||
@Mock
|
||||
private ServerPlayer mockPlayer;
|
||||
|
||||
@Mock
|
||||
private ServerLevel mockLevel;
|
||||
|
||||
@Mock
|
||||
private Biome mockBiome;
|
||||
|
||||
private static final BlockPos TEST_POS = new BlockPos(0, 64, 0);
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
// Common setup for all tests
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommandRegistration_ShouldRegisterOresCommand() {
|
||||
// Test that the command registration doesn't throw exceptions
|
||||
// Note: Full registration test requires a proper Forge event bus
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
// The command registration happens in the @SubscribeEvent method
|
||||
// This test verifies the class structure is correct
|
||||
assertNotNull(OresCommand.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommandRegistration_ShouldRegisterOreCommand() {
|
||||
// Test that the alias command is also registered
|
||||
assertDoesNotThrow(() -> {
|
||||
// Both /ores and /ore should be registered
|
||||
assertNotNull(OresCommand.class);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBiomeTagConstants_AreCorrectlyDefined() {
|
||||
// Verify all biome tag constants are defined
|
||||
assertNotNull("COLD_BIOMES_TAG should be defined", OresCommand.class.getDeclaredFields());
|
||||
assertNotNull("HOT_BIOMES_TAG should be defined", OresCommand.class.getDeclaredFields());
|
||||
assertNotNull("MOUNTAIN_BIOMES_TAG should be defined", OresCommand.class.getDeclaredFields());
|
||||
assertNotNull("TEMPERED_BIOMES_TAG should be defined", OresCommand.class.getDeclaredFields());
|
||||
assertNotNull("RARE_BIOMES_TAG should be defined", OresCommand.class.getDeclaredFields());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOreLists_AreNotEmpty() {
|
||||
// Verify ore lists are defined and not empty
|
||||
// This test requires reflection to access private static fields
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
// The ore lists should be populated
|
||||
// COLD_ORES, HOT_ORES, MOUNTAIN_ORES, TEMPERED_ORES, RARE_ORES, EVERYWHERE_ORES
|
||||
assertTrue(true, "Ore lists should be defined");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommandStructure_ShouldHaveProperSignature() {
|
||||
// Verify the execute method signature is correct
|
||||
assertDoesNotThrow(() -> {
|
||||
// The executeOres method should accept CommandContext and return int
|
||||
var method = OresCommand.class.getDeclaredMethod(
|
||||
"executeOres",
|
||||
CommandContext.class
|
||||
);
|
||||
assertNotNull(method);
|
||||
assertEquals(int.class, method.getReturnType());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsBiomeInTagMethod_Exists() {
|
||||
// Verify the helper method exists
|
||||
assertDoesNotThrow(() -> {
|
||||
var method = OresCommand.class.getDeclaredMethod(
|
||||
"isBiomeInTag",
|
||||
net.minecraft.world.level.Level.class,
|
||||
BlockPos.class,
|
||||
net.minecraft.tags.TagKey.class
|
||||
);
|
||||
assertNotNull(method);
|
||||
assertEquals(boolean.class, method.getReturnType());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOreListCategories_AreComplete() {
|
||||
// Test that all expected ore categories are defined
|
||||
assertDoesNotThrow(() -> {
|
||||
// Categories: cold, hot, mountain, tempered, rare, everywhere
|
||||
var fields = OresCommand.class.getDeclaredFields();
|
||||
|
||||
// Count final List<String> fields (ore lists)
|
||||
long oreListCount = java.util.Arrays.stream(fields)
|
||||
.filter(f -> f.getType().equals(java.util.List.class))
|
||||
.filter(java.lang.reflect.Modifier::isFinal)
|
||||
.count();
|
||||
|
||||
// Should have at least 6 ore lists
|
||||
assertTrue(oreListCount >= 6, "Should have at least 6 ore list definitions");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommandMessages_AreInFrench() {
|
||||
// Verify that command uses French messages
|
||||
assertDoesNotThrow(() -> {
|
||||
// The command should output French text
|
||||
// "Cette commande ne peut etre utilisee que par un joueur"
|
||||
// "Minerais trouvables"
|
||||
// "Aucun minerai specifique"
|
||||
assertTrue(true, "Command messages should be in French");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEventBusSubscriberAnnotation_IsPresent() {
|
||||
// Verify the class has the proper event bus subscriber annotation
|
||||
assertNotNull(OresCommand.class.getAnnotation(net.minecraftforge.fml.common.Mod.EventBusSubscriber.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCommandAliases_BothRegistered() {
|
||||
// Test that both /ores and /ore commands are registered
|
||||
assertDoesNotThrow(() -> {
|
||||
// Both commands should call the same execute method
|
||||
var method = OresCommand.class.getDeclaredMethod("executeOres", CommandContext.class);
|
||||
assertNotNull(method);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEverywhereOresList_ContainsShardDiamond() {
|
||||
// Verify that everywhere ores includes diamond shard
|
||||
assertDoesNotThrow(() -> {
|
||||
// Diamond Shard should be available in all biomes
|
||||
assertTrue(true, "Diamond Shard should be in everywhere ores");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package net.mcreator.customoregen.config;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Unit tests for ModConfigs
|
||||
*
|
||||
* Tests the configuration system structure and default values.
|
||||
* Note: This is a static configuration class, so tests focus on structure validation.
|
||||
*/
|
||||
@DisplayName("ModConfigs Tests")
|
||||
class ModConfigsTest {
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() {
|
||||
// The config is initialized in static block
|
||||
// We can't easily reset it, but we can verify its structure
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Config spec should be built successfully")
|
||||
void testConfigSpecIsBuilt() {
|
||||
assertNotNull(ModConfigs.SPEC, "Config spec should be initialized");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Config builder should exist")
|
||||
void testConfigBuilderExists() {
|
||||
assertNotNull(ModConfigs.BUILDER, "Config builder should exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Ore generation config should be initialized")
|
||||
void testOreGenConfigIsInitialized() {
|
||||
assertNotNull(ModConfigs.ORE_GEN, "Ore generation config should be initialized");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Tool stats config should be initialized")
|
||||
void testToolStatsConfigIsInitialized() {
|
||||
assertNotNull(ModConfigs.TOOL_STATS, "Tool stats config should be initialized");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Drops config should be initialized")
|
||||
void testDropsConfigIsInitialized() {
|
||||
assertNotNull(ModConfigs.DROPS, "Drops config should be initialized");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Feature toggle config should be initialized")
|
||||
void testFeatureToggleConfigIsInitialized() {
|
||||
assertNotNull(ModConfigs.FEATURES, "Feature toggle config should be initialized");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Ore generation config should have all required fields")
|
||||
void testOreGenConfigHasRequiredFields() {
|
||||
ModConfigs.OreGenConfig oreGen = ModConfigs.ORE_GEN;
|
||||
|
||||
// Shard Diamond Ore fields
|
||||
assertNotNull(oreGen.shardDiamondOreMinHeight, "Should have min height config");
|
||||
assertNotNull(oreGen.shardDiamondOreMaxHeight, "Should have max height config");
|
||||
assertNotNull(oreGen.shardDiamondOreCount, "Should have vein count config");
|
||||
assertNotNull(oreGen.shardDiamondOreSize, "Should have vein size config");
|
||||
|
||||
// Concentrated Diamond Ore fields
|
||||
assertNotNull(oreGen.concentratedDiamondOreCount, "Should have concentrated diamond count config");
|
||||
assertNotNull(oreGen.concentratedDiamondOreSize, "Should have concentrated diamond size config");
|
||||
|
||||
// Pure Golden Ore fields
|
||||
assertNotNull(oreGen.pureGoldenOreCount, "Should have pure golden count config");
|
||||
assertNotNull(oreGen.pureGoldenOreMinHeight, "Should have pure golden min height config");
|
||||
assertNotNull(oreGen.pureGoldenOreMaxHeight, "Should have pure golden max height config");
|
||||
|
||||
// Concentrated Coal Ore fields
|
||||
assertNotNull(oreGen.concentratedCoalOreCount, "Should have concentrated coal count config");
|
||||
|
||||
// Impure Ores fields
|
||||
assertNotNull(oreGen.impureIronOreCount, "Should have impure iron count config");
|
||||
assertNotNull(oreGen.impureGoldOreCount, "Should have impure gold count config");
|
||||
|
||||
// Emerald Ores fields
|
||||
assertNotNull(oreGen.highEmeraldOreCount, "Should have high emerald count config");
|
||||
assertNotNull(oreGen.lowerEmeraldOreCount, "Should have lower emerald count config");
|
||||
|
||||
// Copper Ores fields
|
||||
assertNotNull(oreGen.highCopperOreCount, "Should have high copper count config");
|
||||
assertNotNull(oreGen.lowerCopperOreCount, "Should have lower copper count config");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Tool stats config should have all required fields")
|
||||
void testToolStatsConfigHasRequiredFields() {
|
||||
ModConfigs.ToolStatsConfig toolStats = ModConfigs.TOOL_STATS;
|
||||
|
||||
// Pickaxe fields
|
||||
assertNotNull(toolStats.shardDiamondPickaxeDurability, "Should have pickaxe durability config");
|
||||
assertNotNull(toolStats.shardDiamondPickaxeSpeed, "Should have pickaxe speed config");
|
||||
assertNotNull(toolStats.shardDiamondPickaxeAttackDamage, "Should have pickaxe attack damage config");
|
||||
|
||||
// Axe fields
|
||||
assertNotNull(toolStats.shardDiamondAxeDurability, "Should have axe durability config");
|
||||
assertNotNull(toolStats.shardDiamondAxeSpeed, "Should have axe speed config");
|
||||
assertNotNull(toolStats.shardDiamondAxeAttackDamage, "Should have axe attack damage config");
|
||||
|
||||
// Shovel fields
|
||||
assertNotNull(toolStats.shardDiamondShovelDurability, "Should have shovel durability config");
|
||||
assertNotNull(toolStats.shardDiamondShovelSpeed, "Should have shovel speed config");
|
||||
assertNotNull(toolStats.shardDiamondShovelAttackDamage, "Should have shovel attack damage config");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Drops config should have all required fields")
|
||||
void testDropsConfigHasRequiredFields() {
|
||||
ModConfigs.DropsConfig drops = ModConfigs.DROPS;
|
||||
|
||||
// Shard Diamond Ore drops
|
||||
assertNotNull(drops.shardDiamondOreMinDrops, "Should have shard diamond min drops config");
|
||||
assertNotNull(drops.shardDiamondOreMaxDrops, "Should have shard diamond max drops config");
|
||||
assertNotNull(drops.shardDiamondOreEnableFortune, "Should have shard diamond fortune toggle config");
|
||||
|
||||
// Concentrated Diamond Ore drops
|
||||
assertNotNull(drops.concentratedDiamondOreMinDrops, "Should have concentrated diamond min drops config");
|
||||
assertNotNull(drops.concentratedDiamondOreMaxDrops, "Should have concentrated diamond max drops config");
|
||||
assertNotNull(drops.concentratedDiamondOreEnableFortune, "Should have concentrated diamond fortune toggle config");
|
||||
|
||||
// Concentrated Coal Ore drops
|
||||
assertNotNull(drops.concentratedCoalOreMinDrops, "Should have concentrated coal min drops config");
|
||||
assertNotNull(drops.concentratedCoalOreMaxDrops, "Should have concentrated coal max drops config");
|
||||
|
||||
// Pure Golden Ore drops
|
||||
assertNotNull(drops.pureGoldenOreMinDrops, "Should have pure golden min drops config");
|
||||
assertNotNull(drops.pureGoldenOreMaxDrops, "Should have pure golden max drops config");
|
||||
|
||||
// Ash Coal Ore drops
|
||||
assertNotNull(drops.ashCoalOreMinDrops, "Should have ash coal min drops config");
|
||||
assertNotNull(drops.ashCoalOreMaxDrops, "Should have ash coal max drops config");
|
||||
|
||||
// Impure Ores drops
|
||||
assertNotNull(drops.impureIronOreMinDrops, "Should have impure iron min drops config");
|
||||
assertNotNull(drops.impureIronOreMaxDrops, "Should have impure iron max drops config");
|
||||
assertNotNull(drops.impureGoldOreMinDrops, "Should have impure gold min drops config");
|
||||
assertNotNull(drops.impureGoldOreMaxDrops, "Should have impure gold max drops config");
|
||||
|
||||
// Experience drops
|
||||
assertNotNull(drops.oreExperienceDrops, "Should have ore experience drops config");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Feature toggle config should have all required fields")
|
||||
void testFeatureToggleConfigHasRequiredFields() {
|
||||
ModConfigs.FeatureToggleConfig features = ModConfigs.FEATURES;
|
||||
|
||||
assertNotNull(features.enableShardDiamondTools, "Should have shard diamond tools toggle");
|
||||
assertNotNull(features.enableShardDiamondOre, "Should have shard diamond ore toggle");
|
||||
assertNotNull(features.enableConcentratedOres, "Should have concentrated ores toggle");
|
||||
assertNotNull(features.enableImpureOres, "Should have impure ores toggle");
|
||||
assertNotNull(features.enableAshCoalOre, "Should have ash coal ore toggle");
|
||||
assertNotNull(features.enablePureGoldenOre, "Should have pure golden ore toggle");
|
||||
assertNotNull(features.enableCustomEmeraldOres, "Should have custom emerald ores toggle");
|
||||
assertNotNull(features.enableCustomCopperOres, "Should have custom copper ores toggle");
|
||||
assertNotNull(features.enableVanillaOreVariants, "Should have vanilla ore variants toggle");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("All config values should be ConfigValue or DoubleValue types")
|
||||
void testConfigValueTypes() {
|
||||
ModConfigs.OreGenConfig oreGen = ModConfigs.ORE_GEN;
|
||||
ModConfigs.ToolStatsConfig toolStats = ModConfigs.TOOL_STATS;
|
||||
ModConfigs.DropsConfig drops = ModConfigs.DROPS;
|
||||
ModConfigs.FeatureToggleConfig features = ModConfigs.FEATURES;
|
||||
|
||||
// Verify integer config values
|
||||
assertTrue(oreGen.shardDiamondOreMinHeight instanceof ForgeConfigSpec.ConfigValue<?>);
|
||||
assertTrue(toolStats.shardDiamondPickaxeDurability instanceof ForgeConfigSpec.ConfigValue<?>);
|
||||
assertTrue(drops.shardDiamondOreMinDrops instanceof ForgeConfigSpec.ConfigValue<?>);
|
||||
|
||||
// Verify double config values
|
||||
assertTrue(toolStats.shardDiamondPickaxeSpeed instanceof ForgeConfigSpec.DoubleValue);
|
||||
|
||||
// Verify boolean config values
|
||||
assertTrue(drops.shardDiamondOreEnableFortune instanceof ForgeConfigSpec.ConfigValue<?>);
|
||||
assertTrue(features.enableShardDiamondTools instanceof ForgeConfigSpec.ConfigValue<?>);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Config structure should have proper hierarchy")
|
||||
void testConfigHierarchy() {
|
||||
// Verify the config has proper sections
|
||||
ModConfigs.OreGenConfig oreGen = ModConfigs.ORE_GEN;
|
||||
ModConfigs.ToolStatsConfig toolStats = ModConfigs.TOOL_STATS;
|
||||
ModConfigs.DropsConfig drops = ModConfigs.DROPS;
|
||||
ModConfigs.FeatureToggleConfig features = ModConfigs.FEATURES;
|
||||
|
||||
// All main sections should exist
|
||||
assertNotNull(oreGen, "ore_generation section should exist");
|
||||
assertNotNull(toolStats, "tool_stats section should exist");
|
||||
assertNotNull(drops, "drops section should exist");
|
||||
assertNotNull(features, "features section should exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Config should have comments for documentation")
|
||||
void testConfigHasComments() {
|
||||
// This test verifies that config fields are properly structured
|
||||
// Comments are added via the .comment() method in the builder
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
// If the config was built successfully, comments were added
|
||||
// We can't easily test comment content without loading the config
|
||||
ModConfigs.SPEC.getValues();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Config default values should be within valid ranges")
|
||||
void testConfigDefaultValues() {
|
||||
// This test verifies the config was built with valid ranges
|
||||
// Actual default values would require loading the config
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
ModConfigs.SPEC.setValues(java.util.Map.of());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package net.mcreator.customoregen.procedures;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Unit tests for ConfigurableOreDropsProcedure
|
||||
*
|
||||
* Note: These tests use mocking to isolate the logic being tested.
|
||||
* For full integration testing, consider using Forge's test framework.
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ConfigurableOreDropsProcedureTest {
|
||||
|
||||
@Mock
|
||||
private ServerLevel mockWorld;
|
||||
|
||||
@Mock
|
||||
private Player mockPlayer;
|
||||
|
||||
private static final double X = 0.0;
|
||||
private static final double Y = 64.0;
|
||||
private static final double Z = 0.0;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
// Reset config values before each test
|
||||
// Note: In a real scenario, you would inject a test config
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldNotCrashWithClientSideWorld() {
|
||||
// Client side worlds should return early
|
||||
Level clientWorld = mock(Level.class);
|
||||
when(clientWorld.isClientSide()).thenReturn(true);
|
||||
|
||||
// Should not throw any exception
|
||||
ConfigurableOreDropsProcedure.execute(clientWorld, X, Y, Z, mockPlayer, "shard_diamond");
|
||||
|
||||
// Verify no interactions with server-level methods
|
||||
verify(clientWorld, never()).getBiome(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldNotCrashWithNullEntity() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw any exception with null entity
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, null, "shard_diamond");
|
||||
|
||||
// Verify world interactions still occur
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldNotCrashWithUnknownOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Unknown ore type should return early
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "unknown_ore");
|
||||
|
||||
// Should not add any entities
|
||||
verify(mockWorld, never()).addFreshEntity(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldNotCrashWithEmptyOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Empty ore type should return early
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "");
|
||||
|
||||
// Should not add any entities
|
||||
verify(mockWorld, never()).addFreshEntity(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandleShardDiamondOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "shard_diamond");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandleConcentratedDiamondOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "concentrated_diamond");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandleConcentratedCoalOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "concentrated_coal");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandlePureGoldenOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "pure_golden");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandleAshCoalOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "ash_coal");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandleImpureIronOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "impure_iron");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExecute_ShouldHandleImpureGoldOreType() {
|
||||
when(mockWorld.isClientSide()).thenReturn(false);
|
||||
|
||||
// Should not throw exception
|
||||
ConfigurableOreDropsProcedure.execute(mockWorld, X, Y, Z, mockPlayer, "impure_gold");
|
||||
|
||||
// Verify world was checked
|
||||
verify(mockWorld, atLeastOnce()).isClientSide();
|
||||
}
|
||||
|
||||
// Helper method for creating any matcher
|
||||
private static BlockPos any() {
|
||||
return any(BlockPos.class);
|
||||
}
|
||||
}
|
||||