fixed fall detection
This commit is contained in:
parent
b7eaf881a0
commit
b5a6112bde
@ -56,6 +56,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
*/
|
||||
static boolean canWalkThrough(BlockPos pos) {
|
||||
IBlockState state = BlockStateInterface.get(pos);
|
||||
return canWalkThrough(pos, state);
|
||||
}
|
||||
|
||||
static boolean canWalkThrough(BlockPos pos, IBlockState state) {
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BlockLilyPad
|
||||
|| block instanceof BlockFire
|
||||
@ -193,6 +197,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return new MovementDescend(pos, destDown);
|
||||
}
|
||||
}
|
||||
System.out.println(dest + " descend distance!");
|
||||
// we're clear for a fall 2
|
||||
// let's see how far we can fall
|
||||
for (int fallHeight = 3; true; fallHeight++) {
|
||||
@ -200,14 +205,15 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (onto.getY() <= 0) {
|
||||
break;
|
||||
}
|
||||
if (BlockStateInterface.isAir(onto)) {
|
||||
IBlockState ontoBlock = BlockStateInterface.get(onto);
|
||||
if (BlockStateInterface.isWater(ontoBlock.getBlock())) {
|
||||
return new MovementFall(pos, onto);
|
||||
}
|
||||
if (canWalkThrough(onto, ontoBlock)) {
|
||||
continue;
|
||||
}
|
||||
if (BlockStateInterface.isWater(onto)) {
|
||||
return new MovementFall(pos, onto);
|
||||
}
|
||||
if (MovementHelper.canWalkOn(onto)) {
|
||||
return new MovementFall(pos, onto);
|
||||
if (canWalkOn(onto, ontoBlock)) {
|
||||
return new MovementFall(pos, onto.up());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -70,6 +70,10 @@ public class BlockStateInterface {
|
||||
return BlockStateInterface.getBlock(pos).equals(Blocks.AIR);
|
||||
}
|
||||
|
||||
public static boolean isAir(IBlockState state) {
|
||||
return state.getBlock().equals(Blocks.AIR);
|
||||
}
|
||||
|
||||
static boolean canFall(BlockPos pos) {
|
||||
return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user