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) {
|
static boolean canWalkThrough(BlockPos pos) {
|
||||||
IBlockState state = BlockStateInterface.get(pos);
|
IBlockState state = BlockStateInterface.get(pos);
|
||||||
|
return canWalkThrough(pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean canWalkThrough(BlockPos pos, IBlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof BlockLilyPad
|
if (block instanceof BlockLilyPad
|
||||||
|| block instanceof BlockFire
|
|| block instanceof BlockFire
|
||||||
@ -193,6 +197,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
return new MovementDescend(pos, destDown);
|
return new MovementDescend(pos, destDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println(dest + " descend distance!");
|
||||||
// we're clear for a fall 2
|
// we're clear for a fall 2
|
||||||
// let's see how far we can fall
|
// let's see how far we can fall
|
||||||
for (int fallHeight = 3; true; fallHeight++) {
|
for (int fallHeight = 3; true; fallHeight++) {
|
||||||
@ -200,14 +205,15 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (onto.getY() <= 0) {
|
if (onto.getY() <= 0) {
|
||||||
break;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.isWater(onto)) {
|
if (canWalkOn(onto, ontoBlock)) {
|
||||||
return new MovementFall(pos, onto);
|
return new MovementFall(pos, onto.up());
|
||||||
}
|
|
||||||
if (MovementHelper.canWalkOn(onto)) {
|
|
||||||
return new MovementFall(pos, onto);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -67,13 +67,13 @@ public class MovementFall extends Movement {
|
|||||||
case RUNNING:
|
case RUNNING:
|
||||||
BlockPos playerFeet = playerFeet();
|
BlockPos playerFeet = playerFeet();
|
||||||
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) {
|
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) {
|
||||||
if(!player().inventory.hasItemStack(new ItemStack(new ItemBucket(Blocks.WATER)))) {
|
if (!player().inventory.hasItemStack(new ItemStack(new ItemBucket(Blocks.WATER)))) {
|
||||||
state.setStatus(MovementStatus.UNREACHABLE);
|
state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
player().inventory.currentItem = player().inventory.getSlotFor(new ItemStack(new ItemBucket(Blocks.WATER)));
|
player().inventory.currentItem = player().inventory.getSlotFor(new ItemStack(new ItemBucket(Blocks.WATER)));
|
||||||
LookBehaviorUtils.reachable(dest).ifPresent(rotation ->
|
LookBehaviorUtils.reachable(dest).ifPresent(rotation ->
|
||||||
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
|
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
|
||||||
.setTarget(new MovementTarget(rotation))
|
.setTarget(new MovementTarget(rotation))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world()));
|
Rotation rotationToBlock = Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(dest, world()));
|
||||||
|
@ -70,6 +70,10 @@ public class BlockStateInterface {
|
|||||||
return BlockStateInterface.getBlock(pos).equals(Blocks.AIR);
|
return BlockStateInterface.getBlock(pos).equals(Blocks.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAir(IBlockState state) {
|
||||||
|
return state.getBlock().equals(Blocks.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
static boolean canFall(BlockPos pos) {
|
static boolean canFall(BlockPos pos) {
|
||||||
return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling;
|
return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user