Posted July 29, 20205 yr I am trying to make a mechanic where if a player is wearing a full hazmat suit they do not get poisoned. My current way of doing it is this: if((livingEntity.getItemStackFromSlot(EquipmentSlotType.HEAD) == new ItemStack(RegistryHandler.HAZMAT_HELMET.get())) && (livingEntity.getItemStackFromSlot(EquipmentSlotType.CHEST) == new ItemStack(RegistryHandler.HAZMAT_CHESTPLATE.get())) && (livingEntity.getItemStackFromSlot(EquipmentSlotType.LEGS) == new ItemStack(RegistryHandler.HAZMAT_LEGGINGS.get())) && (livingEntity.getItemStackFromSlot(EquipmentSlotType.FEET) == new ItemStack(RegistryHandler.HAZMAT_BOOTS.get()))) { return; } but 1) It isn't working 2) It looks very janky and I don't like it.
July 29, 20205 yr 4 minutes ago, sccreeper said: I am trying to make a mechanic where if a player is wearing a full hazmat suit they do not get poisoned. My current way of doing it is this: if((livingEntity.getItemStackFromSlot(EquipmentSlotType.HEAD) == new ItemStack(RegistryHandler.HAZMAT_HELMET.get())) && (livingEntity.getItemStackFromSlot(EquipmentSlotType.CHEST) == new ItemStack(RegistryHandler.HAZMAT_CHESTPLATE.get())) && (livingEntity.getItemStackFromSlot(EquipmentSlotType.LEGS) == new ItemStack(RegistryHandler.HAZMAT_LEGGINGS.get())) && (livingEntity.getItemStackFromSlot(EquipmentSlotType.FEET) == new ItemStack(RegistryHandler.HAZMAT_BOOTS.get()))) { return; } but 1) It isn't working 2) It looks very janky and I don't like it. Probably you should use ItemStack::equals for comparing itemstacks Everything said above may be absolutely wrong. No rights reserved.
July 29, 20205 yr Compare ItemStacks using some provided methods in ItemStack (I don't remember what they're called), but you should be checking if their Items are equal (which == is fine), not the ItemStacks.
July 29, 20205 yr Just now, diesieben07 said: ItemStack has no equals method. Oh, that's sad:( But yeah, == is likely to not work here. Everything said above may be absolutely wrong. No rights reserved.
July 29, 20205 yr Author Got it to work with this code: if(e.player.inventory.hasItemStack(new ItemStack(RegistryHandler.HAZMAT_CHESTPLATE.get()))) { if(e.player.inventory.armorItemInSlot(2).getItem() == RegistryHandler.HAZMAT_CHESTPLATE.get()) { e.player.removeActivePotionEffect(Effects.POISON); e.player.removeActivePotionEffect(Effects.NAUSEA); LOGGER.log(Level.INFO, "I works"); return; } And yes I know I could check for both conditions with the && operator. This post here helped a bit didn't realise armorItemSlot had other methods. Edited July 29, 20205 yr by sccreeper
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.