mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-27 15:33:03 +00:00
Merge pull request #693 from blue42u/patch-mining
Fix some block breaking problems.
This commit is contained in:
commit
389b41c8a1
11 files changed
+216
-668
No files matched your search
@@ -20,44 +20,6 @@ public abstract class DualHarvestTool extends HarvestTool
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
if (block == null || block == Blocks.air)
|
||||
return false;
|
||||
int hlvl = -1;
|
||||
int shlvl = -1;
|
||||
if (block.getHarvestTool(meta) == null || block.getHarvestTool(meta).equals(getHarvestType()))
|
||||
hlvl = block.getHarvestLevel(meta);
|
||||
if (block.getHarvestTool(meta) == null || block.getHarvestTool(meta).equals(getSecondHarvestType()))
|
||||
shlvl = block.getHarvestLevel(meta);
|
||||
|
||||
if (hlvl <= tags.getInteger("HarvestLevel") && shlvl <= tags.getInteger("HarvestLevel2"))
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
return cancelHarvest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
onBlockDestroyed(stack, world, block, x, y, z, player);
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
|
||||
@@ -22,96 +22,6 @@ public abstract class HarvestTool extends ToolCore
|
||||
super(baseDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
World world = player.worldObj;
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
// Block block = Block.blocksList[bID];
|
||||
if (block == null || block == Blocks.air)
|
||||
return false;
|
||||
int hlvl = -1;
|
||||
if (!(tags.getBoolean("Broken")))
|
||||
{
|
||||
Block localBlock = world.getBlock(x, y, z);
|
||||
int localMeta = world.getBlockMetadata(x, y, z);
|
||||
if (block.getHarvestTool(meta) != null && block.getHarvestTool(meta).equals(this.getHarvestType()))
|
||||
hlvl = block.getHarvestLevel(meta);
|
||||
int toolLevel = tags.getInteger("HarvestLevel");
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z);
|
||||
|
||||
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (localBlock != null && !(localHardness < 0))
|
||||
{
|
||||
|
||||
boolean isEffective = false;
|
||||
|
||||
for (int iter = 0; iter < getEffectiveMaterials().length; iter++)
|
||||
{
|
||||
if (getEffectiveMaterials()[iter] == localBlock.getMaterial() || localBlock == Blocks.monster_egg)
|
||||
{
|
||||
isEffective = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (localBlock.getMaterial().isToolNotRequired())
|
||||
{
|
||||
isEffective = true;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (isEffective)
|
||||
{
|
||||
if (localBlock.removedByPlayer(world, player, x, y, z))
|
||||
{
|
||||
localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
|
||||
}
|
||||
localBlock.harvestBlock(world, player, x, y, z, localMeta);
|
||||
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localBlock, x, y, z, player);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHelper.setBlockToAir(world, x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
||||
{
|
||||
|
||||
@@ -606,14 +606,28 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem
|
||||
@Override
|
||||
public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
if (mod.beforeBlockBreak(this, stack, x, y, z, player))
|
||||
cancelHarvest = true;
|
||||
}
|
||||
World world = player.worldObj;
|
||||
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Lava") && world.isRemote)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
float f = (float) x + random.nextFloat();
|
||||
float f1 = (float) y + random.nextFloat();
|
||||
float f2 = (float) z + random.nextFloat();
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
return cancelHarvest;
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user