Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.14.4] Removing modifiers completely when not wearing custom armor

Featured Replies

Posted
@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.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.