fixed fall detection

This commit is contained in:
Leijurv 2018-08-07 07:39:55 -07:00
parent b7eaf881a0
commit b5a6112bde
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 19 additions and 9 deletions

View File

@ -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;
}

View File

@ -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;
}