New hook to allow Trapdoors be climbable for custom ladders (#7816)

This commit is contained in:
cech12 authored and GitHub committed 2021-07-16 18:01:27 -07:00
1 parent 5169f1f6fe
commit 043e49a694
2 files changed
+17 -3

No files matched your search

@@ -9,9 +9,9 @@
+ @Override
+ public boolean isLadder(BlockState state, net.minecraft.world.IWorldReader world, BlockPos pos, net.minecraft.entity.LivingEntity entity) {
+ if (state.func_177229_b(field_176283_b)) {
+ BlockState down = world.func_180495_p(pos.func_177977_b());
+ if (down.func_203425_a(net.minecraft.block.Blocks.field_150468_ap))
+ return down.func_177229_b(LadderBlock.field_176382_a) == state.func_177229_b(field_185512_D);
+ BlockPos downPos = pos.func_177977_b();
+ BlockState down = world.func_180495_p(downPos);
+ return down.func_177230_c().makesOpenTrapdoorAboveClimbable(down, world, downPos, state);
+ }
+ return false;
+ }
@@ -116,6 +116,20 @@ public interface IForgeBlock
return state.getBlock().is(BlockTags.CLIMBABLE);
}
/**
* Checks if this block makes an open trapdoor above it climbable.
*
* @param state The current state
* @param world The current world
* @param pos Block position in world
* @param trapdoorState The current state of the open trapdoor above
* @return True if the block should act like a ladder
*/
default boolean makesOpenTrapdoorAboveClimbable(BlockState state, IWorldReader world, BlockPos pos, BlockState trapdoorState)
{
return state.getBlock() instanceof LadderBlock && state.getValue(LadderBlock.FACING) == trapdoorState.getValue(TrapDoorBlock.FACING);
}
/**
* Determines if this block should set fire and deal fire damage
* to entities coming into contact with it.