diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMine.java b/src/main/java/vazkii/botania/common/item/lens/LensMine.java index 304fa5b9f..e3f5d67f9 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMine.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMine.java @@ -33,14 +33,15 @@ import java.util.List; public class LensMine extends Lens { @Override - public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { + public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult rtr, boolean isManaBlock, boolean dead, ItemStack stack) { World world = entity.world; - BlockPos pos_ = pos.getBlockPos(); - if (world.isRemote || pos_ == null) + BlockPos collidePos = rtr.getBlockPos(); + if (world.isRemote || collidePos == null) return false; - Block block = world.getBlockState(pos_).getBlock(); + IBlockState state = world.getBlockState(collidePos); + Block block = state.getBlock(); ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack); boolean warp = composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP; @@ -50,32 +51,31 @@ public class LensMine extends Lens { int harvestLevel = ConfigHandler.harvestLevelBore; - TileEntity tile = world.getTileEntity(pos_); + TileEntity tile = world.getTileEntity(collidePos); - IBlockState state = world.getBlockState(pos_); - float hardness = state.getBlockHardness(world, pos_); + float hardness = state.getBlockHardness(world, collidePos); int neededHarvestLevel = block.getHarvestLevel(state); int mana = burst.getMana(); - BlockPos coords = burst.getBurstSourceBlockPos(); - if(!coords.equals(pos.getBlockPos()) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) { - NonNullList items = NonNullList.create(); - block.getDrops(items, world, pos_, world.getBlockState(pos_), 0); + BlockPos source = burst.getBurstSourceBlockPos(); + if(!source.equals(rtr.getBlockPos()) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) { + if(!burst.hasAlreadyCollidedAt(collidePos)) { + if(!burst.isFake()) { + NonNullList items = NonNullList.create(); + block.getDrops(items, world, collidePos, world.getBlockState(collidePos), 0); + float chance = net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, world, collidePos, state, 0, 1.0f, false, null); - if(!burst.hasAlreadyCollidedAt(pos_)) { - if(!burst.isFake() && !entity.world.isRemote) { - world.setBlockToAir(pos_); + world.setBlockToAir(collidePos); if(ConfigHandler.blockBreakParticles) - entity.world.playEvent(2001, pos_, Block.getStateId(state)); + world.playEvent(2001, collidePos, Block.getStateId(state)); - boolean offBounds = coords.getY() < 0; + boolean offBounds = source.getY() < 0; boolean doWarp = warp && !offBounds; - int dropX = doWarp ? coords.getX() : pos_.getX(); - int dropY = doWarp ? coords.getY() : pos_.getY(); - int dropZ = doWarp ? coords.getZ() : pos_.getZ(); + BlockPos dropCoord = doWarp ? source : collidePos; for(ItemStack stack_ : items) - world.spawnEntity(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_)); + if(world.rand.nextFloat() <= chance) + Block.spawnAsEntity(world, dropCoord, stack_); burst.setMana(mana - 24); }