Skip to content

Commit

Permalink
Merge pull request #477 from Glassmaker/patch-3
Browse files Browse the repository at this point in the history
Patch 3
  • Loading branch information
progwml6 committed Feb 15, 2014
2 parents 040d051 + da752a3 commit f6b6564
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main/java/tconstruct/items/tools/Hammer.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPl
Block localBlock = world.getBlock(xPos, yPos, zPos);
int localMeta = world.getBlockMetadata(xPos, yPos, zPos);
int hlvl = -1;
if (block.getHarvestTool(meta) != null && block.getHarvestTool(meta).equals(this.getHarvestType()))
hlvl = block.getHarvestLevel(meta);
if (localBlock.getHarvestTool(localMeta) != null && localBlock.getHarvestTool(localMeta).equals(this.getHarvestType()))
hlvl = localBlock.getHarvestLevel(localMeta);
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, xPos, yPos, zPos);

if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
Expand Down
51 changes: 35 additions & 16 deletions src/main/java/tconstruct/library/tools/HarvestTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import tconstruct.TConstruct;
import tconstruct.library.ActiveToolMod;
import tconstruct.library.TConstructRegistry;

Expand Down Expand Up @@ -58,28 +57,48 @@ public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPl
{
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)
{
if (!player.capabilities.isCreativeMode)
{
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
isEffective = true;
break;
}
}

if (localBlock.getMaterial().isToolNotRequired())
{
isEffective = true;
}

if (!player.capabilities.isCreativeMode)
{
if (isEffective)
{
if (localBlock.removedByPlayer(world, player, x, y, z))
{
WorldHelper.setBlockToAir(world, x, y, z);
world.func_147479_m(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);
}
}
}
Expand Down

0 comments on commit f6b6564

Please sign in to comment.