Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;
		}
	}

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
}

  • 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

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

Oops, seems like onArmorTickUpdate(args) is only called on client side when the item is in the slot.

Your code was really misleading.  :P

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.

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.