MrDood_Modding

ItemCaelumFlyingArmor.java

Feb 3rd, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.56 KB | None | 0 0
  1. package com.josh.gomc.armor;
  2.  
  3. import com.josh.gomc.Main;
  4.  
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.item.ItemArmor;
  9. import net.minecraft.item.ItemArmor.ArmorMaterial;
  10. import net.minecraft.potion.Potion;
  11. import net.minecraft.potion.PotionEffect;
  12. import net.minecraft.world.World;
  13.  
  14. public class ItemCaelumFlyingArmor extends ItemArmor{
  15.     private String textureName;
  16.  
  17.     public ItemCaelumFlyingArmor(ArmorMaterial material, int type, String textureName) {
  18.         super(material, 0, type);
  19.         this.textureName = textureName;
  20.     }
  21.     @Override
  22.     public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
  23.     {
  24.         return "gomc:textures/models/armor/" + this.textureName + "_" + (this.armorType == 2 ? "2" : "1") + ".png";
  25.     }
  26.    
  27.     @Override
  28.     public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
  29.         if (itemStack.getItem().equals(Main.itemCaelumFlyingHelmet))
  30.             player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300));
  31.         if (itemStack.getItem().equals(Main.itemCaelumFlyingChestplate))
  32.             player.addPotionEffect(new PotionEffect(Potion.resistance.id, 40, 2));
  33.         if (itemStack.getItem().equals(Main.itemCaelumFlyingLeggings))
  34.             player.addPotionEffect(new PotionEffect(Potion.jump.id, 40, 3));
  35.         if (itemStack.getItem().equals(Main.itemCaelumFlyingBoots))
  36.             player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 40, 2));
  37.         if(player.getCurrentArmor(3) != null && player.getCurrentArmor(2) != null && player.getCurrentArmor(1) != null && player.getCurrentArmor(0) != null){
  38.             ItemStack helmet = player.getCurrentArmor(3);
  39.             ItemStack chestplate = player.getCurrentArmor(2);
  40.             ItemStack leggings = player.getCurrentArmor(1);
  41.             ItemStack boots = player.getCurrentArmor(0);
  42.  
  43.             if(helmet.getItem() == Main.itemCaelumFlyingHelmet) {
  44.                 if(chestplate.getItem() == Main.itemCaelumFlyingChestplate){
  45.                     if(leggings.getItem() == Main.itemCaelumFlyingLeggings){
  46.                         if(boots.getItem() == Main.itemCaelumFlyingBoots){
  47.                             player.capabilities.allowFlying = true;
  48.                             player.fallDistance = 0.0f;
  49.                         }
  50.                     }
  51.                 }
  52.             }
  53.             if(helmet.getItem() != Main.itemCaelumFlyingHelmet || chestplate.getItem() != Main.itemCaelumFlyingChestplate || leggings.getItem() != Main.itemCaelumFlyingLeggings || boots.getItem() != Main.itemCaelumFlyingBoots) {
  54.             player.capabilities.allowFlying = false;
  55.             player.capabilities.isFlying = false;
  56.             }
  57.             }
  58.     }
  59. }
Add Comment
Please, Sign In to add comment