Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag) {
- super.onUpdate(itemStack, world, entity, i, flag);
- NBTTagCompound nbtDataCompund = itemStack.getSubCompound("coolDown", true);
- int coolDown = nbtDataCompund.getInteger("coolDown");
- if (coolDown > 0) {
- --coolDown;
- nbtDataCompund.setInteger("coolDown", coolDown);
- }
- }
- @Override
- public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityPlayer, EntityLivingBase entity, EnumHand hand) {
- NBTTagCompound nbtDataCompund = itemStack.getSubCompound("coolDown", true);
- if (nbtDataCompund != null) {
- int coolDown = nbtDataCompund.getInteger("coolDown");
- if (coolDown > 0) {
- return false;
- }
- if (coolDown == 0) {
- if (entity instanceof EntityMob) {
- if (itemStack.getItemDamage() > 0) {
- entity.setHealth(0.0F);
- nbtDataCompund.setInteger("coolDown", ItemConfig.magicStoneCooldown);
- if (!entity.worldObj.isRemote) {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Soul Absurbed!"));
- }
- itemStack.damageItem(-1, entityPlayer);
- return true;
- } else {
- if (!entity.worldObj.isRemote) {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "The Magical Stone seems to be full?"));
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "It seems to be useless now."));
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "I wonder whats inside?"));
- }
- return true;
- }
- } else if (!entity.worldObj.isRemote) {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
- }
- } else {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement