Fix DM/RM tools and armor crashing server on NeoForge 1.21.1#2462
Open
Soccerbeats wants to merge 2 commits into
Open
Fix DM/RM tools and armor crashing server on NeoForge 1.21.1#2462Soccerbeats wants to merge 2 commits into
Soccerbeats wants to merge 2 commits into
Conversation
added 2 commits
April 18, 2026 15:02
NoDurabilityItemProperties overrode durability() as a NO-OP, causing DM/RM tools and armor to be registered without a minecraft:max_damage data component. NeoForge's DataComponentUtil.wrapEncodingExceptions requires a positive value for this component, throwing: IllegalStateException: Value must be positive: 0 at ItemStack.save() on the next player tick after crafting. Fix: remove NoDurabilityItemProperties, register tools and armor with durability(Integer.MAX_VALUE). damageItem() still returns 0 in PETool, PEPickaxe, and PEArmor so durability is never actually consumed. Also adds registerArmor() to ItemDeferredRegister and switches all 12 DM/RM/Gem armor registrations from registerNoStackFireImmune to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Crafting any DM/RM tool or armor causes the server to crash on the next player tick with:
java.lang.IllegalStateException: Value must be positive: 0
at net.neoforged.neoforge.common.util.DataComponentUtil.wrapEncodingExceptions
at net.minecraft.world.item.ItemStack.save
at net.minecraft.world.entity.player.Inventory.save
at net.minecraft.server.level.ServerPlayer.tick
Root Cause
NoDurabilityItemPropertiesinItemDeferredRegisteroverridesdurability()as a NO-OP. This prevents theminecraft:max_damagedata component from being added to the ItemStack. NeoForge 1.21.1 requires a positive value for thiscomponent when serializing any item that is a tool or armor.
Fix
NoDurabilityItemPropertiesentirelydurability(Integer.MAX_VALUE)so the component is presentregisterArmor()helper toItemDeferredRegisterregisterArmor()damageItem()still returns 0 inPETool,PEPickaxe, andPEArmor— durability is never consumedTested
Confirmed working on a live NeoForge 1.21.1 server — DM/RM tools and armor can be crafted and used without crashing.