Move this to a helper method and add missing cases

This commit is contained in:
ZacSharp
2022-09-30 22:27:32 +02:00
parent 45c0b38156
commit c14be17e53
3 changed files with 22 additions and 3 deletions

View File

@@ -374,6 +374,26 @@ public interface MovementHelper extends ActionCosts, Helper {
&& ((Integer) state.getValue(BlockLiquid.LEVEL)) == 0;
}
/**
* If movements make us stand/walk on this block, will it have a top to walk on?
*/
static boolean mustBeSolidToWalkOn(CalculationContext context, int x, int y, int z, IBlockState state) {
Block block = state.getBlock();
if (block == Blocks.LADDER || block == Blocks.VINE) {
return false;
}
if (block instanceof BlockLiquid) {
if (context.assumeWalkOnWater) {
return false;
}
Block blockAbove = context.getBlock(x, y+1, z);
if (blockAbove instanceof BlockLiquid) {
return false;
}
}
return true;
}
static boolean canPlaceAgainst(BlockStateInterface bsi, int x, int y, int z) {
return canPlaceAgainst(bsi, x, y, z, bsi.get0(x, y, z));
}