From 2aac2ad4e738c960fb0e72123f28c8559e06b93e Mon Sep 17 00:00:00 2001 From: MonstoBusta <119002070+MonstoBusta@users.noreply.github.com> Date: Mon, 27 Feb 2023 01:16:24 -0600 Subject: [PATCH] Partially Rewrite Horizontal Reacharound Replace use of BlockPos with Vec3d to allow double increased clamp on vector instead of integer. --- .../client/MidnightReacharound.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java b/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java index 6c1f8f4..7b927b8 100644 --- a/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java +++ b/src/main/java/eu/midnightdust/midnightcontrols/client/MidnightReacharound.java @@ -120,31 +120,39 @@ public class MidnightReacharound { return null; if (client.player != null && client.crosshairTarget != null && client.crosshairTarget.getType() == HitResult.Type.MISS - && client.player.isOnGround() && client.player.getPitch(0.f) > 35.f) { + && client.player.isOnGround() && client.player.getPitch(0.f) >= 35.f) { if (client.player.isRiding()) return null; - var playerPos = client.player.getBlockPos().down(); + // Temporary pos, do not use + Vec3d playerPosi = client.player.getPos(); + + // Imitates var playerPos = client.player.getBlockPos().down(); + Vec3d playerPos = new Vec3d(playerPosi.getX(), playerPosi.getY() - 1.0, playerPosi.getZ()); if (client.player.getY() - playerPos.getY() - 1.0 >= 0.25) { - playerPos = playerPos.up(); + // Imitates playerPos = playerPos.up(); + playerPos = playerPosi; this.onSlab = true; } else { this.onSlab = false; } - var targetPos = new BlockPos(client.crosshairTarget.getPos()).subtract(playerPos); - var vector = new BlockPos.Mutable(MathHelper.clamp(targetPos.getX(), -1, 1), 0, MathHelper.clamp(targetPos.getZ(), -1, 1)); + var targetPos = new Vec3d(client.crosshairTarget.getPos().getX(), client.crosshairTarget.getPos().getY(), client.crosshairTarget.getPos().getZ()).subtract(playerPos); + var vector = new Vec3d(MathHelper.clamp(targetPos.getX(), -1, 1), 0, MathHelper.clamp(targetPos.getZ(), -1, 1)); var blockPos = playerPos.add(vector); + // Some functions still need BlockPos, so this is here to let that happen + var blockyPos = new BlockPos(blockPos); + var direction = client.player.getHorizontalFacing(); - var state = client.world.getBlockState(blockPos); + var state = client.world.getBlockState(blockyPos); if (!state.isAir()) return null; - var adjacentBlockState = client.world.getBlockState(blockPos.offset(direction.getOpposite())); + var adjacentBlockState = client.world.getBlockState(blockyPos.offset(direction.getOpposite())); if (adjacentBlockState.isAir() || adjacentBlockState.getBlock() instanceof FluidBlock || (vector.getX() == 0 && vector.getZ() == 0)) { return null; } - return new BlockHitResult(new Vec3d(blockPos.getX(),blockPos.getY(),blockPos.getZ()), direction, blockPos, false); + return new BlockHitResult(blockPos, direction, blockyPos, false); } return null; }