mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fixes #1018
This commit is contained in:
parent
335f0fc37e
commit
f5ae3240f8
2 changed files with 2 additions and 34 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue