Admiral_Damage

Armor.java

Feb 2nd, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. package eu.tetrabyte.contentmod.items;
  2.  
  3. import eu.tetrabyte.contentmod.ContentMod;
  4. import net.minecraft.client.model.ModelBiped;
  5. import net.minecraft.entity.EntityLivingBase;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.item.EnumAction;
  8. import net.minecraft.item.ItemArmor;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraftforge.fml.relauncher.Side;
  11. import net.minecraftforge.fml.relauncher.SideOnly;
  12.  
  13. public class Armor extends ItemArmor {
  14.     private static float scale = 0.125F;
  15.     static ModelBiped armorModel = null;
  16.     private ItemStack heldItem = null;
  17.  
  18.     public Armor(ArmorMaterial material, int renderIndex, int armorType) {
  19.         super(material, renderIndex, armorType);
  20.         this.setMaxStackSize(1);
  21.         this.setCreativeTab(ContentMod.tabContent);
  22.     }
  23.  
  24.     public static void init() {
  25.         armorModel = new ModelBiped(scale);
  26.     }
  27.  
  28.     @Override
  29.     @SideOnly(Side.CLIENT)
  30.     public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
  31.  
  32.         scale = 0.5F;
  33.        
  34.        
  35.         //All below could be replaced by armorModel.setModelAttributes(_default);
  36.         if (itemStack != null) {
  37.  
  38.             armorModel.isSneak = entityLiving.isSneaking();
  39.             armorModel.isRiding = entityLiving.isRiding();
  40.             armorModel.isChild = entityLiving.isChild();
  41.  
  42.             armorModel.heldItemRight = 0;
  43.             armorModel.aimedBow = false;
  44.  
  45.             heldItem = entityLiving.getHeldItem();
  46.  
  47.             if (heldItem != null) {
  48.  
  49.                 armorModel.heldItemRight = 1;
  50.  
  51.                 if (entityLiving instanceof EntityPlayer) {
  52.                     EntityPlayer player = (EntityPlayer) entityLiving;
  53.  
  54.                     if (player.getItemInUseCount() > 0 && entityLiving instanceof EntityPlayer) {
  55.  
  56.                         EnumAction enumaction = heldItem.getItemUseAction();
  57.  
  58.                         if (enumaction == EnumAction.BOW) {
  59.  
  60.                             armorModel.aimedBow = true;
  61.  
  62.                         } else if (enumaction == EnumAction.BLOCK) {
  63.  
  64.                             armorModel.heldItemRight = 3;
  65.  
  66.                         }
  67.                     }
  68.  
  69.                 }
  70.             }
  71.  
  72.         }
  73.         return armorModel;
  74.  
  75.     }
  76.  
  77.     public int getColor(ItemStack itemstack) {
  78.         return 0xFFFFFF;
  79.     }
  80.  
  81.     public int getColorFromItemStack(ItemStack itemstack, int renderpass) {
  82.         return 0xFFFFFF;
  83.     }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment