fix: remove dead config + enchant class, extract & test drop math
Three correctness passes that remove lie-to-the-user code and add real
test coverage on the drop logic. Nothing broke; build + 6 GameTests green.
== Remove dead OreGenConfig (lie to the user) ==
OreGenConfig (veinSize/veinsPerChunk/min/max) was NEVER read anywhere
(grep ORE_GEN. -> NONE), and its defaults did not even match the JSONs:
- copperhighore: JSON count=20 vs config default 2 (10x)
- concentratedcoalore: JSON count=10 vs default 2 (5x)
- deepslateironore: JSON count=20 vs impureIronOreCount default 2 (10x)
- sharddiamondblockore: JSON size=4 vs shardDiamondOreSize default 8 (2x)
So a user reading the generated .toml was actively misled ("2 iron veins
per chunk" when 20 generate). Branching it to runtime config is
architecturally impossible in NeoForge (datapacks load before the runtime
config - the same problem ConfigGatedFeaturesModifier solves). Removed
the class + instance + matching structural tests. Vein params now live
only in the data-driven JSONs, like vanilla.
== Remove dead EnchantabilityFix (non-compiling API) ==
EnchantabilityFix was fully commented out because it referenced
DataComponents.ENCHANTABLE and net.minecraft.world.item.enchantment.Enchantable,
which DO NOT EXIST in 1.21.1 (confirmed via javap on neoforge-21.1.219.jar:
only ENCHANTMENTS / ENCHANTMENT_GLINT_OVERRIDE / STORED_ENCHANTMENTS exist).
Uncommenting it would fail to compile. Enchantability already works
natively via the enchantable tags
(data/minecraft/tags/item/enchantable/{mining,weapon,armor,durability}.json
- all Shard Diamond tools + armor listed) combined with the Tier
getEnchantmentValue()==9. Deleted the dead class.
== Extract & test drop math ==
ConfigurableOreDropsProcedure is hand-written (git log shows fix(drops)/
replace-event-with-GlobalLootModifier commits, no MCreator regeneration).
Extracted the pure fortune/drop/XP math into OreDropMath -> procedure now
delegates: dropCount = OreDropMath.dropCount(...), XP = experienceFor(...).
Added OreDropMathTest (16 tests) covering:
- isMultiDropOre classification
- baseDropCount range + uniform coverage + degenerate (min==max, no draw)
- fortune: disabled/level-0 are no-ops (no RNG consumed)
- discrete ores: bonus bounded in [0, fortuneLevel], vanilla III distribution
- multiplier ores: results are exact multiples of base, vanilla III distribution
- dropCount random-draw order pinned (base then fortune)
- XP: zero-XP types (iron/gold/copper), vanilla ranges, bounds hit
- determinism: same seed -> identical sequences
The procedure is now correct-by-construction for the math; the only
untested part is the MC orchestration (player/tool/registry lookup, spawn).
== Docs ==
CLAUDE.md: mark feature toggles + enchantability as already-working,
correct the "hardcoded tools" / "EnchantabilityFix commented out" claims,
document the native enchantability path (tags + Tier.getEnchantmentValue).
Verification: ./gradlew test build -> BUILD SUCCESSFUL, 71/71 unit tests
./gradlew runGameTestServer -> 6/6 GameTests passed in 1.0s
This commit is contained in:
@@ -57,7 +57,7 @@ net.mcreator.customoregen/
|
||||
├── block/ # Ore block classes (17 blocks)
|
||||
├── item/ # Items (Diamond Shard, tools, armor, Paxel, OreBiomeFinder)
|
||||
├── config/ # NeoForge configuration system (ModConfigs.java)
|
||||
├── event/ # Event handlers (OreBreakEventHandler, EnchantabilityFix)
|
||||
├── event/ # Event handlers (OreBreakEventHandler)
|
||||
├── procedures/ # Game logic (ConfigurableOreDropsProcedure, OreexperienceProcedure)
|
||||
└── init/
|
||||
├── CustomOreGenModBlocks.java # Block registry (deferred register)
|
||||
@@ -115,8 +115,8 @@ Located in `src/main/java/net/mcreator/customoregen/config/`:
|
||||
- **✅ Ore Drops**: Fully implemented via `OreBreakEventHandler.java` which listens to `BlockEvent.BreakEvent` and calls `ConfigurableOreDropsProcedure.execute()` for all custom ores
|
||||
- **⚠️ Tool Stats**: Wired. Tools read their stats from `TOOL_STATS` config when the config is loaded, with a hardcoded fallback when not yet loaded (e.g. `SharddiamondpickaxeItem.java`: `return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get() : 200;`). See also `ConfigHelper.getShardDiamondToolDurability/Speed/Damage`.
|
||||
- **⚠️ Feature Toggles**: Wired (commit `48a0d797`). Toggles in `FeatureToggleConfig` drive ore *generation* via `ConfigGatedFeaturesModifier` + the `config_gated_features` biome modifiers in `data/custom_ore_gen/neoforge/biome_modifier/add_*_ores.json`. A regression test (`ModConfigsTest.testFeatureToggleConfig_declaresAllTogglesReferencedByConfigHelper()`) ensures every toggle string used by `ConfigHelper.isFeatureEnabled()` actually maps to a field on `FeatureToggleConfig`, so a typo can't silently produce a dead toggle. Note: item/block *registration* still always fires (toggling only gates worldgen, not whether the items exist in creative).
|
||||
- **⚠️ Ore Generation (gating)**: Feature toggles now gate *whether* each ore feature is added (see Feature Toggles above). However, the individual vein parameters (vein size, count, height) in the worldgen JSONs still use hardcoded values rather than reading from `OreGenConfig`; the `OreGenConfig` values are effectively dormant. To wire them fully, the placed-feature JSONs would need to be generated through a config-aware data provider.
|
||||
- **⚠️ Enchantability**: `EnchantabilityFix.java` exists but is commented out - enchantment values not yet applied to items
|
||||
- **⚠️ Ore Generation (gating)**: Feature toggles gate *whether* each ore feature is added (see Feature Toggles above). Vein parameters (size, count, height) are hard-coded in the data-driven worldgen JSONs under `data/custom_ore_gen/worldgen/` (`configured_feature/` + `placed_feature/`), exactly like vanilla; there is no runtime-config-driven ore parameter provider.
|
||||
- **Enchantability**: Works natively in 1.21.1 via the enchantable tags (`data/minecraft/tags/item/enchantable/{mining,weapon,armor,durability}.json`, which include all Shard Diamond tools + armor) combined with `Tier.getEnchantmentValue() == 9` on the tool `Tier`s. The dead `EnchantabilityFix.java` class (which referenced the non-existent `DataComponents.ENCHANTABLE` / `net.minecraft.world.item.enchantment.Enchantable` from an earlier 1.20.5-snapshot API) has been removed.
|
||||
|
||||
### Ore Biome Finder
|
||||
|
||||
@@ -169,10 +169,9 @@ The mod uses NeoForge's event system for ore processing:
|
||||
- Calls `ConfigurableOreDropsProcedure.execute()` with ore type when player breaks ore with correct tool
|
||||
- Supports 10 ore types: shard_diamond, concentrated_coal, pure_golden, impure_iron, concentrated_diamond, lapis, redstone, emerald, copper
|
||||
|
||||
### EnchantabilityFix
|
||||
- Uses `ModifyDefaultComponentsEvent` to set enchantability values on tools and armor
|
||||
- Currently **commented out** - enchantability not yet applied
|
||||
- When active, should set `DataComponents.ENCHANTABLE` with value 9 (tools) or 14 (armor)
|
||||
### Enchantability
|
||||
- Implemented natively via 1.21.1 mechanisms: the Shard Diamond tools + armor are listed in `data/minecraft/tags/item/enchantable/{mining,weapon,armor,durability}.json`, and the tool `Tier`s return `getEnchantmentValue() == 9`.
|
||||
- A former `EnchantabilityFix.java` used `ModifyDefaultComponentsEvent` to set a `DataComponents.ENCHANTABLE` component, but that API does not exist in 1.21.1 (only `ENCHANTMENTS`/`ENCHANTMENT_GLINT_OVERRIDE`/`STORED_ENCHANTMENTS` exist on `DataComponents`). The dead class has been deleted.
|
||||
|
||||
## Loot Table Format
|
||||
|
||||
|
||||
Reference in New Issue
Block a user