diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java index c4077953..350b5a9a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundAxe.java @@ -2,6 +2,7 @@ package WayofTime.alchemicalWizardry.common.items; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; +import WayofTime.alchemicalWizardry.common.ItemType; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -25,6 +26,8 @@ import net.minecraftforge.common.ForgeHooks; import java.util.ArrayList; import java.util.List; +import com.google.common.collect.HashMultiset; + public class BoundAxe extends ItemAxe implements IBindable { public float efficiencyOnProperMaterial = 12.0F; @@ -135,6 +138,8 @@ public class BoundAxe extends ItemAxe implements IBindable boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer); int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer); + HashMultiset dropMultiset = HashMultiset.create(); + for (int i = -5; i <= 5; i++) { for (int j = 0; j <= 10; j++) @@ -152,27 +157,18 @@ public class BoundAxe extends ItemAxe implements IBindable { if (silkTouch && block.canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta)) { - ItemStack droppedItem = new ItemStack(block, 1, meta); - - if (!par2World.isRemote) - { - par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem)); - } + dropMultiset.add(new ItemType(block, meta)); } else { ArrayList itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl); if (itemDropList != null) { - for (ItemStack item : itemDropList) - { - if (!par2World.isRemote) - { - par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item)); - } - } + for (ItemStack stack : itemDropList) + dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); } } + par2World.setBlockToAir(posX + i, posY + j, posZ + k); } } @@ -180,7 +176,8 @@ public class BoundAxe extends ItemAxe implements IBindable } } - + BoundPickaxe.dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ); + return par1ItemStack; } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java index f58bc716..cc47270f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundPickaxe.java @@ -184,7 +184,14 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable } } } - + + dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ); + + return par1ItemStack; + } + + public static void dropMultisetStacks(Multiset dropMultiset, World world, double x, double y, double z) + { for (Multiset.Entry entry : dropMultiset.entrySet()) { int count = entry.getCount(); @@ -194,15 +201,13 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable //Drop in groups of maximum size while (count >= maxStackSize) { - par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, type.createStack(maxStackSize))); + world.spawnEntityInWorld(new EntityItem(world, x, y, z, type.createStack(maxStackSize))); count -= maxStackSize; } //Drop remainder if (count > 0) - par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, type.createStack(count))); + world.spawnEntityInWorld(new EntityItem(world, x, y, z, type.createStack(count))); } - - return par1ItemStack; } @Override diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java index 82969790..d3a7777f 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/items/BoundShovel.java @@ -2,8 +2,10 @@ package WayofTime.alchemicalWizardry.common.items; import WayofTime.alchemicalWizardry.AlchemicalWizardry; import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable; +import WayofTime.alchemicalWizardry.common.ItemType; import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; +import com.google.common.collect.HashMultiset; import com.google.common.collect.Multimap; import cpw.mods.fml.relauncher.Side; @@ -141,6 +143,8 @@ public class BoundShovel extends ItemSpade implements IBindable boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer); int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer); + HashMultiset dropMultiset = HashMultiset.create(); + for (int i = -5; i <= 5; i++) { for (int j = 0; j <= 10; j++) @@ -158,25 +162,15 @@ public class BoundShovel extends ItemSpade implements IBindable { if (silkTouch && block.canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta)) { - ItemStack droppedItem = new ItemStack(block, 1, meta); - - if (!par2World.isRemote) - { - par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem)); - } + dropMultiset.add(new ItemType(block, meta)); } else { ArrayList itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl); if (itemDropList != null) { - for (ItemStack item : itemDropList) - { - if (!par2World.isRemote) - { - par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item)); - } - } + for (ItemStack stack : itemDropList) + dropMultiset.add(ItemType.fromStack(stack), stack.stackSize); } } @@ -186,6 +180,8 @@ public class BoundShovel extends ItemSpade implements IBindable } } } + + BoundPickaxe.dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ); return par1ItemStack; }