refactor: remove dead code (drops, configs, procedures, data files)
- Delete OreexperienceProcedure: no-op class (all effects commented out) - ConfigurableOreDropsProcedure: drop the dead item-drop computation (result only consumed by a commented-out block; drops are handled by the GLM). Keep silk-touch check + XP orb. ~130 lines removed. - CustomOreGenMod: remove unused queueServerWork/workQueue/tick and the GAME bus registration that only served them (MCreator leftover) - ConfigHelper: remove never-called tool stat getters and the shardDiamondTools case - ModConfigs: remove never-read entries (oreExperienceDrops, impureGoldOre min/max, armorKnockbackResistance, enableShardDiamondTools). ModConfigSpec ignores stale keys in existing player config files, so this is safe. - LatitudeConfig: remove never-called update(); use the ModConfigs import instead of fully-qualified names - Delete dead data files: data/neoforge/loot_modifiers/ (old Forge GLM path, ignored by NeoForge), custom_ore_gen-common.toml in resources (stale artifact), empty mcreator.gradle - Remove unused imports (ModLoadingContext, EnchantmentHelper, ...)
This commit is contained in:
@@ -4,17 +4,8 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
import net.neoforged.fml.ModContainer;
|
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.fml.common.Mod;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.bus.api.IEventBus;
|
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.core.registries.Registries;
|
|
||||||
|
|
||||||
import net.mcreator.customoregen.init.CustomOreGenModTabs;
|
import net.mcreator.customoregen.init.CustomOreGenModTabs;
|
||||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||||
@@ -31,11 +22,6 @@ import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
|||||||
import net.mcreator.customoregen.loot.CustomOreLootModifier;
|
import net.mcreator.customoregen.loot.CustomOreLootModifier;
|
||||||
import net.mcreator.customoregen.worldgen.WorldGenRegistration;
|
import net.mcreator.customoregen.worldgen.WorldGenRegistration;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
|
|
||||||
@Mod(CustomOreGenMod.MODID)
|
@Mod(CustomOreGenMod.MODID)
|
||||||
public class CustomOreGenMod {
|
public class CustomOreGenMod {
|
||||||
@@ -49,8 +35,6 @@ public class CustomOreGenMod {
|
|||||||
LOOT_MODIFIERS.register("custom_ore_drops", () -> CustomOreLootModifier.CODEC);
|
LOOT_MODIFIERS.register("custom_ore_drops", () -> CustomOreLootModifier.CODEC);
|
||||||
// End of user code block mod constructor
|
// End of user code block mod constructor
|
||||||
|
|
||||||
NeoForge.EVENT_BUS.register(this);
|
|
||||||
|
|
||||||
CustomOreGenModBlocks.REGISTRY.register(modEventBus);
|
CustomOreGenModBlocks.REGISTRY.register(modEventBus);
|
||||||
CustomOreGenModItems.REGISTRY.register(modEventBus);
|
CustomOreGenModItems.REGISTRY.register(modEventBus);
|
||||||
ShardDiamondArmorMaterial.REGISTRY.register(modEventBus);
|
ShardDiamondArmorMaterial.REGISTRY.register(modEventBus);
|
||||||
@@ -67,22 +51,4 @@ public class CustomOreGenMod {
|
|||||||
|
|
||||||
// Start of user code block mod methods
|
// Start of user code block mod methods
|
||||||
// End of user code block mod methods
|
// End of user code block mod methods
|
||||||
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueue = new ConcurrentLinkedQueue<>();
|
|
||||||
|
|
||||||
public static void queueServerWork(int tick, Runnable action) {
|
|
||||||
if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER)
|
|
||||||
workQueue.add(new AbstractMap.SimpleEntry<>(action, tick));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
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,13 +1,9 @@
|
|||||||
package net.mcreator.customoregen.config;
|
package net.mcreator.customoregen.config;
|
||||||
|
|
||||||
import net.neoforged.fml.ModList;
|
|
||||||
|
|
||||||
public class ConfigHelper {
|
public class ConfigHelper {
|
||||||
// Helper method to safely access config values
|
// Helper method to safely access config values
|
||||||
public static boolean isFeatureEnabled(String featureName) {
|
public static boolean isFeatureEnabled(String featureName) {
|
||||||
switch (featureName) {
|
switch (featureName) {
|
||||||
case "shardDiamondTools":
|
|
||||||
return ModConfigs.FEATURES.enableShardDiamondTools.get();
|
|
||||||
case "shardDiamondOre":
|
case "shardDiamondOre":
|
||||||
return ModConfigs.FEATURES.enableShardDiamondOre.get();
|
return ModConfigs.FEATURES.enableShardDiamondOre.get();
|
||||||
case "concentratedOres":
|
case "concentratedOres":
|
||||||
@@ -26,43 +22,4 @@ public class ConfigHelper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getShardDiamondToolDurability(String toolType) {
|
|
||||||
switch (toolType) {
|
|
||||||
case "pickaxe":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get();
|
|
||||||
case "axe":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondAxeDurability.get();
|
|
||||||
case "shovel":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondShovelDurability.get();
|
|
||||||
default:
|
|
||||||
return 200;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getShardDiamondToolSpeed(String toolType) {
|
|
||||||
switch (toolType) {
|
|
||||||
case "pickaxe":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondPickaxeSpeed.get().floatValue();
|
|
||||||
case "axe":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondAxeSpeed.get().floatValue();
|
|
||||||
case "shovel":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondShovelSpeed.get().floatValue();
|
|
||||||
default:
|
|
||||||
return 7.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getShardDiamondToolDamage(String toolType) {
|
|
||||||
switch (toolType) {
|
|
||||||
case "pickaxe":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondPickaxeAttackDamage.get();
|
|
||||||
case "axe":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondAxeAttackDamage.get();
|
|
||||||
case "shovel":
|
|
||||||
return ModConfigs.TOOL_STATS.shardDiamondShovelAttackDamage.get();
|
|
||||||
default:
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,6 @@ public class ModConfigs {
|
|||||||
shardDiamondArmorToughness = builder
|
shardDiamondArmorToughness = builder
|
||||||
.comment("Toughness of Shard Diamond Armor (default: 1.0)")
|
.comment("Toughness of Shard Diamond Armor (default: 1.0)")
|
||||||
.defineInRange("armorToughness", 1.0, 0.0, 10.0);
|
.defineInRange("armorToughness", 1.0, 0.0, 10.0);
|
||||||
shardDiamondArmorKnockbackResistance = builder
|
|
||||||
.comment("Knockback resistance of Shard Diamond Armor (default: 0.0)")
|
|
||||||
.defineInRange("armorKnockbackResistance", 0.0, 0.0, 1.0);
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
@@ -117,7 +114,6 @@ public class ModConfigs {
|
|||||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondLeggingsDurability;
|
public final ModConfigSpec.ConfigValue<Integer> shardDiamondLeggingsDurability;
|
||||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondBootsDurability;
|
public final ModConfigSpec.ConfigValue<Integer> shardDiamondBootsDurability;
|
||||||
public final ModConfigSpec.DoubleValue shardDiamondArmorToughness;
|
public final ModConfigSpec.DoubleValue shardDiamondArmorToughness;
|
||||||
public final ModConfigSpec.DoubleValue shardDiamondArmorKnockbackResistance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration pour les drops des minerais
|
// Configuration pour les drops des minerais
|
||||||
@@ -142,9 +138,6 @@ public class ModConfigs {
|
|||||||
public final ModConfigSpec.ConfigValue<Integer> impureIronOreMaxDrops;
|
public final ModConfigSpec.ConfigValue<Integer> impureIronOreMaxDrops;
|
||||||
public final ModConfigSpec.BooleanValue impureIronOreEnableFortune;
|
public final ModConfigSpec.BooleanValue impureIronOreEnableFortune;
|
||||||
|
|
||||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMinDrops;
|
|
||||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMaxDrops;
|
|
||||||
|
|
||||||
public final ModConfigSpec.ConfigValue<Integer> lapisOreMinDrops;
|
public final ModConfigSpec.ConfigValue<Integer> lapisOreMinDrops;
|
||||||
public final ModConfigSpec.ConfigValue<Integer> lapisOreMaxDrops;
|
public final ModConfigSpec.ConfigValue<Integer> lapisOreMaxDrops;
|
||||||
public final ModConfigSpec.BooleanValue lapisOreEnableFortune;
|
public final ModConfigSpec.BooleanValue lapisOreEnableFortune;
|
||||||
@@ -160,9 +153,6 @@ public class ModConfigs {
|
|||||||
public final ModConfigSpec.ConfigValue<Integer> copperOreMaxDrops;
|
public final ModConfigSpec.ConfigValue<Integer> copperOreMaxDrops;
|
||||||
public final ModConfigSpec.BooleanValue copperOreEnableFortune;
|
public final ModConfigSpec.BooleanValue copperOreEnableFortune;
|
||||||
|
|
||||||
public final ModConfigSpec.ConfigValue<Integer> oreExperienceDrops;
|
|
||||||
|
|
||||||
|
|
||||||
public DropsConfig(ModConfigSpec.Builder builder) {
|
public DropsConfig(ModConfigSpec.Builder builder) {
|
||||||
builder.push("drops");
|
builder.push("drops");
|
||||||
|
|
||||||
@@ -224,12 +214,6 @@ public class ModConfigs {
|
|||||||
impureIronOreEnableFortune = builder
|
impureIronOreEnableFortune = builder
|
||||||
.comment("Enable Fortune enchantment on Iron Ore (default: false) - vanilla iron/gold ores ignore Fortune")
|
.comment("Enable Fortune enchantment on Iron Ore (default: false) - vanilla iron/gold ores ignore Fortune")
|
||||||
.define("enableFortune", false);
|
.define("enableFortune", false);
|
||||||
impureGoldOreMinDrops = builder
|
|
||||||
.comment("Minimum raw gold dropped by Impure Gold Ore (default: 1)")
|
|
||||||
.defineInRange("goldMinDrops", 1, 0, 64);
|
|
||||||
impureGoldOreMaxDrops = builder
|
|
||||||
.comment("Maximum raw gold dropped by Impure Gold Ore (default: 1)")
|
|
||||||
.defineInRange("goldMaxDrops", 1, 0, 64);
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
builder.push("vanilla_ore_variants");
|
builder.push("vanilla_ore_variants");
|
||||||
@@ -267,19 +251,11 @@ public class ModConfigs {
|
|||||||
.comment("Enable Fortune enchantment on Copper Ore (default: true) - vanilla equivalent")
|
.comment("Enable Fortune enchantment on Copper Ore (default: true) - vanilla equivalent")
|
||||||
.define("enableFortune", true);
|
.define("enableFortune", true);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
oreExperienceDrops = builder
|
|
||||||
|
|
||||||
.comment("Experience dropped when mining custom ores (default: 2)")
|
|
||||||
.defineInRange("oreExperience", 2, 0, 100);
|
|
||||||
|
|
||||||
builder.pop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration pour activer/désactiver les fonctionnalités
|
// Configuration pour activer/désactiver les fonctionnalités
|
||||||
public static class FeatureToggleConfig {
|
public static class FeatureToggleConfig {
|
||||||
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondTools;
|
|
||||||
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondOre;
|
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondOre;
|
||||||
public final ModConfigSpec.ConfigValue<Boolean> enableConcentratedOres;
|
public final ModConfigSpec.ConfigValue<Boolean> enableConcentratedOres;
|
||||||
public final ModConfigSpec.ConfigValue<Boolean> enableImpureOres;
|
public final ModConfigSpec.ConfigValue<Boolean> enableImpureOres;
|
||||||
@@ -291,9 +267,6 @@ public class ModConfigs {
|
|||||||
public FeatureToggleConfig(ModConfigSpec.Builder builder) {
|
public FeatureToggleConfig(ModConfigSpec.Builder builder) {
|
||||||
builder.push("features");
|
builder.push("features");
|
||||||
|
|
||||||
enableShardDiamondTools = builder
|
|
||||||
.comment("Enable Shard Diamond Tools (default: true)")
|
|
||||||
.define("enableShardDiamondTools", true);
|
|
||||||
enableShardDiamondOre = builder
|
enableShardDiamondOre = builder
|
||||||
.comment("Enable Shard Diamond Ore generation (default: true)")
|
.comment("Enable Shard Diamond Ore generation (default: true)")
|
||||||
.define("enableShardDiamondOre", true);
|
.define("enableShardDiamondOre", true);
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
|||||||
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
||||||
import net.neoforged.neoforge.common.loot.LootModifier;
|
import net.neoforged.neoforge.common.loot.LootModifier;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|
||||||
import net.minecraft.world.item.enchantment.Enchantments;
|
import net.minecraft.world.item.enchantment.Enchantments;
|
||||||
|
|
||||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||||
|
|||||||
+16
-148
@@ -2,173 +2,41 @@ package net.mcreator.customoregen.procedures;
|
|||||||
|
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.item.ItemStack;
|
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.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.core.registries.Registries;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
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.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.world.entity.ExperienceOrb;
|
import net.minecraft.world.entity.ExperienceOrb;
|
||||||
|
|
||||||
import net.mcreator.customoregen.config.ModConfigs;
|
|
||||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the experience dropped when a player mines one of the mod's ores.
|
||||||
|
*
|
||||||
|
* <p>Item drops are handled separately by {@code CustomOreLootModifier} (a Global Loot
|
||||||
|
* Modifier) so machines (Create drills, Mekanism Digital Miner, ...) also get them.
|
||||||
|
* This procedure only spawns the XP orb, mirroring vanilla 1.21: no XP when the block
|
||||||
|
* is harvested with Silk Touch, and no XP for non-player breakers.</p>
|
||||||
|
*/
|
||||||
public class ConfigurableOreDropsProcedure {
|
public class ConfigurableOreDropsProcedure {
|
||||||
|
|
||||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, String oreType) {
|
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, String oreType) {
|
||||||
if (world.isClientSide())
|
if (world.isClientSide())
|
||||||
return;
|
return;
|
||||||
|
if (!(entity instanceof Player player))
|
||||||
|
return;
|
||||||
|
|
||||||
Random random = new Random();
|
// Silk Touch: vanilla ores drop no XP when silk-touched
|
||||||
int fortuneLevel = 0;
|
ItemStack tool = player.getMainHandItem();
|
||||||
boolean silkTouch = false;
|
|
||||||
|
|
||||||
// Get fortune and silk touch from the tool if mining by player
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
Player player = (Player) entity;
|
|
||||||
ItemStack mainHandItem = player.getMainHandItem();
|
|
||||||
// 1.21: Enchantment API changed - use getAllEnchantments with registry lookup
|
|
||||||
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||||
for (Holder<Enchantment> enchantment : mainHandItem.getAllEnchantments(enchantmentRegistry).keySet()) {
|
if (tool.getEnchantmentLevel(enchantmentRegistry.getOrThrow(Enchantments.SILK_TOUCH)) > 0) {
|
||||||
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
|
|
||||||
if (silkTouch) {
|
|
||||||
return; // Let vanilla handle silk touch
|
|
||||||
}
|
|
||||||
|
|
||||||
int minDrops = 1;
|
|
||||||
int maxDrops = 2;
|
|
||||||
boolean enableFortune = true;
|
|
||||||
ItemStack dropItem = ItemStack.EMPTY;
|
|
||||||
|
|
||||||
// Configure drops based on ore type
|
|
||||||
switch (oreType) {
|
|
||||||
case "shard_diamond":
|
|
||||||
minDrops = ModConfigs.DROPS.shardDiamondOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.shardDiamondOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.shardDiamondOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "concentrated_diamond":
|
|
||||||
minDrops = ModConfigs.DROPS.concentratedDiamondOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.concentratedDiamondOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.concentratedDiamondOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.DIAMOND);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "concentrated_coal":
|
|
||||||
minDrops = ModConfigs.DROPS.concentratedCoalOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.concentratedCoalOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.concentratedCoalOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.COAL);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "pure_golden":
|
|
||||||
minDrops = ModConfigs.DROPS.pureGoldenOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.pureGoldenOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.pureGoldenOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.RAW_GOLD);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "impure_iron":
|
|
||||||
minDrops = ModConfigs.DROPS.impureIronOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.impureIronOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.impureIronOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.RAW_IRON);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "impure_gold":
|
|
||||||
minDrops = ModConfigs.DROPS.impureGoldOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.impureGoldOreMaxDrops.get();
|
|
||||||
dropItem = new ItemStack(Items.RAW_GOLD);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "lapis":
|
|
||||||
minDrops = ModConfigs.DROPS.lapisOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.lapisOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.lapisOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.LAPIS_LAZULI);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "redstone":
|
|
||||||
minDrops = ModConfigs.DROPS.redstoneOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.redstoneOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.redstoneOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.REDSTONE);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "emerald":
|
|
||||||
minDrops = ModConfigs.DROPS.emeraldOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.emeraldOreMaxDrops.get();
|
|
||||||
dropItem = new ItemStack(Items.EMERALD);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "copper":
|
|
||||||
minDrops = ModConfigs.DROPS.copperOreMinDrops.get();
|
|
||||||
maxDrops = ModConfigs.DROPS.copperOreMaxDrops.get();
|
|
||||||
enableFortune = ModConfigs.DROPS.copperOreEnableFortune.get();
|
|
||||||
dropItem = new ItemStack(Items.RAW_COPPER);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate base drops + fortune (pure math, unit-tested via OreDropMath)
|
int expAmount = OreDropMath.experienceFor(oreType, new Random());
|
||||||
int dropCount = OreDropMath.dropCount(oreType, minDrops, maxDrops, enableFortune, fortuneLevel, random);
|
if (expAmount > 0 && world instanceof ServerLevel serverLevel) {
|
||||||
|
serverLevel.addFreshEntity(new ExperienceOrb(serverLevel, x + 0.5, y + 0.5, z + 0.5, expAmount));
|
||||||
/*
|
|
||||||
// ITEM DROPS ARE NOW HANDLED BY CustomLootModifier TO SUPPORT MACHINES (like Mekanism Digital Miner)
|
|
||||||
// This avoids duplicate drops for players and ensures machines get drops.
|
|
||||||
if (!dropItem.isEmpty() && dropCount > 0) {
|
|
||||||
dropItem.setCount(dropCount);
|
|
||||||
if (world instanceof ServerLevel) {
|
|
||||||
ItemEntity itemEntity = new ItemEntity(
|
|
||||||
(ServerLevel) world,
|
|
||||||
x + 0.5, y + 0.5, z + 0.5,
|
|
||||||
dropItem
|
|
||||||
);
|
|
||||||
itemEntity.setDefaultPickUpDelay();
|
|
||||||
((ServerLevel) world).addFreshEntity(itemEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Drop experience based on ore type (Vanilla 1.21 values, pure math in OreDropMath)
|
|
||||||
int expAmount = 0;
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
expAmount = OreDropMath.experienceFor(oreType, random);
|
|
||||||
|
|
||||||
if (expAmount > 0 && world instanceof ServerLevel) {
|
|
||||||
ExperienceOrb expOrb = new ExperienceOrb(
|
|
||||||
(ServerLevel) world,
|
|
||||||
x + 0.5, y + 0.5, z + 0.5,
|
|
||||||
expAmount
|
|
||||||
);
|
|
||||||
((ServerLevel) world).addFreshEntity(expOrb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package net.mcreator.customoregen.procedures;
|
|
||||||
|
|
||||||
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;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
|
|
||||||
public class OreexperienceProcedure {
|
|
||||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
// 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) {
|
|
||||||
// XP is now handled centrally in ConfigurableOreDropsProcedure to match Vanilla 1.21 values
|
|
||||||
// if (world instanceof ServerLevel _level)
|
|
||||||
// _level.addFreshEntity(new ExperienceOrb(_level, x, y, z, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,7 @@ public final class LatitudeConfig {
|
|||||||
/** Z threshold below which is the cold zone. Negative = north. */
|
/** Z threshold below which is the cold zone. Negative = north. */
|
||||||
public static int getColdZoneZ() {
|
public static int getColdZoneZ() {
|
||||||
try {
|
try {
|
||||||
return net.mcreator.customoregen.config.ModConfigs.LATITUDE_ORE.coldZoneZ.get();
|
return ModConfigs.LATITUDE_ORE.coldZoneZ.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return coldZoneZ;
|
return coldZoneZ;
|
||||||
}
|
}
|
||||||
@@ -36,18 +36,12 @@ public final class LatitudeConfig {
|
|||||||
/** Z threshold above which is the hot zone. Positive = south. */
|
/** Z threshold above which is the hot zone. Positive = south. */
|
||||||
public static int getHotZoneZ() {
|
public static int getHotZoneZ() {
|
||||||
try {
|
try {
|
||||||
return net.mcreator.customoregen.config.ModConfigs.LATITUDE_ORE.hotZoneZ.get();
|
return ModConfigs.LATITUDE_ORE.hotZoneZ.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return hotZoneZ;
|
return hotZoneZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called from the config load to update thresholds. */
|
|
||||||
public static void update(int coldZ, int hotZ) {
|
|
||||||
coldZoneZ = coldZ;
|
|
||||||
hotZoneZ = hotZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a human-readable description of the zone for a given Z. */
|
/** Returns a human-readable description of the zone for a given Z. */
|
||||||
public static String zoneName(int z) {
|
public static String zoneName(int z) {
|
||||||
if (z < getColdZoneZ()) return "COLD";
|
if (z < getColdZoneZ()) return "COLD";
|
||||||
|
|||||||
@@ -1,179 +0,0 @@
|
|||||||
|
|
||||||
#==========================
|
|
||||||
# Custom Ore Gem - Configuration
|
|
||||||
#==========================
|
|
||||||
# Ce fichier permet de personnaliser le mod Custom Ore Gem
|
|
||||||
# Modifiez ces valeurs pour ajuster la génération des minerais, les stats des outils et plus encore!
|
|
||||||
|
|
||||||
|
|
||||||
#==========================
|
|
||||||
# Génération des Minerais
|
|
||||||
#==========================
|
|
||||||
[ore_generation]
|
|
||||||
|
|
||||||
# Configuration du Minerai d'Éclats de Diamant
|
|
||||||
[ore_generation.shard_diamond_ore]
|
|
||||||
# Hauteur minimale de génération (par défaut: 0)
|
|
||||||
# Min: -64, Max: 320
|
|
||||||
minHeight = 0
|
|
||||||
# Hauteur maximale de génération (par défaut: 15)
|
|
||||||
# Min: -64, Max: 320
|
|
||||||
maxHeight = 15
|
|
||||||
# Nombre de filons par chunk (par défaut: 1)
|
|
||||||
# Min: 0, Max: 20
|
|
||||||
veinsPerChunk = 1
|
|
||||||
# Taille des filons (par défaut: 8)
|
|
||||||
# Min: 1, Max: 32
|
|
||||||
veinSize = 8
|
|
||||||
|
|
||||||
# Configuration du Minerai de Diamant Concentré
|
|
||||||
[ore_generation.concentrated_diamond_ore]
|
|
||||||
# Nombre de filons par chunk (par défaut: 1)
|
|
||||||
veinsPerChunk = 1
|
|
||||||
# Taille des filons (par défaut: 8)
|
|
||||||
veinSize = 8
|
|
||||||
|
|
||||||
# Configuration du Minerai d'Or Pur
|
|
||||||
[ore_generation.pure_golden_ore]
|
|
||||||
# Nombre de filons par chunk (par défaut: 4)
|
|
||||||
veinsPerChunk = 4
|
|
||||||
# Hauteur minimale de génération (par défaut: 0)
|
|
||||||
minHeight = 0
|
|
||||||
# Hauteur maximale de génération (par défaut: 256)
|
|
||||||
maxHeight = 256
|
|
||||||
|
|
||||||
# Configuration du Minerai de Charbon Concentré
|
|
||||||
[ore_generation.concentrated_coal_ore]
|
|
||||||
veinsPerChunk = 2
|
|
||||||
|
|
||||||
# Configuration des Minerais Impurs
|
|
||||||
[ore_generation.impure_ores]
|
|
||||||
# Nombre de filons de Fer Impur par chunk (par défaut: 2)
|
|
||||||
ironVeinsPerChunk = 2
|
|
||||||
# Nombre de filons d'Or Impur par chunk (par défaut: 2)
|
|
||||||
goldVeinsPerChunk = 2
|
|
||||||
|
|
||||||
# Configuration des Minerais d'Émeraude
|
|
||||||
[ore_generation.emerald_ores]
|
|
||||||
# Nombre de filons de Haut Émeraude par chunk (par défaut: 1)
|
|
||||||
highVeinsPerChunk = 1
|
|
||||||
# Nombre de filons de Bas Émeraude par chunk (par défaut: 1)
|
|
||||||
lowerVeinsPerChunk = 1
|
|
||||||
|
|
||||||
# Configuration des Minerais de Cuivre
|
|
||||||
[ore_generation.copper_ores]
|
|
||||||
# Nombre de filons de Haut Cuivre par chunk (par défaut: 2)
|
|
||||||
highVeinsPerChunk = 2
|
|
||||||
# Nombre de filons de Bas Cuivre par chunk (par défaut: 2)
|
|
||||||
lowerVeinsPerChunk = 2
|
|
||||||
|
|
||||||
|
|
||||||
#==========================
|
|
||||||
# Stats des Outils
|
|
||||||
#==========================
|
|
||||||
[tool_stats]
|
|
||||||
|
|
||||||
# Configuration des Outils en Éclats de Diamant
|
|
||||||
[tool_stats.shard_diamond_tools]
|
|
||||||
# Durabilité de la Pioche (par défaut: 200)
|
|
||||||
# Min: 1, Max: 5000
|
|
||||||
pickaxeDurability = 200
|
|
||||||
# Vitesse de minage de la Pioche (par défaut: 7.0)
|
|
||||||
pickaxeSpeed = 7.0
|
|
||||||
# Dégâts d'attaque de la Pioche (par défaut: 1)
|
|
||||||
pickaxeAttackDamage = 1
|
|
||||||
|
|
||||||
# Durabilité de la Hache (par défaut: 200)
|
|
||||||
axeDurability = 200
|
|
||||||
# Vitesse de minage de la Hache (par défaut: 7.0)
|
|
||||||
axeSpeed = 7.0
|
|
||||||
# Dégâts d'attaque de la Hache (par défaut: 6)
|
|
||||||
axeAttackDamage = 6
|
|
||||||
|
|
||||||
# Durabilité de la Pelle (par défaut: 200)
|
|
||||||
shovelDurability = 200
|
|
||||||
# Vitesse de minage de la Pelle (par défaut: 4.0)
|
|
||||||
shovelSpeed = 4.0
|
|
||||||
# Dégâts d'attaque de la Pelle (par défaut: 2)
|
|
||||||
shovelAttackDamage = 2
|
|
||||||
|
|
||||||
|
|
||||||
#==========================
|
|
||||||
# Drops des Minerais
|
|
||||||
#==========================
|
|
||||||
[drops]
|
|
||||||
|
|
||||||
# Configuration du Minerai d'Éclats de Diamant
|
|
||||||
[drops.shard_diamond_ore]
|
|
||||||
# Nombre minimum d'éclats droppés (par défaut: 1)
|
|
||||||
minDrops = 1
|
|
||||||
# Nombre maximum d'éclats droppés (par défaut: 2)
|
|
||||||
maxDrops = 2
|
|
||||||
# Activer l'enchantement Fortune (par défaut: true)
|
|
||||||
enableFortune = true
|
|
||||||
|
|
||||||
# Configuration du Minerai de Diamant Concentré
|
|
||||||
[drops.concentrated_diamond_ore]
|
|
||||||
# Nombre minimum de diamants droppés (par défaut: 1)
|
|
||||||
minDrops = 1
|
|
||||||
# Nombre maximum de diamants droppés (par défaut: 2)
|
|
||||||
maxDrops = 2
|
|
||||||
# Activer l'enchantement Fortune (par défaut: true)
|
|
||||||
enableFortune = true
|
|
||||||
|
|
||||||
# Configuration du Minerai de Charbon Concentré
|
|
||||||
[drops.concentrated_coal_ore]
|
|
||||||
# Nombre minimum de charbon droppé (par défaut: 2)
|
|
||||||
minDrops = 2
|
|
||||||
# Nombre maximum de charbon droppé (par défaut: 4)
|
|
||||||
maxDrops = 4
|
|
||||||
|
|
||||||
# Configuration du Minerai d'Or Pur
|
|
||||||
[drops.pure_golden_ore]
|
|
||||||
# Nombre minimum de pépites d'or droppées (par défaut: 2)
|
|
||||||
minDrops = 2
|
|
||||||
# Nombre maximum de pépites d'or droppées (par défaut: 4)
|
|
||||||
maxDrops = 4
|
|
||||||
|
|
||||||
# Configuration du Minerai de Charbon de Cendre
|
|
||||||
[drops.ash_coal_ore]
|
|
||||||
# Nombre minimum de charbon de cendre droppé (par défaut: 1)
|
|
||||||
minDrops = 1
|
|
||||||
# Nombre maximum de charbon de cendre droppé (par défaut: 2)
|
|
||||||
maxDrops = 2
|
|
||||||
|
|
||||||
# Configuration des Minerais Impurs
|
|
||||||
[drops.impure_ores]
|
|
||||||
# Configuration du Fer Impur
|
|
||||||
ironMinDrops = 1
|
|
||||||
ironMaxDrops = 2
|
|
||||||
# Configuration de l'Or Impur
|
|
||||||
goldMinDrops = 1
|
|
||||||
goldMaxDrops = 2
|
|
||||||
|
|
||||||
# Expérience droppée par les minerais personnalisés (par défaut: 2)
|
|
||||||
oreExperience = 2
|
|
||||||
|
|
||||||
|
|
||||||
#==========================
|
|
||||||
# Activation des Fonctionnalités
|
|
||||||
#==========================
|
|
||||||
[features]
|
|
||||||
# Activer les Outils en Éclats de Diamant (par défaut: true)
|
|
||||||
enableShardDiamondTools = true
|
|
||||||
# Activer le Minerai d'Éclats de Diamant (par défaut: true)
|
|
||||||
enableShardDiamondOre = true
|
|
||||||
# Activer les Minerais Concentrés (Diamant, Charbon) (par défaut: true)
|
|
||||||
enableConcentratedOres = true
|
|
||||||
# Activer les Minerais Impurs (Fer, Or) (par défaut: true)
|
|
||||||
enableImpureOres = true
|
|
||||||
# Activer le Minerai de Charbon de Cendre (par défaut: true)
|
|
||||||
enableAshCoalOre = true
|
|
||||||
# Activer le Minerai d'Or Pur (par défaut: true)
|
|
||||||
enablePureGoldenOre = true
|
|
||||||
# Activer les Minerais d'Émeraude Personnalisés (Haut, Bas) (par défaut: true)
|
|
||||||
enableCustomEmeraldOres = true
|
|
||||||
# Activer les Minerais de Cuivre Personnalisés (Haut, Bas) (par défaut: true)
|
|
||||||
enableCustomCopperOres = true
|
|
||||||
# Activer les Variantes de Minerais Vanilla (Fer, Redstone, Lapis, etc.) (par défaut: true)
|
|
||||||
enableVanillaOreVariants = true
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"replace": false,
|
|
||||||
"entries": [
|
|
||||||
"custom_ore_gen:custom_ore_drops"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -104,7 +104,7 @@ class ModConfigsTest {
|
|||||||
@DisplayName("FeatureToggleConfig declares every toggle referenced by ConfigHelper")
|
@DisplayName("FeatureToggleConfig declares every toggle referenced by ConfigHelper")
|
||||||
void testFeatureToggleConfig_declaresAllTogglesReferencedByConfigHelper() {
|
void testFeatureToggleConfig_declaresAllTogglesReferencedByConfigHelper() {
|
||||||
String[] toggles = {
|
String[] toggles = {
|
||||||
"shardDiamondTools", "shardDiamondOre", "concentratedOres", "impureOres",
|
"shardDiamondOre", "concentratedOres", "impureOres",
|
||||||
"pureGoldenOre", "customEmeraldOres", "customCopperOres", "vanillaOreVariants"
|
"pureGoldenOre", "customEmeraldOres", "customCopperOres", "vanillaOreVariants"
|
||||||
};
|
};
|
||||||
for (String toggle : toggles) {
|
for (String toggle : toggles) {
|
||||||
|
|||||||
Reference in New Issue
Block a user