mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 16:38:33 +01:00
Closes #1239
This commit is contained in:
parent
785dccbed8
commit
66718437d9
4 changed files with 6 additions and 4 deletions
|
@ -85,7 +85,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
|
|||
if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof BlockLiquid) && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getBlockHardness(this.world, breakCoords) >= 0.0F) {
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
blockToBreak.getDrops(drops, this.world, breakCoords, stateToBreak, 0);
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, breakCoords);
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, breakCoords);
|
||||
|
||||
if (chance > 0 && this.world.rand.nextFloat() <= chance) {
|
||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase {
|
|||
if (blockToBreak != null && !this.world.isAirBlock(coordsBlock) && this.world.getBlockState(coordsBlock).getBlockHardness(this.world, coordsBlock) > -1.0F) {
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
blockToBreak.getDrops(drops, this.world, coordsBlock, breakState, 0);
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, coordsBlock);
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, coordsBlock);
|
||||
|
||||
if (chance > 0 && this.world.rand.nextFloat() <= chance) {
|
||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||
|
|
|
@ -131,7 +131,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR
|
|||
if (block.getHarvestLevel(this.world.getBlockState(pos)) <= ItemDrill.HARVEST_LEVEL && state.getBlockHardness(this.world, pos) >= 0F && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock) && this.isMinable(block, stack)) {
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
block.getDrops(drops, this.world, pos, state, 0);
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, pos);
|
||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, pos);
|
||||
|
||||
if (chance > 0 && this.world.rand.nextFloat() <= chance) {
|
||||
if (StackUtil.canAddAll(this.inv, drops, false)) {
|
||||
|
|
|
@ -282,9 +282,11 @@ public final class WorldUtil {
|
|||
}
|
||||
|
||||
//I think something is up with this, but I'm not entirely certain what.
|
||||
public static float fireFakeHarvestEventsForDropChance(NonNullList<ItemStack> drops, World world, BlockPos pos) {
|
||||
public static float fireFakeHarvestEventsForDropChance(TileEntity caller, NonNullList<ItemStack> drops, World world, BlockPos pos) {
|
||||
if (world instanceof WorldServer) {
|
||||
FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer) world);
|
||||
BlockPos tePos = caller.getPos();
|
||||
fake.setPosition(tePos.getX() + 0.5, tePos.getY() + 0.5, tePos.getZ() + 0.5);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
BreakEvent event = new BreakEvent(world, pos, state, fake);
|
||||
|
|
Loading…
Reference in a new issue