Hello, can you please show me a method that allows you to fly when i put on the boots of my armor? i already have a method that gives you effects when you put on the armor, if i allow the player to fly in this method, it works, but when i put off the armor i can still fly. ( yes, im in gamemode 0 ) i have googled it but i didnt find a solution.
Here is my method:
@Override
public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemstack){
if (itemstack.itemID == Superman.itemArmorSupermanHelmet.itemID){
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 5, 15));
}
if(itemstack.itemID == Superman.itemArmorSupermanPlate.itemID){
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 5, 15));
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 5, 15));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 5, 15));
}
if(itemstack.itemID == Superman.itemArmorSupermanLegs.itemID){
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 5, 15));
}
if(itemstack.itemID == Superman.itemArmorSupermanBoots.itemID){
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 5, 15));
player.fallDistance = 0.0F;
player.capabilities.allowFlying = true;
}
}
and here is my whole armor class:
package net.Superman.mod;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ItemSupermanArmor extends ItemArmor {
private String texturePath = Superman.modid + ":" + "textures/model/armor/";
public ItemSupermanArmor(int par1, EnumArmorMaterial armorMaterial, int par3, int par4, String type) {
super(par1, armorMaterial, par3, par4);
this.setMaxStackSize(1);
this.setCreativeTab(Superman.supermanTab);
this.setTextureName(type, par4);
}
private void setTextureName(String type, int armorPart){
if(armorType == 0 || armorType == 1 || armorType == 3){
this.texturePath += type + "_layer_1.png";
}else{
this.texturePath += type + "_layer_2.png";
}
}
@Override
public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemstack){
if (itemstack.itemID == Superman.itemArmorSupermanHelmet.itemID){
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 5, 15));
}
if(itemstack.itemID == Superman.itemArmorSupermanPlate.itemID){
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 5, 15));
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 5, 15));
player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 5, 15));
}
if(itemstack.itemID == Superman.itemArmorSupermanLegs.itemID){
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 5, 15));
}
if(itemstack.itemID == Superman.itemArmorSupermanBoots.itemID){
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 5, 15));
player.fallDistance = 0.0F;
player.capabilities.allowFlying = true;
}
}
public void registerIcons(IconRegister register){
this.itemIcon = register.registerIcon(Superman.modid + ":" + this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".")+1));
}
public String getArmorTexture(ItemStack itemStack, Entity entity, int slot, int layer){
return this.texturePath;
}
}
here is my main mod class:
package net.Superman.mod;
import net.Superman.mod.item.ItemBasic;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Mod(modid = Superman.modid, name = "Superman Mod", version = "Pre-Alpha v0.01")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Superman {
public static final String modid = "superman";
public static Block blockKryptonite;
public static Block oreKryptonite;
public static CreativeTabs supermanTab;
public static EnumToolMaterial toolMaterialKryptonite;
public static EnumToolMaterial toolMaterialKryptonite2;
public static Item itemKryptonite;
public static Item itemAxeKryptonite;
public static Item itemPickaxeKryptonite;
public static Item itemSpadeKryptonite;
public static Item itemHoeKryptonite;
public static Item itemSwordKryptonite;
public static Item itemArmorSupermanHelmet;
public static Item itemArmorSupermanPlate;
public static Item itemArmorSupermanLegs;
public static Item itemArmorSupermanBoots;
public static EnumArmorMaterial armorMaterialSuperman;
@EventHandler
public void load(FMLInitializationEvent e){
supermanTab = new CreativeTabs("Superman"){
@SideOnly(Side.CLIENT)
public int getTabIconItemIndex(){
return Superman.itemKryptonite.itemID;
}
};
LanguageRegistry.instance().addStringLocalization(supermanTab.getTranslatedTabLabel(), "Superman");
armorMaterialSuperman = EnumHelper.addArmorMaterial("SupermanArmorMaterial", 100, new int[]{16, 17, 12, 9}, 50);
blockKryptonite = new BlockKryptonite(1000, Material.iron).setUnlocalizedName("Kryptoniteblock");
oreKryptonite = new OreKryptonite(1043, Material.iron).setUnlocalizedName("Kryptonite Ore");
toolMaterialKryptonite = EnumHelper.addToolMaterial("kryptoniteToolMaterial", 3, 9876, 100F, 3.5F, 25);
toolMaterialKryptonite2 = EnumHelper.addToolMaterial("kryptonite2ToolMaterial", 3, 9876, 100F, 25F, 30);
itemKryptonite = new ItemKryptonite(999).setUnlocalizedName("kryptonite");
itemAxeKryptonite = new ItemAxeKryptonite(1005, toolMaterialKryptonite).setUnlocalizedName("axeKryptonite");
itemPickaxeKryptonite = new ItemPickaxeKryptonite(1006, toolMaterialKryptonite).setUnlocalizedName("pickaxeKryptonite");
itemSpadeKryptonite = new ItemSpadeKryptonite(1007, toolMaterialKryptonite).setUnlocalizedName("spadeKryptonite");
itemHoeKryptonite = new ItemHoeKryptonite(1008, toolMaterialKryptonite).setUnlocalizedName("hoeKryptonite");
itemSwordKryptonite = new ItemSwordKryptonite(1009, toolMaterialKryptonite2).setUnlocalizedName("swordKryptonite");
itemArmorSupermanHelmet = new ItemSupermanArmor(7012, armorMaterialSuperman, 0, 0, "Superman").setUnlocalizedName("SupermanHelmet");
itemArmorSupermanPlate = new ItemSupermanArmor(7013, armorMaterialSuperman, 0, 1, "Superman").setUnlocalizedName("SupermanPlate");
itemArmorSupermanLegs = new ItemSupermanArmor(7014, armorMaterialSuperman, 0, 2, "Superman").setUnlocalizedName("SupermanLegs");
itemArmorSupermanBoots = new ItemSupermanArmor(7015, armorMaterialSuperman, 0, 3, "Superman").setUnlocalizedName("SupermanBoots");
GameRegistry.registerWorldGenerator(new WorldGeneratorSuperman());
GameRegistry.addSmelting(oreKryptonite.blockID, new ItemStack(itemKryptonite), 0.5F);
GameRegistry.addRecipe(new ItemStack(blockKryptonite, 1), new Object[]{
"XXX",
"XXX",
"XXX", 'X', itemKryptonite
});
GameRegistry.addRecipe(new ItemStack(itemKryptonite, 9), new Object[]{
"X", 'X', blockKryptonite
});
GameRegistry.addRecipe(new ItemStack(itemAxeKryptonite), new Object[]{
"XXY",
"XZY",
"YZY", 'X', itemKryptonite , 'Z', Item.stick
});
GameRegistry.addRecipe(new ItemStack(itemPickaxeKryptonite), new Object[]{
"XXX",
"YZY",
"YZY", 'X', itemKryptonite, 'Z', Item.stick
});
GameRegistry.addRecipe(new ItemStack(itemSpadeKryptonite), new Object[]{
"YXY",
"YZY",
"YZY", 'X', itemKryptonite, 'Z', Item.stick
});
GameRegistry.addRecipe(new ItemStack(itemHoeKryptonite), new Object[]{
"XXY",
"YZY",
"YZY", 'X', itemKryptonite, 'Z', Item.stick
});
GameRegistry.addRecipe(new ItemStack(itemSwordKryptonite), new Object[]{
"YXY",
"YXY",
"YZY", 'X', itemKryptonite, 'Z', Item.stick
});
GameRegistry.addRecipe(new ItemStack(itemArmorSupermanHelmet), new Object[]{
"XXX",
"XYX",
"ZZZ", 'X', itemKryptonite, 'Y', Block.obsidian
});
GameRegistry.addRecipe(new ItemStack(itemArmorSupermanHelmet), new Object[]{
"ZZZ",
"XXX",
"XYX", 'X', itemKryptonite, 'Y', Block.obsidian
});
GameRegistry.addRecipe(new ItemStack(itemArmorSupermanPlate), new Object[]{
"XYX",
"XXX",
"XXX", 'X', itemKryptonite, 'Y', Block.blockLapis
});
GameRegistry.addRecipe(new ItemStack(itemArmorSupermanLegs), new Object[]{
"XXX",
"XYX",
"XZX", 'X', itemKryptonite, 'Y', Block.blockLapis
});
GameRegistry.addRecipe(new ItemStack(itemArmorSupermanBoots), new Object[]{
"XYX",
"XZX",
"ZZZ", 'X', itemKryptonite, 'Y', Item.redstone
});
GameRegistry.addRecipe(new ItemStack(itemArmorSupermanBoots), new Object[]{
"ZZZ",
"XYX",
"XZX", 'X', itemKryptonite, 'Y', Item.redstone
});
NetworkRegistry.instance().registerConnectionHandler(new ConnectionHandler());
registerBlock(blockKryptonite, blockKryptonite.getUnlocalizedName().substring(5));
registerBlock(oreKryptonite, oreKryptonite.getUnlocalizedName().substring(5));
registerItem(itemKryptonite, "Kryptonite");
registerItem(itemAxeKryptonite, "Kryptonite Axt");
registerItem(itemPickaxeKryptonite, "Kryptonite Spitzhacke");
registerItem(itemSpadeKryptonite, "Kryptonite Schaufel");
registerItem(itemHoeKryptonite, "Kryptonite Hoe");
registerItem(itemSwordKryptonite, "Kryptonite Schwert");
registerItem(itemArmorSupermanHelmet, "Superman Helmet");
registerItem(itemArmorSupermanPlate, "Superman Chestplate");
registerItem(itemArmorSupermanLegs, "Superman Leggings");
registerItem(itemArmorSupermanBoots, "Superman Boots");
}
public void registerBlock(Block block, String name){
GameRegistry.registerBlock(block, block.getUnlocalizedName());
LanguageRegistry.addName(block, name);
}
public void registerItem(Item item, String name){
GameRegistry.registerItem(item, item.getUnlocalizedName());
LanguageRegistry.addName(item, name);
}
}
i hope you can help me (sorry for my bad english, if it is bad ) [glow=green,2,300]thx[/glow]