Skip to content

Commit

Permalink
Fix broken tools AOE harvesting and harvesting stuff above stone level.
Browse files Browse the repository at this point in the history
Due to how forge/MC does things it's not possible to prevent stone-level from being harvested without extra events.
Closes #1775
  • Loading branch information
bonii-xx committed Oct 27, 2015
1 parent 75b97cf commit dad8ab9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/main/java/tconstruct/library/tools/AOEHarvestTool.java
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.util.MovingObjectPosition;

Expand All @@ -29,7 +30,12 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla
// only effective materials matter. We don't want to aoe when beraking dirt with a hammer.
Block block = player.worldObj.getBlock(x,y,z);
int meta = player.worldObj.getBlockMetadata(x,y,z);
if(block == null || !isEffective(block, meta))
if(block == null || !isEffective(block, meta) || !stack.hasTagCompound())
return super.onBlockStartBreak(stack, x,y,z, player);

// tool broken?
NBTTagCompound toolTags = stack.getTagCompound().getCompoundTag("InfiTool");
if(toolTags == null || toolTags.getBoolean("Broken"))
return super.onBlockStartBreak(stack, x,y,z, player);

MovingObjectPosition mop = AbilityHelper.raytraceFromEntity(player.worldObj, player, false, 4.5d);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/library/tools/HarvestTool.java
Expand Up @@ -58,7 +58,7 @@ public int getHarvestLevel(ItemStack stack, String toolClass) {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
// broken tools suck.
if (tags.getBoolean("Broken"))
return -1;
return 0;

// tadaaaa
return tags.getInteger("HarvestLevel");
Expand Down

0 comments on commit dad8ab9

Please sign in to comment.