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.

Featured Replies

Posted

Hello, so i've been recently working on some special armor. If you press a keybind, your armor slots automatically fill up with the armor. I am using

player.inventory.armorInventory.set

to replace the slots. I am probably doing something really wrong, but whenever i press the keybind, everybody in the world gets the armor. Is there any way i can fix this?

Any help would be greatly appreciated, thanks.

Here is the code:

@SubscribeEvent
public void armorTick(LivingEvent.LivingUpdateEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        if(permanentArmor) {
            if(player.inventory.armorItemInSlot(3).getItem() != ModItems.QUICK_HELMET) {
                player.inventory.armorInventory.set(3, new ItemStack(ModItems.QUICK_HELMET));
            }
            if(player.inventory.armorItemInSlot(2).getItem() != ModItems.QUICK_CHESTPLATE) {
                player.inventory.armorInventory.set(2, new ItemStack(ModItems.QUICK_CHESTPLATE));
            }
            if(player.inventory.armorItemInSlot(1).getItem() != ModItems.QUICK_LEGGINGS) {
                player.inventory.armorInventory.set(1, new ItemStack(ModItems.QUICK_LEGGINGS));
            }
            if(player.inventory.armorItemInSlot(0).getItem() != ModItems.QUICK_BOOTS) {
                player.inventory.armorInventory.set(0, new ItemStack(ModItems.QUICK_BOOTS));
            }

        }

    }
}

EDIT: Here is "permanentarmor":

public static void togglePermanentArmor(EntityPlayer player) {
        if (MAP.containsKey(player) && MAP.get(player)) {
            MAP.remove(player);
            permanentArmor = false;
            player.sendStatusMessage(new TextComponentString("Permanent Armor: Off"), true);
        } else {
            MAP.put(player, true);
            permanentArmor = true;
            player.sendStatusMessage(new TextComponentString("Permanent Armor: On"), true);
        }
    }

}

 

Edited by TesterTesting135
Needed to add more information

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.