Skip to content

Commit

Permalink
Ropes can now hang from fences and walls, allowing for "hanging" a ro…
Browse files Browse the repository at this point in the history
…pe over the edge of a cliff
  • Loading branch information
KnightMiner committed Jul 31, 2019
1 parent cbfb917 commit 8bcdcc7
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -62,15 +62,15 @@ protected BlockStateContainer createBlockState() {
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
BlockPos down = pos.down();
return state.withProperty(BOTTOM, !canConnectTo(world.getBlockState(down), world, down));
return state.withProperty(BOTTOM, !canConnectTo(world.getBlockState(down), world, down, EnumFacing.UP));
}

private boolean canConnectTo(IBlockState state, IBlockAccess world, BlockPos pos) {
private boolean canConnectTo(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
if(state.getBlock() == this) {
return true;
}

BlockFaceShape shape = state.getBlockFaceShape(world, pos, EnumFacing.UP);
BlockFaceShape shape = state.getBlockFaceShape(world, pos, side);
return shape == BlockFaceShape.CENTER || shape == BlockFaceShape.CENTER_BIG || shape == BlockFaceShape.SOLID;
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public boolean canPlaceBlockAt(World world, BlockPos pos) {
private boolean isValidRope(World world, BlockPos pos) {
BlockPos up = pos.up();
IBlockState state = world.getBlockState(up);
return state.isSideSolid(world, up, EnumFacing.DOWN) || state.getBlock() == this;
return canConnectTo(state, world, pos, EnumFacing.DOWN);
}

/**
Expand Down

0 comments on commit 8bcdcc7

Please sign in to comment.