From 000c4c5692bdbc29a5b9d80cf89d98fa8c236113 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Fri, 18 Mar 2016 16:31:55 -0400 Subject: [PATCH] Bound Tools (61 errors) --- .../bloodmagic/item/ItemArcaneAshes.java | 28 ++++---- .../bloodmagic/item/ItemBoundAxe.java | 16 +++-- .../bloodmagic/item/ItemBoundPickaxe.java | 29 ++++---- .../bloodmagic/item/ItemBoundShovel.java | 50 ++++++++------ .../bloodmagic/item/ItemBoundSword.java | 44 ++++++------ .../bloodmagic/item/ItemBoundTool.java | 68 ++++++++----------- .../bloodmagic/item/ItemRitualDiviner.java | 46 +++++++------ 7 files changed, 148 insertions(+), 133 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java b/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java index 5249a262..69858c91 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java @@ -1,23 +1,25 @@ package WayofTime.bloodmagic.item; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.registry.ModBlocks; import WayofTime.bloodmagic.util.helper.TextHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.ArrayList; -import java.util.List; public class ItemArcaneAshes extends Item implements IVariantProvider { diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java index 105321f2..e5ef51a6 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java @@ -6,6 +6,7 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; @@ -14,6 +15,7 @@ import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Enchantments; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -50,7 +52,7 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player) + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @@ -62,7 +64,7 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider return; boolean silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, stack) > 0; - int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); + int fortuneLvl = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, stack); int range = (int) (charge / 6); //Charge is a max of 30 - want 5 to be the max HashMultiset drops = HashMultiset.create(); @@ -87,7 +89,7 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider if (blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) { - float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock()); + float strengthVsBlock = getStrVsBlock(stack, blockStack.getState()); if (strengthVsBlock > 1.1F || blockStack.getBlock() instanceof BlockLeaves && world.canMineBlockBody(player, blockPos)) { @@ -115,10 +117,12 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider } @Override - public Multimap getAttributeModifiers(ItemStack stack) + public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { - Multimap multimap = super.getAttributeModifiers(stack); - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 7, 0)); + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 7, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); + return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java index b570bd91..0e63adfa 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java @@ -6,6 +6,7 @@ import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; @@ -13,6 +14,8 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Enchantments; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -49,13 +52,13 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player) + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @Override - public boolean canHarvestBlock(Block blockIn) + public boolean canHarvestBlock(IBlockState blockIn) { return blockIn == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (blockIn != Blocks.diamond_block && blockIn != Blocks.diamond_ore ? (blockIn != Blocks.emerald_ore && blockIn != Blocks.emerald_block ? (blockIn != Blocks.gold_block && blockIn != Blocks.gold_ore ? (blockIn != Blocks.iron_block && blockIn != Blocks.iron_ore ? (blockIn != Blocks.lapis_block && blockIn != Blocks.lapis_ore ? (blockIn != Blocks.redstone_ore && blockIn != Blocks.lit_redstone_ore ? (blockIn.getMaterial() == Material.rock || (blockIn.getMaterial() == Material.iron || blockIn.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) @@ -63,12 +66,12 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider } @Override - public float getStrVsBlock(ItemStack stack, Block block) + public float getStrVsBlock(ItemStack stack, IBlockState state) { if (!getActivated(stack)) return 1.0F; - return block.getMaterial() != Material.iron && block.getMaterial() != Material.anvil && block.getMaterial() != Material.rock ? super.getStrVsBlock(stack, block) : this.efficiencyOnProperMaterial; + return state.getMaterial() != Material.iron && state.getMaterial() != Material.anvil && state.getMaterial() != Material.rock ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial; } @Override @@ -77,8 +80,8 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider if (world.isRemote) return; - boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); - int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); + boolean silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, stack) > 0; + int fortuneLvl = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, stack); int range = (int) (charge / 6); //Charge is a max of 30 - want 5 to be the max HashMultiset drops = HashMultiset.create(); @@ -94,16 +97,16 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider BlockPos blockPos = playerPos.add(i, j, k); BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos); - if (blockStack.getBlock().isAir(world, blockPos)) + if (blockStack.getBlock().isAir(blockStack.getState(), world, blockPos)) continue; BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockPos, blockStack.getState(), player); if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) continue; - if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(world, blockPos) != -1) + if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) { - float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock()); + float strengthVsBlock = getStrVsBlock(stack, blockStack.getState()); if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) { @@ -131,10 +134,12 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider } @Override - public Multimap getAttributeModifiers(ItemStack stack) + public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { - Multimap multimap = super.getAttributeModifiers(stack); - multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 5, 0)); + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 5, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); + return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java index bff22e31..00d33f15 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java @@ -1,15 +1,11 @@ package WayofTime.bloodmagic.item; -import WayofTime.bloodmagic.api.BlockStack; -import WayofTime.bloodmagic.api.Constants; -import WayofTime.bloodmagic.api.ItemStackWrapper; -import WayofTime.bloodmagic.api.util.helper.NetworkHelper; -import WayofTime.bloodmagic.client.IMeshProvider; -import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; @@ -17,18 +13,26 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Enchantments; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import WayofTime.bloodmagic.api.BlockStack; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.ItemStackWrapper; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; +import WayofTime.bloodmagic.client.IMeshProvider; +import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider { @@ -47,7 +51,7 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase player) + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @@ -58,8 +62,8 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider if (world.isRemote) return; - boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(player); - int fortuneLvl = EnchantmentHelper.getFortuneModifier(player); + boolean silkTouch = EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, stack) > 0; + int fortuneLvl = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, stack); int range = (int) (charge / 6); //Charge is a max of 30 - want 5 to be the max HashMultiset drops = HashMultiset.create(); @@ -75,16 +79,16 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider BlockPos blockPos = playerPos.add(i, j, k); BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos); - if (blockStack.getBlock().isAir(world, blockPos)) + if (blockStack.getBlock().isAir(blockStack.getState(), world, blockPos)) continue; BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, blockPos, blockStack.getState(), player); if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) continue; - if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(world, blockPos) != -1) + if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) { - float strengthVsBlock = getStrVsBlock(stack, blockStack.getBlock()); + float strengthVsBlock = getStrVsBlock(stack, blockStack.getState()); if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) { @@ -112,10 +116,12 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider } @Override - public Multimap getAttributeModifiers(ItemStack stack) + public Multimap getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) { - Multimap multimap = super.getAttributeModifiers(stack); - multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", 1, 0)); + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 1, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); + return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java index d45e5ca7..bb0ab078 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java @@ -3,20 +3,26 @@ package WayofTime.bloodmagic.item; import java.util.ArrayList; import java.util.List; -import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.event.BoundToolEvent; import WayofTime.bloodmagic.api.iface.IActivatable; import WayofTime.bloodmagic.api.iface.IBindable; import WayofTime.bloodmagic.api.util.helper.NBTHelper; @@ -27,7 +33,6 @@ import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.base.Strings; -import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; public class ItemBoundSword extends ItemSword implements IBindable, IActivatable, IMeshProvider @@ -46,15 +51,22 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { - if (!player.isSneaking() && getActivated(stack)) - player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); - if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); - return stack; + if (!player.isSneaking() && getActivated(stack)) + { + BoundToolEvent.Charge event = new BoundToolEvent.Charge(player, stack); + if (MinecraftForge.EVENT_BUS.post(event)) + return new ActionResult(EnumActionResult.FAIL, event.result); + + player.setActiveHand(hand); + return new ActionResult(EnumActionResult.SUCCESS, stack); + } + + return super.onItemRightClick(stack, world, player, hand); } @Override @@ -64,7 +76,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn) + public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) { return true; } @@ -81,8 +93,8 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable { NBTHelper.checkNBT(stack); - if (StatCollector.canTranslate("tooltip.BloodMagic.bound.sword.desc")) - tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.bound.sword.desc")); +// if (StatCollector.canTranslate("tooltip.BloodMagic.bound.sword.desc")) + tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.bound.sword.desc")); tooltip.add(TextHelper.localize("tooltip.BloodMagic." + (getActivated(stack) ? "activated" : "deactivated"))); @@ -91,17 +103,11 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public Multimap getItemAttributeModifiers() + public Multimap getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) { - return HashMultimap.create(); - } - - @Override - public Multimap getAttributeModifiers(ItemStack stack) - { - Multimap multimap = super.getAttributeModifiers(stack); + Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); double damage = getActivated(stack) ? this.attackDamage : 1.0D; - multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", damage, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", damage, 0)); return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java index 92f3217b..773d8f9b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java @@ -9,13 +9,15 @@ import lombok.Getter; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -31,7 +33,6 @@ import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.util.helper.TextHelper; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Multimap; import com.google.common.collect.Multiset; @Getter @@ -48,7 +49,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable public ItemBoundTool(String name, float damage, Set effectiveBlocks) { - super(damage, ModItems.boundToolMaterial, effectiveBlocks); + super(damage, 1, ModItems.boundToolMaterial, effectiveBlocks); setUnlocalizedName(Constants.Mod.MODID + ".bound." + name); this.name = name; @@ -57,13 +58,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public float getStrVsBlock(ItemStack stack, Block block) - { - return getActivated(stack) ? getToolMaterial().getEfficiencyOnProperMaterial() : 1.0F; - } - - @Override - public float getDigSpeed(ItemStack stack, IBlockState state) + public float getStrVsBlock(ItemStack stack, IBlockState state) { return getActivated(stack) ? getToolMaterial().getEfficiencyOnProperMaterial() : 1.0F; } @@ -77,10 +72,10 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (entityIn instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entityIn).getCurrentEquippedItem()) + if (entityIn instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entityIn).getActiveItemStack()) { EntityPlayer player = (EntityPlayer) entityIn; - setHeldDownCount(stack, Math.min(player.getItemInUseDuration(), chargeTime)); + setHeldDownCount(stack, Math.min(player.getItemInUseCount(), chargeTime)); } else if (!isSelected) { setBeingHeldDown(stack, false); @@ -114,7 +109,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); @@ -123,29 +118,33 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable { BoundToolEvent.Charge event = new BoundToolEvent.Charge(player, stack); if (MinecraftForge.EVENT_BUS.post(event)) - return event.result; + return new ActionResult(EnumActionResult.FAIL, event.result); - player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); - setBeingHeldDown(stack, true); + player.setActiveHand(hand); + return new ActionResult(EnumActionResult.SUCCESS, stack); } - return stack; + return super.onItemRightClick(stack, world, player, hand); } @Override - public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) + public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { - if (!playerIn.isSneaking() && getActivated(stack)) + if (entityLiving instanceof EntityPlayer) { - int i = this.getMaxItemUseDuration(stack) - timeLeft; - BoundToolEvent.Release event = new BoundToolEvent.Release(playerIn, stack, i); - if (MinecraftForge.EVENT_BUS.post(event)) - return; + EntityPlayer player = (EntityPlayer) entityLiving; + if (!player.isSneaking() && getActivated(stack)) + { + int i = this.getMaxItemUseDuration(stack) - timeLeft; + BoundToolEvent.Release event = new BoundToolEvent.Release(player, stack, i); + if (MinecraftForge.EVENT_BUS.post(event)) + return; - i = event.charge; + i = event.charge; - onBoundRelease(stack, worldIn, playerIn, Math.min(i, chargeTime)); - setBeingHeldDown(stack, false); + onBoundRelease(stack, worldIn, player, Math.min(i, chargeTime)); + setBeingHeldDown(stack, false); + } } } @@ -155,16 +154,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public Multimap getAttributeModifiers(ItemStack stack) - { - Multimap multimap = super.getAttributeModifiers(stack); - double damage = getActivated(stack) ? this.damage : 1.0D; - multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Weapon modifier", damage, 0)); - return multimap; - } - - @Override - public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) + public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) { return stack; } @@ -191,8 +181,8 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { - if (StatCollector.canTranslate(tooltipBase + "desc")) - tooltip.add(TextHelper.localizeEffect(tooltipBase + "desc")); +// if (StatCollector.canTranslate(tooltipBase + "desc")) + tooltip.add(TextHelper.localizeEffect(tooltipBase + "desc")); tooltip.add(TextHelper.localize("tooltip.BloodMagic." + (getActivated(stack) ? "activated" : "deactivated"))); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java index e472cbf4..f93485c6 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java @@ -1,5 +1,29 @@ package WayofTime.bloodmagic.item; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.input.Keyboard; + import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.registry.RitualRegistry; @@ -12,28 +36,6 @@ import WayofTime.bloodmagic.registry.ModBlocks; import WayofTime.bloodmagic.tile.TileMasterRitualStone; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.List; public class ItemRitualDiviner extends Item implements IVariantProvider {