Skip to content

Fix DM/RM tools and armor crashing server on NeoForge 1.21.1#2462

Open
Soccerbeats wants to merge 2 commits into
sinkillerj:mc1.21.1from
Soccerbeats:fix/dm-rm-tool-max-damage-component
Open

Fix DM/RM tools and armor crashing server on NeoForge 1.21.1#2462
Soccerbeats wants to merge 2 commits into
sinkillerj:mc1.21.1from
Soccerbeats:fix/dm-rm-tool-max-damage-component

Conversation

@Soccerbeats

Copy link
Copy Markdown

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

NoDurabilityItemProperties in ItemDeferredRegister overrides durability() as a NO-OP. This prevents the
minecraft:max_damage data component from being added to the ItemStack. NeoForge 1.21.1 requires a positive value for this
component when serializing any item that is a tool or armor.

Fix

  • Remove NoDurabilityItemProperties entirely
  • Register tools and armor with durability(Integer.MAX_VALUE) so the component is present
  • Add registerArmor() helper to ItemDeferredRegister
  • Switch all 12 DM/RM/Gem armor registrations to registerArmor()
  • damageItem() still returns 0 in PETool, PEPickaxe, and PEArmor — durability is never consumed

Tested

Confirmed working on a live NeoForge 1.21.1 server — DM/RM tools and armor can be crafted and used without crashing.

austin 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant