Posted June 20, 20187 yr How would one test for the armor a player is wearing and if say the player was wearing a full set of diamond armor give some effect or buff? The seven became one and the one became two.
June 20, 20187 yr If you have a reference to the player, check their equipment slots. There are four of them. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 20, 20187 yr Author @SubscribeEvent public void onDamage(LivingDamageEvent event) { EntityPlayer player; List<ItemStack> armor = null; if(event.getEntity() instanceof EntityPlayer) { player = (EntityPlayer) event.getEntity(); armor = (List<ItemStack>) player.getArmorInventoryList(); } if(!armor.isEmpty()) { if(armor.get(0) == new ItemStack(ItemInit.BOOTS_MERTHEW)) { if(armor.get(1) == new ItemStack(ItemInit.LEGGINGS_MERTHEW)) { if(armor.get(2) == new ItemStack(ItemInit.CHESTPLATE_MERTHEW)) { if(armor.get(3) == new ItemStack(ItemInit.HELM_MERTHEW)) { event.setAmount(0); } } } } } } This is what i was trying to do, what am i doing wrong? if you need the git hub: https://github.com/Merthew/MerthewMod/ The seven became one and the one became two.
June 20, 20187 yr Author wrong code.. srry @Override public void onArmorTick(final World world, final EntityPlayer player, final ItemStack itemStack) { List<ItemStack> narmor = new ArrayList<ItemStack>(); narmor.add(new ItemStack(ItemInit.BOOTS_MERTHEW)); narmor.add(new ItemStack(ItemInit.LEGGINGS_MERTHEW)); narmor.add(new ItemStack(ItemInit.CHESTPLATE_MERTHEW)); narmor.add(new ItemStack(ItemInit.HELM_MERTHEW)); List<ItemStack> armor = (List<ItemStack>) player.getArmorInventoryList(); if(armor.get(0) == narmor.get(3)) { if (!player.isPotionActive(potionEffect.getPotion())) { // If the Potion isn't currently active, player.addPotionEffect(new PotionEffect(potionEffect)); // Apply a copy of the PotionEffect to the player } } } The seven became one and the one became two.
June 20, 20187 yr What if they are wearing only a chestplate? Is the list still 4 items long? Are the items in the right order? if(armor.get(0) == narmor.get(3)) This will never be true. You should be using EntityPlayer#getItemStackFromSlot(EntityEquipmentSlot) Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 20, 20187 yr Author Thanks, i never knew about many of the methods you so far have helped with. The seven became one and the one became two.
June 21, 20187 yr 7 hours ago, Merthew said: Thanks, i never knew about many of the methods you so far have helped with. To compare ItemStacks you need to compare the item and the metadata. ItemStack#getItem and ItemStack.getMetadata() It is also possible to use the utility functions in the ItemStack class. ItemStack.are..... VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
June 21, 20187 yr Author I just used isItemEqual(); and it seems to be working fine. The seven became one and the one became two.
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.