Guest User

Untitled

a guest
Jan 22nd, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. package idunno_meneither.tutorial.init.main.items;
  2.  
  3. import java.util.List;
  4.  
  5. import net.minecraft.entity.EntityLivingBase;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.nbt.NBTTagCompound;
  10.  
  11. public class ItemOrbBoss extends Item {
  12.  
  13.    
  14.     @Override
  15.     public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
  16.  
  17.         NBTTagCompound nbt;
  18.         if (stack.hasTagCompound()) {
  19.             nbt = stack.getTagCompound();
  20.         } else {
  21.             nbt = new NBTTagCompound();
  22.         }
  23.  
  24.         if (nbt.hasKey("Uses") && target.getHealth() <= 0) {
  25.             nbt.setInteger("Uses", nbt.getInteger("Uses") + 1);
  26.         }
  27.         stack.setTagCompound(nbt);
  28.         return stack != null;
  29.     }
  30.    
  31.     @Override
  32.     public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
  33.  
  34.         if (stack.hasTagCompound() && stack.getTagCompound().hasKey("Uses")) {
  35.             tooltip.add(Integer.toString(stack.getTagCompound().getInteger("Uses")));
  36.             if (stack.getTagCompound().hasKey("Uses") && stack.getTagCompound().getInteger("Uses") >= 10) {
  37.                 tooltip.removeAll(tooltip);
  38.                 tooltip.add(stack.getUnlocalizedName());
  39.                 tooltip.add("Orb is full");
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment