Skip to content

Commit

Permalink
Fixed #332
Browse files Browse the repository at this point in the history
  • Loading branch information
DisasterMoo committed Aug 26, 2019
1 parent b08df80 commit 05e2a4b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Expand Up @@ -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();
}
Expand Down
Expand Up @@ -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)
Expand Down
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/net/dries007/tfc/util/IFallingBlock.java
Expand Up @@ -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;

Expand All @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 05e2a4b

Please sign in to comment.