mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 12:42:57 +00:00
Adjust tools to new blockbreak code stuff. Yay for proper calls.
This commit is contained in:
1 parent
8773232660
commit
619bfdb1f1
6 files changed
+81
-366
No files matched your search
@@ -15,11 +15,11 @@ import tconstruct.library.*;
|
||||
import tconstruct.library.tools.*;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
|
||||
public class Excavator extends HarvestTool
|
||||
public class Excavator extends AOEHarvestTool
|
||||
{
|
||||
public Excavator()
|
||||
{
|
||||
super(2);
|
||||
super(2, 1,0);
|
||||
this.setUnlocalizedName("InfiTool.Excavator");
|
||||
}
|
||||
|
||||
@@ -130,118 +130,6 @@ public class Excavator extends HarvestTool
|
||||
return "excavator";
|
||||
}
|
||||
|
||||
/* Excavator Specific */
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
World world = player.worldObj;
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
if (block == null)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
boolean validStart = false;
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == block.getMaterial())
|
||||
{
|
||||
validStart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(world, player, false, 5.0D);
|
||||
if (mop == null || !validStart)
|
||||
return super.onBlockStartBreak(stack, x, y, z, player);
|
||||
|
||||
int xRange = 1;
|
||||
int yRange = 1;
|
||||
int zRange = 1;
|
||||
switch (mop.sideHit)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
yRange = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
zRange = 0;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
xRange = 0;
|
||||
break;
|
||||
}
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
for (int xPos = x - xRange; xPos <= x + xRange; xPos++)
|
||||
{
|
||||
for (int yPos = y - yRange; yPos <= y + yRange; yPos++)
|
||||
{
|
||||
for (int zPos = z - zRange; zPos <= z + zRange; zPos++)
|
||||
{
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
Block localBlock = world.getBlock(xPos, yPos, zPos);
|
||||
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
|
||||
int hlvl = localBlock.getHarvestLevel(localMeta);
|
||||
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, xPos, yPos, zPos, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
// send blockbreak event
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, localBlock, localMeta, player);
|
||||
event.setCanceled(cancelHarvest);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
cancelHarvest = event.isCanceled();
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (localBlock != null && !(localHardness < 0))
|
||||
{
|
||||
for (int iter = 0; iter < materials.length; iter++)
|
||||
{
|
||||
if (materials[iter] == localBlock.getMaterial())
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
mineBlock(world, xPos, yPos, zPos, localMeta, player, localBlock);
|
||||
if (localHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localBlock, xPos, yPos, zPos, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, xPos, yPos, zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float breakSpeedModifier ()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user