Add forceRotations field to MovementState
Preparation for silent moving
This commit is contained in:
parent
c5c26b73d8
commit
843bc17777
@ -131,7 +131,7 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos);
|
Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos);
|
||||||
if (reachable.isPresent()) {
|
if (reachable.isPresent()) {
|
||||||
player().inventory.currentItem = new ToolSet().getBestSlot(BlockStateInterface.get(blockPos));
|
player().inventory.currentItem = new ToolSet().getBestSlot(BlockStateInterface.get(blockPos));
|
||||||
state.setTarget(new MovementState.MovementTarget(reachable.get())).setInput(Input.CLICK_LEFT, true);
|
state.setTarget(new MovementState.MovementTarget(reachable.get(), true)).setInput(Input.CLICK_LEFT, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//get rekt minecraft
|
//get rekt minecraft
|
||||||
@ -139,7 +139,7 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
//i dont care if theres snow in the way!!!!!!!
|
//i dont care if theres snow in the way!!!!!!!
|
||||||
//you dont own me!!!!
|
//you dont own me!!!!
|
||||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||||
Utils.getBlockPosCenter(blockPos)))
|
Utils.getBlockPosCenter(blockPos)), true)
|
||||||
).setInput(InputOverrideHandler.Input.CLICK_LEFT, true);
|
).setInput(InputOverrideHandler.Input.CLICK_LEFT, true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -255,10 +255,12 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void moveTowards(MovementState state, BlockPos pos) {
|
static void moveTowards(MovementState state, BlockPos pos) {
|
||||||
state.setTarget(new MovementTarget(new Rotation(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
state.setTarget(new MovementTarget(
|
||||||
|
new Rotation(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||||
Utils.getBlockPosCenter(pos),
|
Utils.getBlockPosCenter(pos),
|
||||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getFirst(), mc.player.rotationPitch))
|
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getFirst(), mc.player.rotationPitch),
|
||||||
).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
false
|
||||||
|
)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Movement generateMovementFallOrDescend(BlockPos pos, BlockPos dest, CalculationContext calcContext) {
|
static Movement generateMovementFallOrDescend(BlockPos pos, BlockPos dest, CalculationContext calcContext) {
|
||||||
|
@ -93,21 +93,29 @@ public class MovementState {
|
|||||||
*/
|
*/
|
||||||
public Rotation rotation;
|
public Rotation rotation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not this target must force rotations.
|
||||||
|
* <p>
|
||||||
|
* {@code true} if we're trying to place or break blocks, {@code false} if we're trying to look at the movement location
|
||||||
|
*/
|
||||||
|
private boolean forceRotations;
|
||||||
|
|
||||||
public MovementTarget() {
|
public MovementTarget() {
|
||||||
this(null, null);
|
this(null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MovementTarget(Vec3d position) {
|
public MovementTarget(Vec3d position) {
|
||||||
this(position, null);
|
this(position, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MovementTarget(Rotation rotation) {
|
public MovementTarget(Rotation rotation, boolean forceRotations) {
|
||||||
this(null, rotation);
|
this(null, rotation, forceRotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MovementTarget(Vec3d position, Rotation rotation) {
|
public MovementTarget(Vec3d position, Rotation rotation, boolean forceRotations) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
|
this.forceRotations = forceRotations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Optional<Vec3d> getPosition() {
|
public final Optional<Vec3d> getPosition() {
|
||||||
@ -117,5 +125,9 @@ public class MovementState {
|
|||||||
public final Optional<Rotation> getRotation() {
|
public final Optional<Rotation> getRotation() {
|
||||||
return Optional.ofNullable(this.rotation);
|
return Optional.ofNullable(this.rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasToForceRotations() {
|
||||||
|
return this.forceRotations;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class MovementAscend extends Movement {
|
|||||||
double faceX = (dest.getX() + anAgainst.getX() + 1.0D) * 0.5D;
|
double faceX = (dest.getX() + anAgainst.getX() + 1.0D) * 0.5D;
|
||||||
double faceY = (dest.getY() + anAgainst.getY()) * 0.5D;
|
double faceY = (dest.getY() + anAgainst.getY()) * 0.5D;
|
||||||
double faceZ = (dest.getZ() + anAgainst.getZ() + 1.0D) * 0.5D;
|
double faceZ = (dest.getZ() + anAgainst.getZ() + 1.0D) * 0.5D;
|
||||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations())));
|
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations()), true));
|
||||||
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
||||||
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), anAgainst) && LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) {
|
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), anAgainst) && LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionsToPlace[0])) {
|
||||||
ticksWithoutPlacement++;
|
ticksWithoutPlacement++;
|
||||||
|
@ -101,9 +101,9 @@ public class MovementFall extends Movement {
|
|||||||
}
|
}
|
||||||
if (targetRotation.isPresent()) {
|
if (targetRotation.isPresent()) {
|
||||||
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
|
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
|
||||||
.setTarget(new MovementTarget(targetRotation.get()));
|
.setTarget(new MovementTarget(targetRotation.get(), true));
|
||||||
} else {
|
} else {
|
||||||
state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest))));
|
state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest)), true));
|
||||||
}
|
}
|
||||||
if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 // lilypads
|
if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.094 // lilypads
|
||||||
|| BlockStateInterface.isWater(dest))) {
|
|| BlockStateInterface.isWater(dest))) {
|
||||||
|
@ -115,7 +115,7 @@ public class MovementPillar extends Movement {
|
|||||||
if (!ladder) {
|
if (!ladder) {
|
||||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
||||||
Utils.getBlockPosCenter(positionsToPlace[0]),
|
Utils.getBlockPosCenter(positionsToPlace[0]),
|
||||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch))));
|
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)), true));
|
||||||
}
|
}
|
||||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||||
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
||||||
|
@ -148,7 +148,7 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
if (isDoorActuallyBlockingUs) {
|
if (isDoorActuallyBlockingUs) {
|
||||||
if (!(Blocks.IRON_DOOR.equals(srcBlock) || Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
if (!(Blocks.IRON_DOOR.equals(srcBlock) || Blocks.IRON_DOOR.equals(pb0.getBlock()) || Blocks.IRON_DOOR.equals(pb1.getBlock()))) {
|
||||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world()))));
|
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.calcCenterFromCoords(positionsToBreak[0], world())), true));
|
||||||
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
|
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ public class MovementTraverse extends Movement {
|
|||||||
double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D;
|
double faceX = (dest.getX() + against1.getX() + 1.0D) * 0.5D;
|
||||||
double faceY = (dest.getY() + against1.getY()) * 0.5D;
|
double faceY = (dest.getY() + against1.getY()) * 0.5D;
|
||||||
double faceZ = (dest.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
double faceZ = (dest.getZ() + against1.getZ() + 1.0D) * 0.5D;
|
||||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations())));
|
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations()), true));
|
||||||
|
|
||||||
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
EnumFacing side = Minecraft.getMinecraft().objectMouseOver.sideHit;
|
||||||
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against1) && Minecraft.getMinecraft().player.isSneaking()) {
|
if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against1) && Minecraft.getMinecraft().player.isSneaking()) {
|
||||||
@ -217,7 +217,7 @@ public class MovementTraverse extends Movement {
|
|||||||
double faceZ = (dest.getZ() + src.getZ() + 1.0D) * 0.5D;
|
double faceZ = (dest.getZ() + src.getZ() + 1.0D) * 0.5D;
|
||||||
// faceX, faceY, faceZ is the middle of the face between from and to
|
// faceX, faceY, faceZ is the middle of the face between from and to
|
||||||
BlockPos goalLook = src.down(); // this is the block we were just standing on, and the one we want to place against
|
BlockPos goalLook = src.down(); // this is the block we were just standing on, and the one we want to place against
|
||||||
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations())));
|
state.setTarget(new MovementState.MovementTarget(Utils.calcRotationFromVec3d(playerHead(), new Vec3d(faceX, faceY, faceZ), playerRotations()), true));
|
||||||
|
|
||||||
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);
|
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);
|
||||||
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
state.setInput(InputOverrideHandler.Input.SNEAK, true);
|
||||||
|
@ -164,7 +164,7 @@ public class ToolSet implements Helper {
|
|||||||
event.setSlot(this.overrideSlot);
|
event.setSlot(this.overrideSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setOverrideSlot(int overrideSlot) {
|
final void setOverrideSlot(int overrideSlot) {
|
||||||
this.overrideSlot = overrideSlot;
|
this.overrideSlot = overrideSlot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user