From f5ae3240f8dab0b34161754d9e36dd82b88ed693 Mon Sep 17 00:00:00 2001 From: Shadows_of_Fire Date: Wed, 31 Jan 2018 00:07:29 -0500 Subject: [PATCH] Fixes #1018 --- .../mod/items/ItemDrill.java | 3 +- .../actuallyadditions/mod/util/WorldUtil.java | 33 ------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 04595b780..618bfc9cd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -53,6 +53,7 @@ import net.minecraft.util.EnumFacing.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -465,7 +466,7 @@ public class ItemDrill extends ItemEnergy{ IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); float hardness = state.getBlockHardness(world, pos); - boolean canHarvest = WorldUtil.canBreakExtraBlock(stack, world, player, pos); + boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F); if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(world.getBlockState(pos))))){ if(!player.capabilities.isCreativeMode){ this.extractEnergyInternal(stack, use, false); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index 24f2434ea..3d2368c98 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -370,39 +370,6 @@ public final class WorldUtil { } //Stolen from TiC - - /** - * Returns true if the tool is effective for harvesting the given block. - */ - public static boolean isToolEffective(ItemStack stack, IBlockState state) { - // check material - for (String type : stack.getItem().getToolClasses(stack)) { - if (state.getBlock().isToolEffective(type, state)) { return true; } - } - - return false; - } - - public static boolean canBreakExtraBlock(ItemStack stack, World world, EntityPlayer player, BlockPos pos) { - // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events - if (world.isAirBlock(pos)) { return false; } - - // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian - // or precious ores you can't harvest while mining stone - IBlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - - // only effective materials - if (!isToolEffective(stack, state)) { return false; } - - // only harvestable blocks that aren't impossibly slow to harvest - if (!ForgeHooks.canHarvestBlock(block, player, world, pos)) { return false; } - - // From this point on it's clear that the player CAN break the block - - return true; - } - public static boolean breakExtraBlock(ItemStack stack, World world, EntityPlayer player, BlockPos pos) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock();