Posted March 1, 20205 yr @Mod.EventBusSubscriber(modid = HardSteel.modid, bus = Mod.EventBusSubscriber.Bus.FORGE ) public final class ModEventSubscriber { @SubscribeEvent public void onEquipmentChangeEvent(LivingEquipmentChangeEvent event) { if(event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); ItemStack head = player.getItemStackFromSlot(EquipmentSlotType.HEAD); ItemStack chest = player.getItemStackFromSlot(EquipmentSlotType.CHEST); ItemStack legs = player.getItemStackFromSlot(EquipmentSlotType.LEGS); ItemStack feet = player.getItemStackFromSlot(EquipmentSlotType.FEET); if(player.getAttributes().getAttributeInstanceByName("generic.movementSpeed").getModifier(UUID.fromString("031cd58c-2529-4c7f-ad1b-ae48df68d2c8")) != null && head.isEmpty() && chest.isEmpty() && legs.isEmpty() && feet.isEmpty()){ player.getAttributes().getAttributeInstanceByName("generic.movementSpeed").removeModifier(UUID.fromString("031cd58c-2529-4c7f-ad1b-ae48df68d2c8")); } if(player.getAttributes().getAttributeInstanceByName("generic.knockbackResistance").getModifier(UUID.fromString("0663661e-a7f6-4a73-84ba-1b8214fb6eec")) != null && head.isEmpty() && chest.isEmpty() && legs.isEmpty() && feet.isEmpty()){ player.getAttributes().getAttributeInstanceByName("generic.knockbackResistance").removeModifier(UUID.fromString("0663661e-a7f6-4a73-84ba-1b8214fb6eec")); } } I'm trying to make sure certain modifiers added by armor are completely removed when not wearing armor, as my modifiers decrease as the player removes armor but not when the player removes the last piece.
March 1, 20205 yr Author The fix for this (or rather, the CORRECT way to do what I was trying to do) is to override getAttributeModifiers in the Armor class and then add the modifiers into that mapping system. Do not use onArmorTick in your Armor class for this purpose like I originally was doing.
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.