Adjust tools to new blockbreak code stuff. Yay for proper calls.

This commit is contained in:
Bernhard Bonigl committed 2014-09-17 15:32:51 +02:00
1 parent 8773232660
commit 619bfdb1f1
6 files changed
+81 -366

No files matched your search

@@ -16,11 +16,11 @@ import tconstruct.library.*;
import tconstruct.library.tools.*;
import tconstruct.tools.TinkerTools;
public class Battleaxe extends HarvestTool
public class Battleaxe extends AOEHarvestTool
{
public Battleaxe()
{
super(4);
super(4, 1,1);
this.setUnlocalizedName("InfiTool.Battleaxe");
}
@@ -233,56 +233,4 @@ public class Battleaxe extends HarvestTool
}
}
}
@Override
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
{
if (!stack.hasTagCompound())
return false;
World world = player.worldObj;
final Block block = world.getBlock(x, y, z);
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
final int meta = world.getBlockMetadata(x, y, z);
for (int yPos = y + 1; yPos < y + 9; yPos++)
{
Block localBlock = world.getBlock(x, yPos, z);
if (!(tags.getBoolean("Broken")) && localBlock != null && localBlock.getMaterial() == Material.wood)
{
int localMeta = world.getBlockMetadata(x, yPos, z);
int hlvl = localBlock.getHarvestLevel(localMeta);
if (hlvl <= tags.getInteger("HarvestLevel"))
{
boolean cancelHarvest = false;
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
{
if (mod.beforeBlockBreak(this, stack, x, yPos, z, player))
cancelHarvest = true;
}
if (!cancelHarvest)
{
if (localBlock != null && localBlock.getMaterial() == Material.wood)
{
if (!player.capabilities.isCreativeMode)
{
mineBlock(world, x, yPos, z, localMeta, player, localBlock);
onBlockDestroyed(stack, world, localBlock, x, yPos, z, player);
}
else
{
WorldHelper.setBlockToAir(world, x, yPos, z);
}
}
}
}
}
else
break;
}
if (!world.isRemote)
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
return super.onBlockStartBreak(stack, x, y, z, player);
}
}