Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package idunno_meneither.tutorial.init.main.items;
- import java.util.List;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- public class ItemOrbBoss extends Item {
- @Override
- public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
- NBTTagCompound nbt;
- if (stack.hasTagCompound()) {
- nbt = stack.getTagCompound();
- } else {
- nbt = new NBTTagCompound();
- }
- if (nbt.hasKey("Uses") && target.getHealth() <= 0) {
- nbt.setInteger("Uses", nbt.getInteger("Uses") + 1);
- }
- stack.setTagCompound(nbt);
- return stack != null;
- }
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
- if (stack.hasTagCompound() && stack.getTagCompound().hasKey("Uses")) {
- tooltip.add(Integer.toString(stack.getTagCompound().getInteger("Uses")));
- if (stack.getTagCompound().hasKey("Uses") && stack.getTagCompound().getInteger("Uses") >= 10) {
- tooltip.removeAll(tooltip);
- tooltip.add(stack.getUnlocalizedName());
- tooltip.add("Orb is full");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment