Jump to content

Recommended Posts

Posted (edited)

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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