CrimsonDawn45 Posted February 24, 2020 Share Posted February 24, 2020 I have added a custom shield to the game which extends the ShieldItem class. Blocking works, switching between the two models using overrides works but I can't seem to get durability for this item to work. Here is the custom shield item class: package me.crimsondawn45.survivaladditions.object.item; import me.crimsondawn45.survivaladditions.util.SAregistries; import net.minecraft.block.DispenserBlock; import net.minecraft.item.ArmorItem; import net.minecraft.item.Item; import net.minecraft.item.ShieldItem; public class SAshieldItem extends ShieldItem { public SAshieldItem(Item.Properties builder) { super(builder); this.addPropertyOverride(SAregistries.resLoc("blocking"), (item, world, entity) -> { return entity != null && entity.isHandActive() && entity.getActiveItemStack() == item ? 1.0F : 0.0F; }); DispenserBlock.registerDispenseBehavior(this, ArmorItem.DISPENSER_BEHAVIOR); } } And here is the instance I am passing into the .registerAll method: SAitems.wooden_shield = new SAshieldItem(new Item.Properties().group(ITEM).maxStackSize(1).maxDamage(100)).setRegistryName(resLoc("wooden_shield")), I have tried using ".defaultMaxDamage()" in the properties bulder and passing in durability directly in the item class using "getMaxUses()" Quote Link to comment Share on other sites More sharing options...
someRandomKid Posted September 21, 2020 Share Posted September 21, 2020 Try creating an @SubsribeEvent for LivingAttackEvent. (I personally have not been able to get this working) You would also have to set .DefaultMaxDamage() in the builder properties. Quote Link to comment Share on other sites More sharing options...
vemerion Posted September 21, 2020 Share Posted September 21, 2020 In 1.15 at least you can override the isShield() method in your shield class, which should allow the shield to take damage when blocking with it. Quote Link to comment Share on other sites More sharing options...
someRandomKid Posted September 21, 2020 Share Posted September 21, 2020 (edited) wow worked instantly (for 1.15.2) Edited September 22, 2020 by someRandomKid Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.