Posted August 27, 201312 yr Hey all anyway I have this armor set that when worn, would allow the player to creative fly. However, the armor does allow for such things, but when the armor is removed, the player can still fly(on survival). This shouldn't be happening and if any of you can point out to me why I would be grateful. Anyways here is my code: @Override public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack) { if (player.inventory.armorItemInSlot(2) != null) { ItemStack itemstack = player.inventory.armorItemInSlot(2); if (itemstack.itemID == FuturologyCore.grapheneSuitChest.itemID) { player.capabilities.allowFlying = true; player.sendPlayerAbilities(); }else if(itemstack.itemID != FuturologyCore.grapheneSuitChest.itemID){ player.capabilities.allowFlying = false; player.capabilities.isFlying = false; } }
August 27, 201312 yr if (player.inventory.armorItemInSlot(2) != null) { ItemStack itemstack = player.inventory.armorItemInSlot(2); if (itemstack.itemID == FuturologyCore.grapheneSuitChest.itemID) { player.capabilities.allowFlying = true; player.sendPlayerAbilities(); }else if(itemstack.itemID != FuturologyCore.grapheneSuitChest.itemID){ player.capabilities.allowFlying = false; player.capabilities.isFlying = false; } } else { //case where player doesn't have any armor }
August 27, 201312 yr Author okay so I tried that( i put the code that was in the Else if into the else bracket you told me to make, and I still get the same thing happening
August 27, 201312 yr I have never done this, but try putting player.sendAbilities(); back in the else statement when the armor is unequipped, so you're resending the details Other than that, i have no idea
August 27, 201312 yr Oops, seems like onArmorTickUpdate(args) is only called on client side when the item is in the slot. Your code was really misleading. So, this else case would never be reached and your code would be better as: @Override public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack) { if (itemStack.itemID == FuturologyCore.grapheneSuitChest.itemID) { player.capabilities.allowFlying = true; player.sendPlayerAbilities(); }else if(itemStack.itemID != FuturologyCore.grapheneSuitChest.itemID){ player.capabilities.allowFlying = false; player.capabilities.isFlying = false; } } You'll need a TickHandler to reset the values.
August 27, 201312 yr Author Okay could you perhaps elaborate a bit? What would i need in the methods of the TickHandler class(I assume it implements ITickHandler) and do I keep my onArmorTickUpdate in the Item class or the tick class, and how would I link these classes together?
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.