fix yet more player references
This commit is contained in:
parent
dd08b2c825
commit
1a1686b7c3
@ -86,7 +86,7 @@ public class Rotation {
|
|||||||
public Rotation clamp() {
|
public Rotation clamp() {
|
||||||
return new Rotation(
|
return new Rotation(
|
||||||
this.yaw,
|
this.yaw,
|
||||||
RotationUtils.clampPitch(this.pitch)
|
clampPitch(this.pitch)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public class Rotation {
|
|||||||
*/
|
*/
|
||||||
public Rotation normalize() {
|
public Rotation normalize() {
|
||||||
return new Rotation(
|
return new Rotation(
|
||||||
RotationUtils.normalizeYaw(this.yaw),
|
normalizeYaw(this.yaw),
|
||||||
this.pitch
|
this.pitch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -105,8 +105,35 @@ public class Rotation {
|
|||||||
*/
|
*/
|
||||||
public Rotation normalizeAndClamp() {
|
public Rotation normalizeAndClamp() {
|
||||||
return new Rotation(
|
return new Rotation(
|
||||||
RotationUtils.normalizeYaw(this.yaw),
|
normalizeYaw(this.yaw),
|
||||||
RotationUtils.clampPitch(this.pitch)
|
clampPitch(this.pitch)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamps the specified pitch value between -90 and 90.
|
||||||
|
*
|
||||||
|
* @param pitch The input pitch
|
||||||
|
* @return The clamped pitch
|
||||||
|
*/
|
||||||
|
public static float clampPitch(float pitch) {
|
||||||
|
return Math.max(-90, Math.min(90, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes the specified yaw value between -180 and 180.
|
||||||
|
*
|
||||||
|
* @param yaw The input yaw
|
||||||
|
* @return The normalized yaw
|
||||||
|
*/
|
||||||
|
public static float normalizeYaw(float yaw) {
|
||||||
|
float newYaw = yaw % 360F;
|
||||||
|
if (newYaw < -180F) {
|
||||||
|
newYaw += 360F;
|
||||||
|
}
|
||||||
|
if (newYaw >= 180F) {
|
||||||
|
newYaw -= 360F;
|
||||||
|
}
|
||||||
|
return newYaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,7 @@ import baritone.Baritone;
|
|||||||
import baritone.api.pathing.movement.IMovement;
|
import baritone.api.pathing.movement.IMovement;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.*;
|
import baritone.api.utils.*;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.*;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import baritone.utils.InputOverrideHandler;
|
|
||||||
import net.minecraft.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -19,12 +19,11 @@ package baritone.pathing.movement;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.pathing.movement.ActionCosts;
|
import baritone.api.pathing.movement.ActionCosts;
|
||||||
import baritone.api.utils.*;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
|
import baritone.api.utils.VecUtils;
|
||||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.*;
|
||||||
import baritone.utils.Helper;
|
|
||||||
import baritone.utils.InputOverrideHandler;
|
|
||||||
import baritone.utils.ToolSet;
|
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@ -393,7 +392,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
* @param ts previously calculated ToolSet
|
* @param ts previously calculated ToolSet
|
||||||
*/
|
*/
|
||||||
static void switchToBestToolFor(IBlockState b, ToolSet ts) {
|
static void switchToBestToolFor(IBlockState b, ToolSet ts) {
|
||||||
mc.player.inventory.currentItem = ts.getBestSlot(b.getBlock());
|
Helper.HELPER.player().inventory.currentItem = ts.getBestSlot(b.getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean throwaway(boolean select) {
|
static boolean throwaway(boolean select) {
|
||||||
@ -433,10 +432,11 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void moveTowards(MovementState state, BlockPos pos) {
|
static void moveTowards(MovementState state, BlockPos pos) {
|
||||||
|
EntityPlayerSP player = Helper.HELPER.player();
|
||||||
state.setTarget(new MovementTarget(
|
state.setTarget(new MovementTarget(
|
||||||
new Rotation(RotationUtils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
new Rotation(RotationUtils.calcRotationFromVec3d(player.getPositionEyes(1.0F),
|
||||||
VecUtils.getBlockPosCenter(pos),
|
VecUtils.getBlockPosCenter(pos),
|
||||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch)).getYaw(), mc.player.rotationPitch),
|
new Rotation(player.rotationYaw, player.rotationPitch)).getYaw(), player.rotationPitch),
|
||||||
false
|
false
|
||||||
)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
)).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ package baritone.pathing.movement.movements;
|
|||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.RayTraceUtils;
|
import baritone.utils.RayTraceUtils;
|
||||||
import baritone.api.utils.RotationUtils;
|
import baritone.utils.RotationUtils;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
|
@ -19,13 +19,17 @@ package baritone.pathing.movement.movements;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.*;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
|
import baritone.api.utils.VecUtils;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
|
import baritone.utils.RayTraceUtils;
|
||||||
|
import baritone.utils.RotationUtils;
|
||||||
import baritone.utils.pathing.MutableMoveResult;
|
import baritone.utils.pathing.MutableMoveResult;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
@ -67,7 +71,7 @@ public class MovementFall extends Movement {
|
|||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player().posY - dest.getY() < mc.playerController.getBlockReachDistance()) {
|
if (player().posY - dest.getY() < playerController().getBlockReachDistance()) {
|
||||||
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER);
|
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER);
|
||||||
|
|
||||||
targetRotation = new Rotation(player().rotationYaw, 90.0F);
|
targetRotation = new Rotation(player().rotationYaw, 90.0F);
|
||||||
|
@ -20,9 +20,9 @@ package baritone.pathing.movement.movements;
|
|||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.RayTraceUtils;
|
import baritone.utils.RayTraceUtils;
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
import baritone.api.utils.RotationUtils;
|
import baritone.utils.RotationUtils;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
import baritone.pathing.movement.MovementHelper;
|
import baritone.pathing.movement.MovementHelper;
|
||||||
|
@ -20,7 +20,6 @@ package baritone.pathing.movement.movements;
|
|||||||
import baritone.api.pathing.movement.MovementStatus;
|
import baritone.api.pathing.movement.MovementStatus;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
import baritone.api.utils.RotationUtils;
|
|
||||||
import baritone.api.utils.VecUtils;
|
import baritone.api.utils.VecUtils;
|
||||||
import baritone.pathing.movement.CalculationContext;
|
import baritone.pathing.movement.CalculationContext;
|
||||||
import baritone.pathing.movement.Movement;
|
import baritone.pathing.movement.Movement;
|
||||||
@ -28,6 +27,7 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
|
import baritone.utils.RotationUtils;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
@ -157,11 +157,11 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine;
|
boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine;
|
||||||
boolean vine = fromDown.getBlock() instanceof BlockVine;
|
boolean vine = fromDown.getBlock() instanceof BlockVine;
|
||||||
Rotation rotation = RotationUtils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
|
Rotation rotation = RotationUtils.calcRotationFromVec3d(player().getPositionEyes(1.0F),
|
||||||
VecUtils.getBlockPosCenter(positionToPlace),
|
VecUtils.getBlockPosCenter(positionToPlace),
|
||||||
new Rotation(mc.player.rotationYaw, mc.player.rotationPitch));
|
new Rotation(player().rotationYaw, player().rotationPitch));
|
||||||
if (!ladder) {
|
if (!ladder) {
|
||||||
state.setTarget(new MovementState.MovementTarget(new Rotation(mc.player.rotationYaw, rotation.getPitch()), true));
|
state.setTarget(new MovementState.MovementTarget(new Rotation(player().rotationYaw, rotation.getPitch()), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
boolean blockIsThere = MovementHelper.canWalkOn(src) || ladder;
|
||||||
|
@ -26,6 +26,8 @@ import baritone.pathing.movement.MovementHelper;
|
|||||||
import baritone.pathing.movement.MovementState;
|
import baritone.pathing.movement.MovementState;
|
||||||
import baritone.utils.BlockStateInterface;
|
import baritone.utils.BlockStateInterface;
|
||||||
import baritone.utils.InputOverrideHandler;
|
import baritone.utils.InputOverrideHandler;
|
||||||
|
import baritone.utils.RayTraceUtils;
|
||||||
|
import baritone.utils.RotationUtils;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -22,7 +22,7 @@ import baritone.api.pathing.goals.*;
|
|||||||
import baritone.api.process.IMineProcess;
|
import baritone.api.process.IMineProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
import baritone.api.utils.RotationUtils;
|
import baritone.utils.RotationUtils;
|
||||||
import baritone.cache.CachedChunk;
|
import baritone.cache.CachedChunk;
|
||||||
import baritone.cache.ChunkPacker;
|
import baritone.cache.ChunkPacker;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
|
@ -23,7 +23,6 @@ import baritone.api.cache.IWaypoint;
|
|||||||
import baritone.api.event.events.ChatEvent;
|
import baritone.api.event.events.ChatEvent;
|
||||||
import baritone.api.pathing.goals.*;
|
import baritone.api.pathing.goals.*;
|
||||||
import baritone.api.pathing.movement.ActionCosts;
|
import baritone.api.pathing.movement.ActionCosts;
|
||||||
import baritone.api.utils.RayTraceUtils;
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
import baritone.behavior.Behavior;
|
import baritone.behavior.Behavior;
|
||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
|
@ -23,6 +23,7 @@ import baritone.api.utils.Rotation;
|
|||||||
import net.minecraft.block.BlockSlab;
|
import net.minecraft.block.BlockSlab;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
@ -57,6 +58,13 @@ public interface Helper {
|
|||||||
return mc.player;
|
return mc.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PlayerControllerMP playerController() { // idk
|
||||||
|
if (!mc.isCallingFromMinecraftThread()) {
|
||||||
|
throw new IllegalStateException("h00000000");
|
||||||
|
}
|
||||||
|
return mc.playerController;
|
||||||
|
}
|
||||||
|
|
||||||
default WorldClient world() {
|
default WorldClient world() {
|
||||||
return mc.world;
|
return mc.world;
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import baritone.api.utils.Rotation;
|
||||||
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
@ -29,11 +30,7 @@ import java.util.Optional;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/25/2018
|
* @since 8/25/2018
|
||||||
*/
|
*/
|
||||||
public final class RayTraceUtils {
|
public final class RayTraceUtils implements Helper {
|
||||||
/**
|
|
||||||
* The {@link Minecraft} instance
|
|
||||||
*/
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
private RayTraceUtils() {}
|
private RayTraceUtils() {}
|
||||||
|
|
||||||
@ -50,19 +47,20 @@ public final class RayTraceUtils {
|
|||||||
* @return The calculated raytrace result
|
* @return The calculated raytrace result
|
||||||
*/
|
*/
|
||||||
public static RayTraceResult simulateRayTrace(float yaw, float pitch) {
|
public static RayTraceResult simulateRayTrace(float yaw, float pitch) {
|
||||||
|
EntityPlayerSP player = Helper.HELPER.player();
|
||||||
RayTraceResult oldTrace = mc.objectMouseOver;
|
RayTraceResult oldTrace = mc.objectMouseOver;
|
||||||
float oldYaw = mc.player.rotationYaw;
|
float oldYaw = player.rotationYaw;
|
||||||
float oldPitch = mc.player.rotationPitch;
|
float oldPitch = player.rotationPitch;
|
||||||
|
|
||||||
mc.player.rotationYaw = yaw;
|
player.rotationYaw = yaw;
|
||||||
mc.player.rotationPitch = pitch;
|
player.rotationPitch = pitch;
|
||||||
|
|
||||||
mc.entityRenderer.getMouseOver(1.0F);
|
mc.entityRenderer.getMouseOver(1.0F);
|
||||||
RayTraceResult result = mc.objectMouseOver;
|
RayTraceResult result = mc.objectMouseOver;
|
||||||
mc.objectMouseOver = oldTrace;
|
mc.objectMouseOver = oldTrace;
|
||||||
|
|
||||||
mc.player.rotationYaw = oldYaw;
|
player.rotationYaw = oldYaw;
|
||||||
mc.player.rotationPitch = oldPitch;
|
player.rotationPitch = oldPitch;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -76,8 +74,8 @@ public final class RayTraceUtils {
|
|||||||
* @return The calculated raytrace result
|
* @return The calculated raytrace result
|
||||||
*/
|
*/
|
||||||
public static RayTraceResult rayTraceTowards(Rotation rotation) {
|
public static RayTraceResult rayTraceTowards(Rotation rotation) {
|
||||||
double blockReachDistance = mc.playerController.getBlockReachDistance();
|
double blockReachDistance = Helper.HELPER.playerController().getBlockReachDistance();
|
||||||
Vec3d start = mc.player.getPositionEyes(1.0F);
|
Vec3d start = Helper.HELPER.player().getPositionEyes(1.0F);
|
||||||
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
Vec3d direction = RotationUtils.calcVec3dFromRotation(rotation);
|
||||||
Vec3d end = start.add(
|
Vec3d end = start.add(
|
||||||
direction.x * blockReachDistance,
|
direction.x * blockReachDistance,
|
@ -15,11 +15,12 @@
|
|||||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package baritone.api.utils;
|
package baritone.utils;
|
||||||
|
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
|
import baritone.api.utils.VecUtils;
|
||||||
import net.minecraft.block.BlockFire;
|
import net.minecraft.block.BlockFire;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
|
|
||||||
@ -29,12 +30,7 @@ import java.util.Optional;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 9/25/2018
|
* @since 9/25/2018
|
||||||
*/
|
*/
|
||||||
public final class RotationUtils {
|
public final class RotationUtils implements Helper {
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link Minecraft} instance
|
|
||||||
*/
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant that a degree value is multiplied by to get the equivalent radian value
|
* Constant that a degree value is multiplied by to get the equivalent radian value
|
||||||
@ -60,33 +56,6 @@ public final class RotationUtils {
|
|||||||
|
|
||||||
private RotationUtils() {}
|
private RotationUtils() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clamps the specified pitch value between -90 and 90.
|
|
||||||
*
|
|
||||||
* @param pitch The input pitch
|
|
||||||
* @return The clamped pitch
|
|
||||||
*/
|
|
||||||
public static float clampPitch(float pitch) {
|
|
||||||
return Math.max(-90, Math.min(90, pitch));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes the specified yaw value between -180 and 180.
|
|
||||||
*
|
|
||||||
* @param yaw The input yaw
|
|
||||||
* @return The normalized yaw
|
|
||||||
*/
|
|
||||||
public static float normalizeYaw(float yaw) {
|
|
||||||
float newYaw = yaw % 360F;
|
|
||||||
if (newYaw < -180F) {
|
|
||||||
newYaw += 360F;
|
|
||||||
}
|
|
||||||
if (newYaw >= 180F) {
|
|
||||||
newYaw -= 360F;
|
|
||||||
}
|
|
||||||
return newYaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the rotation from BlockPos<sub>dest</sub> to BlockPos<sub>orig</sub>
|
* Calculates the rotation from BlockPos<sub>dest</sub> to BlockPos<sub>orig</sub>
|
||||||
*
|
*
|
Loading…
Reference in New Issue
Block a user