Posted August 11, 201510 yr Hello and sry for my silly questions. I want to add a effect on my Item if I hold it. But I everytime i get the effect if it just in the inventory... How can I fix it? (This is a Code I've used in 1.6 but I deleted some code in it to fix errors... this is maybe the problem..) public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { EntityPlayer Player = (EntityPlayer) entity; if(Player.getCurrentEquippedItem() !=null) { Player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 25, 0))); } else { Player.curePotionEffects(itemstack); } } I've changed this: if(Player.getCurrentEquippedItem() !=null && Player.getCurrentEquippedItem().itemID == this.itemID To this: if(Player.getCurrentEquippedItem() !=null) How can I replace .itemID?
August 11, 201510 yr dont use ids to compare, use the instance of the item u create to register the item. so use equippedItem==myItem
August 11, 201510 yr also you dont need to compare the items, the boolean should tell u if the item is equipped or not
August 11, 201510 yr Author Hm I think I don't understand... you mean I've change if(Player.getCurrentEquippedItem() !=null) to if(Player.getCurrentEquippedItem() == ModDatabase.myItem)
August 11, 201510 yr if(Player.getCurrentEquippedItem().equals(ModDatabase.myItem)) That is assuming 'ModDatabase' is your main class or whatever class you have your items registered/defined in. Long time Bukkit & Forge Programmer Happy to try and help
August 11, 201510 yr To make it simple. if(Player.getCurrentEquippedItem() !=null && Player.getCurrentEquippedItem().itemID == this.itemID NO if(Player.getCurrentEquippedItem()==MyItem) YES if you dont understand this go back, learn some java and come backj then
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.