Apply to shovel and axe as well
This commit is contained in:
parent
d800e06cb8
commit
1887df3d1e
|
@ -2,6 +2,7 @@ package WayofTime.alchemicalWizardry.common.items;
|
||||||
|
|
||||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||||
|
import WayofTime.alchemicalWizardry.common.ItemType;
|
||||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -25,6 +26,8 @@ import net.minecraftforge.common.ForgeHooks;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashMultiset;
|
||||||
|
|
||||||
public class BoundAxe extends ItemAxe implements IBindable
|
public class BoundAxe extends ItemAxe implements IBindable
|
||||||
{
|
{
|
||||||
public float efficiencyOnProperMaterial = 12.0F;
|
public float efficiencyOnProperMaterial = 12.0F;
|
||||||
|
@ -135,6 +138,8 @@ public class BoundAxe extends ItemAxe implements IBindable
|
||||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
||||||
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
||||||
|
|
||||||
|
HashMultiset<ItemType> dropMultiset = HashMultiset.create();
|
||||||
|
|
||||||
for (int i = -5; i <= 5; i++)
|
for (int i = -5; i <= 5; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j <= 10; j++)
|
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))
|
if (silkTouch && block.canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta))
|
||||||
{
|
{
|
||||||
ItemStack droppedItem = new ItemStack(block, 1, meta);
|
dropMultiset.add(new ItemType(block, meta));
|
||||||
|
|
||||||
if (!par2World.isRemote)
|
|
||||||
{
|
|
||||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem));
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
||||||
|
|
||||||
if (itemDropList != null)
|
if (itemDropList != null)
|
||||||
{
|
{
|
||||||
for (ItemStack item : itemDropList)
|
for (ItemStack stack : itemDropList)
|
||||||
{
|
dropMultiset.add(ItemType.fromStack(stack), stack.stackSize);
|
||||||
if (!par2World.isRemote)
|
|
||||||
{
|
|
||||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
par2World.setBlockToAir(posX + i, posY + j, posZ + k);
|
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;
|
return par1ItemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<ItemType> dropMultiset, World world, double x, double y, double z)
|
||||||
|
{
|
||||||
for (Multiset.Entry<ItemType> entry : dropMultiset.entrySet())
|
for (Multiset.Entry<ItemType> entry : dropMultiset.entrySet())
|
||||||
{
|
{
|
||||||
int count = entry.getCount();
|
int count = entry.getCount();
|
||||||
|
@ -194,15 +201,13 @@ public class BoundPickaxe extends ItemPickaxe implements IBindable
|
||||||
//Drop in groups of maximum size
|
//Drop in groups of maximum size
|
||||||
while (count >= maxStackSize)
|
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;
|
count -= maxStackSize;
|
||||||
}
|
}
|
||||||
//Drop remainder
|
//Drop remainder
|
||||||
if (count > 0)
|
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
|
@Override
|
||||||
|
|
|
@ -2,8 +2,10 @@ package WayofTime.alchemicalWizardry.common.items;
|
||||||
|
|
||||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||||
|
import WayofTime.alchemicalWizardry.common.ItemType;
|
||||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashMultiset;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
@ -141,6 +143,8 @@ public class BoundShovel extends ItemSpade implements IBindable
|
||||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
||||||
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
||||||
|
|
||||||
|
HashMultiset<ItemType> dropMultiset = HashMultiset.create();
|
||||||
|
|
||||||
for (int i = -5; i <= 5; i++)
|
for (int i = -5; i <= 5; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j <= 10; j++)
|
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))
|
if (silkTouch && block.canSilkHarvest(par2World, par3EntityPlayer, posX + i, posY + j, posZ + k, meta))
|
||||||
{
|
{
|
||||||
ItemStack droppedItem = new ItemStack(block, 1, meta);
|
dropMultiset.add(new ItemType(block, meta));
|
||||||
|
|
||||||
if (!par2World.isRemote)
|
|
||||||
{
|
|
||||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem));
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
||||||
|
|
||||||
if (itemDropList != null)
|
if (itemDropList != null)
|
||||||
{
|
{
|
||||||
for (ItemStack item : itemDropList)
|
for (ItemStack stack : itemDropList)
|
||||||
{
|
dropMultiset.add(ItemType.fromStack(stack), stack.stackSize);
|
||||||
if (!par2World.isRemote)
|
|
||||||
{
|
|
||||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +180,8 @@ public class BoundShovel extends ItemSpade implements IBindable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoundPickaxe.dropMultisetStacks(dropMultiset, par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ);
|
||||||
|
|
||||||
return par1ItemStack;
|
return par1ItemStack;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue