From 59920ef34f3ecad438b721fbc560848d9851e331 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Sun, 5 Feb 2017 12:42:28 -0800 Subject: [PATCH] Bound tools should drain LP (#1033) --- .../java/WayofTime/bloodmagic/item/ItemBoundSword.java | 9 +++++++++ .../java/WayofTime/bloodmagic/item/ItemBoundTool.java | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java index 7e264f3f..4664a5b3 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java @@ -5,10 +5,12 @@ import java.util.List; import javax.annotation.Nullable; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.Utils; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -68,6 +70,13 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable return super.onItemRightClick(stack, world, player, hand); } + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) + { + if (entity instanceof EntityPlayer && getActivated(stack) && world.getTotalWorldTime() % 80 == 0) + NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entity, 20); + } + @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java index 17a03491..7bcb7232 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Set; import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.Utils; import com.google.common.base.Strings; @@ -86,16 +87,19 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { - if (entityIn instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entityIn).getActiveItemStack()) + if (entity instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entity).getActiveItemStack()) { - EntityPlayer player = (EntityPlayer) entityIn; + EntityPlayer player = (EntityPlayer) entity; setHeldDownCount(stack, Math.min(player.getItemInUseCount(), chargeTime)); } else if (!isSelected) { setBeingHeldDown(stack, false); } + + if (entity instanceof EntityPlayer && getActivated(stack) && world.getTotalWorldTime() % 80 == 0) + NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entity, 20); } protected int getHeldDownCount(ItemStack stack)