Jump to content

[1.10.2] Chestplate with Flight?


Haydenman2

Recommended Posts

I want to create a Chestplate that works with flight as long as it's worn, but as soon as it's taken off your flight is immediately disabled and you can no longer fly. I can get it so that you can fly after first putting it on but taking it off won't disable it until a reload. Any tips?

 

 

package tustuff.items.armor;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.EntityEquipmentSlot;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import tustuff.init.GlobalMethods;

import tustuff.init.ModItems;

import tustuff.init.NameReg;

import tustuff.other.ModMaterials;

import tustuff.other.TabTustuff;

 

public class JPurpleGodlyChest extends ItemArmor {

 

public JPurpleGodlyChest(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) {

super(ModMaterials.armorGodlyPurple, 1, EntityEquipmentSlot.CHEST);

setUnlocalizedName(NameReg.ModItems.JPURPLEGODLYCHEST.getUnlocalizedName());

setRegistryName(NameReg.ModItems.JPURPLEGODLYCHEST.getRegistryName());

setCreativeTab(TabTustuff.tabTustuff);

}

 

public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack){

if(player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(2).getItem() == ModItems.jpurplegodlychest){

player.capabilities.allowFlying = true;

player.sendPlayerAbilities();

return;

}else{

player.capabilities.allowFlying = false;

player.capabilities.isFlying = false;

player.sendPlayerAbilities();

}

}

}

 

 

...

Link to comment
Share on other sites

onArmorTickUpdate

doesn't fire unless the armor is in an equip slot.

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.

Link to comment
Share on other sites

I want to create a Chestplate that works with flight as long as it's worn, but as soon as it's taken off your flight is immediately disabled and you can no longer fly. I can get it so that you can fly after first putting it on but taking it off won't disable it until a reload. Any tips?

 

 

package tustuff.items.armor;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.EntityEquipmentSlot;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import tustuff.init.GlobalMethods;

import tustuff.init.ModItems;

import tustuff.init.NameReg;

import tustuff.other.ModMaterials;

import tustuff.other.TabTustuff;

 

public class JPurpleGodlyChest extends ItemArmor {

 

public JPurpleGodlyChest(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) {

super(ModMaterials.armorGodlyPurple, 1, EntityEquipmentSlot.CHEST);

setUnlocalizedName(NameReg.ModItems.JPURPLEGODLYCHEST.getUnlocalizedName());

setRegistryName(NameReg.ModItems.JPURPLEGODLYCHEST.getRegistryName());

setCreativeTab(TabTustuff.tabTustuff);

}

 

public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack){

if(player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(2).getItem() == ModItems.jpurplegodlychest){

player.capabilities.allowFlying = true;

player.sendPlayerAbilities();

return;

}else{

player.capabilities.allowFlying = false;

player.capabilities.isFlying = false;

player.sendPlayerAbilities();

}

}

}

 

 

As Draco said it doesn't get called unless it is equiped, solution subscribe to PlayerTickEvent in an EventHandler.

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.

Link to comment
Share on other sites

onArmorTickUpdate

doesn't fire unless the armor is in an equip slot.

 

That's interesting, is there a method that fires on removal of said piece of armor?

Sadly no.

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.

Link to comment
Share on other sites

I want to create a Chestplate that works with flight as long as it's worn, but as soon as it's taken off your flight is immediately disabled and you can no longer fly. I can get it so that you can fly after first putting it on but taking it off won't disable it until a reload. Any tips?

 

 

package tustuff.items.armor;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.EntityEquipmentSlot;

import net.minecraft.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import tustuff.init.GlobalMethods;

import tustuff.init.ModItems;

import tustuff.init.NameReg;

import tustuff.other.ModMaterials;

import tustuff.other.TabTustuff;

 

public class JPurpleGodlyChest extends ItemArmor {

 

public JPurpleGodlyChest(ArmorMaterial materialIn, int renderIndexIn, EntityEquipmentSlot equipmentSlotIn) {

super(ModMaterials.armorGodlyPurple, 1, EntityEquipmentSlot.CHEST);

setUnlocalizedName(NameReg.ModItems.JPURPLEGODLYCHEST.getUnlocalizedName());

setRegistryName(NameReg.ModItems.JPURPLEGODLYCHEST.getRegistryName());

setCreativeTab(TabTustuff.tabTustuff);

}

 

public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack){

if(player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(2).getItem() == ModItems.jpurplegodlychest){

player.capabilities.allowFlying = true;

player.sendPlayerAbilities();

return;

}else{

player.capabilities.allowFlying = false;

player.capabilities.isFlying = false;

player.sendPlayerAbilities();

}

}

}

 

 

As Draco said it doesn't get called unless it is equiped, solution subscribe to PlayerTickEvent in an EventHandler.

 

Clever method, will do. Thanks you two

...

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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