Skip to content
Permalink
Browse files

Fixed #332

  • Loading branch information
DisasterMoo committed Aug 26, 2019
1 parent b08df80 commit 05e2a4b4d388a82d441de75b97937ae1d308b86c
@@ -82,7 +82,7 @@ public boolean checkFalling(World worldIn, BlockPos pos, IBlockState state)
{
worldIn.setBlockToAir(pos);
pos1 = pos1.down();
while (canFallThrough(worldIn.getBlockState(pos1)) && pos1.getY() > 0)
while (canFallThrough(worldIn, pos1) && pos1.getY() > 0)
{
pos1 = pos1.down();
}
@@ -98,7 +98,7 @@ public BlockPos getFallablePos(World world, BlockPos pos)

// Check if it can fall
faces = Arrays.stream(EnumFacing.HORIZONTALS)
.filter(x -> shouldFall(world, pos.offset(x), pos) && canFallThrough(world.getBlockState(pos.offset(x))))
.filter(x -> shouldFall(world, pos.offset(x), pos) && canFallThrough(world, pos.offset(x)))
.toArray(EnumFacing[]::new);

if (faces.length >= 1)
@@ -145,7 +145,7 @@ else if (!world.isRemote)
setDead();

//world.mayPlace(block, pos, true, EnumFacing.UP, null) &&
if (!falling.canFallThrough(world.getBlockState(pos.down())))
if (!falling.canFallThrough(world, pos.down()))
{
world.destroyBlock(pos, true);
world.setBlockState(pos, state, 3);
@@ -12,6 +12,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

@@ -20,15 +21,16 @@

public interface IFallingBlock
{
default boolean canFallThrough(IBlockState state)
default boolean canFallThrough(World world, BlockPos pos)
{
return state.getMaterial().isReplaceable();
if (!world.isSideSolid(pos, EnumFacing.UP)) return true;
return world.getBlockState(pos).getMaterial().isReplaceable();
}

default boolean shouldFall(World world, BlockPos posToFallAt, BlockPos originalPos)
{
// Can the block fall at a particular position; ignore horizontal falling
return canFallThrough(world.getBlockState(posToFallAt.down())) && !BlockSupport.isBeingSupported(world, originalPos);
return canFallThrough(world, posToFallAt.down()) && !BlockSupport.isBeingSupported(world, originalPos);
}

// Get the position that the block will fall from (allows for horizontal falling)
@@ -61,7 +63,7 @@ default boolean checkFalling(World worldIn, BlockPos pos, IBlockState state)
{
worldIn.setBlockToAir(pos);
pos1 = pos1.down();
while (canFallThrough(worldIn.getBlockState(pos1)) && pos1.getY() > 0)
while (canFallThrough(worldIn, pos1) && pos1.getY() > 0)
{
pos1 = pos1.down();
}

0 comments on commit 05e2a4b

Please sign in to comment.
You can’t perform that action at this time.