#Item disabled instead of breaking

7 messages · Page 1 of 1 (latest)

queen cosmos
#

Is there a way to have an armor item that when it reaches a low durability will simply stop working and stop loosing durability?
whether it be that the item is actually un-equipped, or if it is simply stops loosing durability.
I am in version 1.21.1

oak forge
#

I haven't touched armor items yet but looking at the Elytra the code has an isUsable method in the ElytraItem class: public static boolean isUsable(ItemStack stack) { return stack.getDamage() < stack.getMaxDamage() - 1; }

queen cosmos
#

Yah I saw that too. But the only place that it is used is in the player entity and living entity classes, to determine if the player can “fall fly” and if not the durability is halted from the fact that you cannot fly anymore.
But armor is weird since the damage is simply from taking damage while wearing it.
I do not even know for sure where the durability damage is dealt to the armor. Maybe I would mixin into that and disable the damage that way, but that seems clunky.

oak forge
#

Mixins might be the way. It looks like there is the applyArmorToDamage method in the LivingEntity class that gets called when the the damage method gets called.

light gulch
#

I would start with a custom damage handler through FabricItem

queen cosmos
light gulch