mirror of https://github.com/cabaletta/baritone
swimming
This commit is contained in:
parent
7bb311687b
commit
c00d43c462
|
@ -27,12 +27,13 @@ import net.minecraft.network.chat.Component;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -730,6 +731,11 @@ public final class Settings {
|
|||
*/
|
||||
public final Setting<Boolean> sprintInWater = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* Attempt to enter the underwater swimming state
|
||||
*/
|
||||
public final Setting<Boolean> swimInWater = new Setting<>(true);
|
||||
|
||||
/**
|
||||
* When GetToBlockProcess or MineProcess fails to calculate a path, instead of just giving up, mark the closest instance
|
||||
* of that block as "unreachable" and go towards the next closest. GetToBlock expands this search to the whole "vein"; MineProcess does not.
|
||||
|
|
|
@ -24,13 +24,15 @@ import baritone.api.pathing.movement.MovementStatus;
|
|||
import baritone.api.utils.*;
|
||||
import baritone.api.utils.input.Input;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.pathing.movement.movements.MovementTraverse;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import java.util.*;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class Movement implements IMovement, MovementHelper {
|
||||
|
||||
public static final Direction[] HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP = {Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST, Direction.DOWN};
|
||||
|
@ -123,7 +125,7 @@ public abstract class Movement implements IMovement, MovementHelper {
|
|||
public MovementStatus update() {
|
||||
ctx.player().getAbilities().flying = false;
|
||||
currentState = updateState(currentState);
|
||||
if (MovementHelper.isLiquid(ctx, ctx.playerFeet()) && ctx.player().position().y < dest.y + 0.6) {
|
||||
if ((MovementHelper.isLiquid(ctx, ctx.playerFeet()) && ctx.player().position().y < dest.y + 0.6) && !(Baritone.settings().swimInWater.value && this instanceof MovementTraverse)) {
|
||||
currentState.setInput(Input.JUMP, true);
|
||||
}
|
||||
if (ctx.player().isInWall()) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import baritone.Baritone;
|
|||
import baritone.api.IBaritone;
|
||||
import baritone.api.pathing.movement.MovementStatus;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.Movement;
|
||||
|
@ -29,9 +30,6 @@ import baritone.pathing.movement.MovementState;
|
|||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.pathing.MutableMoveResult;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -39,6 +37,10 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MovementDiagonal extends Movement {
|
||||
|
||||
private static final double SQRT_2 = Math.sqrt(2);
|
||||
|
@ -271,6 +273,10 @@ public class MovementDiagonal extends Movement {
|
|||
state.setInput(Input.SPRINT, true);
|
||||
}
|
||||
MovementHelper.moveTowards(ctx, state, dest);
|
||||
if (ctx.player().isSwimming() && Baritone.settings().swimInWater.value) {
|
||||
state.setInput(Input.SPRINT, true);
|
||||
state.setTarget(new MovementState.MovementTarget(new Rotation(state.getTarget().getRotation().get().getYaw(), -30), true));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,7 @@ import baritone.pathing.movement.MovementState;
|
|||
import baritone.utils.BlockStateInterface;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CarpetBlock;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.FenceGateBlock;
|
||||
import net.minecraft.world.level.block.LadderBlock;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -240,10 +233,16 @@ public class MovementTraverse extends Movement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean swim = Baritone.settings().swimInWater.value &&
|
||||
MovementHelper.isLiquid(ctx, src) &&
|
||||
MovementHelper.isLiquid(ctx, dest) &&
|
||||
(ctx.player().isSwimming() || (ctx.world().getBlockState(dest.below()).equals(pb1) &&
|
||||
ctx.world().getBlockState(src.below()).equals(pb1))) &&
|
||||
ctx.playerFeetAsVec().y >= src.y - 1;
|
||||
boolean isTheBridgeBlockThere = MovementHelper.canWalkOn(ctx, positionToPlace) || ladder || MovementHelper.canUseFrostWalker(ctx, positionToPlace);
|
||||
BlockPos feet = ctx.playerFeet();
|
||||
if (feet.getY() != dest.getY() && !ladder) {
|
||||
state.setInput(Input.JUMP, false);
|
||||
if (feet.getY() != dest.getY() && !ladder && !swim) {
|
||||
logDebug("Wrong Y coordinate");
|
||||
if (feet.getY() < dest.getY()) {
|
||||
System.out.println("In movement traverse");
|
||||
|
@ -283,6 +282,9 @@ public class MovementTraverse extends Movement {
|
|||
}
|
||||
}
|
||||
MovementHelper.moveTowards(ctx, state, against);
|
||||
if (swim) {
|
||||
state.setTarget(new MovementState.MovementTarget(new Rotation(state.getTarget().getRotation().get().getYaw(), -30), true));
|
||||
}
|
||||
return state;
|
||||
} else {
|
||||
wasTheBridgeBlockAlwaysThere = false;
|
||||
|
|
Loading…
Reference in New Issue