-
Notifications
You must be signed in to change notification settings - Fork 0
26.1.2 Dynamic Modded Item Registration
| System Parameter | Value |
|---|---|
| Trigger Point |
MappedRegistry.freeze() (Registries.ITEM) |
| Mixin Hook | MappedRegistryMixin |
| Scanner Class | DurabilityRules.registerDynamicRulesOnRegistryFreeze() |
| Reflection Target | BuiltInRegistries.DATA_COMPONENT_INITIALIZERS |
| Dynamic Item List | DurabilityRules.DYNAMIC_ITEMS |
| Generated Multiplier Key | ig:multiplier_<namespace>_<path> |
| Generated Infinity Key | ig:infinity_<namespace>_<path> |
Many Minecraft mods introduce custom weapons, magical wands, energy tools, or mechanical devices that do not use standard vanilla item classes (PickaxeItem, SwordItem) or tags (#minecraft:swords).
Durability Multiplier automatically detects these items and dynamically generates dedicated GameRules for each uncategorized modded item at server startup, allowing full multiplier and God Mode configuration.
sequenceDiagram
participant MR as MappedRegistry (ITEM)
participant MX as MappedRegistryMixin
participant DR as DurabilityRules
participant DCI as DATA_COMPONENT_INITIALIZERS
participant DGM as DynamicGameRuleManager
MR->>MX: freeze() called
MX->>DR: registerDynamicRulesOnRegistryFreeze()
loop For each Item in BuiltInRegistries.ITEM
DR->>DR: Skip if namespace is "minecraft" or "c"
DR->>DCI: Reflection scan initializers for Item ID
alt Item has MAX_DAMAGE > 0 and uncategorized
DR->>DGM: Register ig:multiplier_<ns>_<path>
DR->>DGM: Register ig:infinity_<ns>_<path>
DR->>DR: Add ID to DYNAMIC_ITEMS list
end
end
To avoid triggering early component binding errors or NullPointerException: Components not bound yet during mod initialization, DurabilityRules inspects BuiltInRegistries.DATA_COMPONENT_INITIALIZERS using reflection:
- Accesses
initializerslist inDATA_COMPONENT_INITIALIZERS. - Locates matching
ResourceKey<Item>. - Runs the initializer against an isolated
DataComponentMap.Builder. - Checks if
DataComponents.MAX_DAMAGEis present and$> 0$ . - Confirms the item does not have
DataComponents.TOOLorDataComponents.EQUIPPABLE(which are already handled in standard categories).
When an uncategorized modded item (e.g. techmod:plasma_cutter) is detected:
- Multiplier Rule registered:
/gamerule ig:multiplier_techmod_plasma_cutter <value> - God Mode Rule registered:
/gamerule ig:infinity_techmod_plasma_cutter <true|false> - The Cloth Config / ModMenu configuration screen automatically populates these under the Modded Items tab.
Durability Multiplier is engineered with ❤️ by Dasik (Rifaditya) | Licensed under GNU General Public License v3.0 (GPL-3.0-or-later).
📌 Repository Source Disclaimer: The documentation in this Wiki reflects the current source code state in the repository, which may include recent unreleased commits or developmental features ahead of public release builds on CurseForge and Modrinth.
- 26.2 Hub
- 26.2 Multipliers
- 26.2 God Mode
- 26.2 Damage & Math
- 26.2 Item Classification
- 26.2 Dynamic Registry
- 26.2 Tooltips & HUD
- 26.2 Network Protocol
- 26.2 GameRules Table
- 26.2 Commands & Admin
- 26.2 Advancements
- 26.2 Configuration
- 26.2 ModVersionGuard
- 26.2 Architecture & Mixins
- 26.2 Developer Setup
- 26.2 API & Addons
- 26.2 FAQ & Diagnostics
- 26.1.2 Hub
- 26.1.2 Multipliers
- 26.1.2 God Mode
- 26.1.2 Damage & Math
- 26.1.2 Item Classification
- 26.1.2 Dynamic Registry
- 26.1.2 Tooltips & HUD
- 26.1.2 Network Protocol
- 26.1.2 GameRules Table
- 26.1.2 Commands & Admin
- 26.1.2 Advancements
- 26.1.2 Configuration
- 26.1.2 Architecture & Mixins
- 26.1.2 Developer Setup
- 26.1.2 API & Addons
- 26.1.2 FAQ & Diagnostics