Add magma block functionality to MovementParkour.
This commit is contained in:
@@ -191,7 +191,7 @@ public class MovementAscend extends Movement {
|
||||
}
|
||||
MovementHelper.moveTowards(ctx, state, dest);
|
||||
|
||||
state.setInput(Input.SNEAK, jumpingOnto.getBlock() == Blocks.MAGMA_BLOCK);
|
||||
state.setInput(Input.SNEAK, jumpingOnto.getBlock().equals(Blocks.MAGMA_BLOCK));
|
||||
|
||||
if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.below()))) {
|
||||
return state; // don't jump while walking from a non double slab into a bottom slab
|
||||
|
||||
@@ -256,7 +256,7 @@ public class MovementDescend extends Movement {
|
||||
double z = ctx.player().position().z - (src.getZ() + 0.5);
|
||||
double fromStart = Math.sqrt(x * x + z * z);
|
||||
|
||||
state.setInput(Input.SNEAK, BlockStateInterface.get(ctx, ctx.player().blockPosition().below()).getBlock() == Blocks.MAGMA_BLOCK);
|
||||
state.setInput(Input.SNEAK, BlockStateInterface.get(ctx, ctx.player().blockPosition().below()).getBlock().equals(Blocks.MAGMA_BLOCK));
|
||||
|
||||
if (!playerFeet.equals(dest) || ab > 0.25) {
|
||||
if (numTicks++ < 20 && fromStart < 1.25) {
|
||||
|
||||
@@ -276,7 +276,7 @@ public class MovementDiagonal extends Movement {
|
||||
if (sprint()) {
|
||||
state.setInput(Input.SPRINT, true);
|
||||
}
|
||||
state.setInput(Input.SNEAK, MovementHelper.steppingOnBlocks(ctx).stream().anyMatch(block -> BlockStateInterface.get(ctx, block).getBlock() == Blocks.MAGMA_BLOCK));
|
||||
state.setInput(Input.SNEAK, MovementHelper.steppingOnBlocks(ctx).stream().anyMatch(block -> BlockStateInterface.get(ctx, block).getBlock().equals(Blocks.MAGMA_BLOCK)));
|
||||
MovementHelper.moveTowards(ctx, state, dest);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MovementFall extends Movement {
|
||||
BlockState destState = ctx.world().getBlockState(dest);
|
||||
Block destBlock = destState.getBlock();
|
||||
|
||||
if (ctx.world().getBlockState(dest.below()).getBlock() == Blocks.MAGMA_BLOCK && MovementHelper.steppingOnBlocks(ctx).stream().allMatch(block -> BlockStateInterface.get(ctx, block).getBlock() instanceof AirBlock)) {
|
||||
if (BlockStateInterface.get(ctx, dest.below()).getBlock().equals(Blocks.MAGMA_BLOCK) && MovementHelper.steppingOnBlocks(ctx).stream().allMatch(block -> BlockStateInterface.get(ctx, block).getBlock() instanceof AirBlock)) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,14 +103,16 @@ public class MovementParkour extends Movement {
|
||||
return; // can't jump out of water
|
||||
}
|
||||
int maxJump;
|
||||
if (standingOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
if (standingOn.getBlock() == Blocks.MAGMA_BLOCK) {
|
||||
maxJump = 2;
|
||||
}
|
||||
else if (standingOn.getBlock() == Blocks.SOUL_SAND) {
|
||||
maxJump = 2; // 1 block gap
|
||||
} else {
|
||||
if (context.canSprint) {
|
||||
maxJump = 4;
|
||||
} else {
|
||||
maxJump = 3;
|
||||
}
|
||||
} else if (context.canSprint) {
|
||||
maxJump = 4;
|
||||
}
|
||||
else {
|
||||
maxJump = 3;
|
||||
}
|
||||
|
||||
// check parkour jumps from smallest to largest for obstacles/walls and landing positions
|
||||
@@ -263,6 +265,11 @@ public class MovementParkour extends Movement {
|
||||
if (dist >= 4 || ascend) {
|
||||
state.setInput(Input.SPRINT, true);
|
||||
}
|
||||
|
||||
if (BlockStateInterface.get(ctx, ctx.playerFeet().below()).getBlock().equals(Blocks.MAGMA_BLOCK)) {
|
||||
state.setInput(Input.SNEAK, true);
|
||||
}
|
||||
|
||||
MovementHelper.moveTowards(ctx, state, dest);
|
||||
if (ctx.playerFeet().equals(dest)) {
|
||||
Block d = BlockStateInterface.getBlock(ctx, dest);
|
||||
|
||||
@@ -221,7 +221,7 @@ public class MovementTraverse extends Movement {
|
||||
boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE;
|
||||
|
||||
//sneak may have been set to true in the PREPPING state while mining an adjacent block, but we still want it to be true if the player is about to go on magma
|
||||
state.setInput(Input.SNEAK, MovementHelper.steppingOnBlocks(ctx).stream().anyMatch(block -> BlockStateInterface.get(ctx, block).getBlock() == Blocks.MAGMA_BLOCK));
|
||||
state.setInput(Input.SNEAK, MovementHelper.steppingOnBlocks(ctx).stream().anyMatch(block -> BlockStateInterface.get(ctx, block).getBlock().equals(Blocks.MAGMA_BLOCK)));
|
||||
|
||||
if (pb0.getBlock() instanceof DoorBlock || pb1.getBlock() instanceof DoorBlock) {
|
||||
boolean notPassable = pb0.getBlock() instanceof DoorBlock && !MovementHelper.isDoorPassable(ctx, src, dest) || pb1.getBlock() instanceof DoorBlock && !MovementHelper.isDoorPassable(ctx, dest, src);
|
||||
|
||||
Reference in New Issue
Block a user