From 9ae6d0a84caa2ca1c0ba8197e1952c274256d806 Mon Sep 17 00:00:00 2001 From: Moosbee Date: Mon, 16 Oct 2023 16:49:55 +0200 Subject: [PATCH 1/2] update clickTP to work in freecam --- .../systems/modules/movement/ClickTP.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java index 64fe9dd512..b5c9a77fad 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java @@ -11,8 +11,11 @@ import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.Freecam; import meteordevelopment.orbit.EventHandler; import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -20,7 +23,10 @@ import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.RaycastContext; public class ClickTP extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -41,7 +47,21 @@ private void onTick(TickEvent.Post event) { if (mc.player.isUsingItem()) return; if (mc.options.useKey.isPressed()) { - HitResult hitResult = mc.player.raycast(maxDistance.get(), 1f / 20f, false); + + Entity rayStart = mc.cameraEntity == null ? mc.player : mc.cameraEntity; + + Vec3d startPos = rayStart.getCameraPosVec(1f/20f); + Vec3d rotationVec = rayStart.getRotationVec(1f/20f); + + if(Modules.get().get(Freecam.class).isActive()){ + Freecam cam=Modules.get().get(Freecam.class); + startPos=new Vec3d(cam.pos.x,cam.pos.y,cam.pos.z); + rotationVec=getRotationVector(cam.pitch, cam.yaw); + } + + Vec3d endPos = startPos.add(rotationVec.x * maxDistance.get(), rotationVec.y * maxDistance.get(), rotationVec.z * maxDistance.get()); + HitResult hitResult = mc.world.raycast(new RaycastContext(startPos, endPos, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, rayStart)); + if (hitResult.getType() == HitResult.Type.ENTITY && mc.player.interact(((EntityHitResult) hitResult).getEntity(), Hand.MAIN_HAND) != ActionResult.PASS) return; @@ -62,4 +82,15 @@ private void onTick(TickEvent.Post event) { } } } + + //copied from entity.class + protected final Vec3d getRotationVector(float pitch, float yaw) { + float f = pitch * 0.017453292F; + float g = -yaw * 0.017453292F; + float h = MathHelper.cos(g); + float i = MathHelper.sin(g); + float j = MathHelper.cos(f); + float k = MathHelper.sin(f); + return new Vec3d((i * j), (-k), (h * j)); + } } From 8961829f356dce2c1e5e48a3274cd48554f3501d Mon Sep 17 00:00:00 2001 From: Moosbee Date: Mon, 16 Oct 2023 16:55:49 +0200 Subject: [PATCH 2/2] update clickTP to work in freecam comments --- .../meteorclient/systems/modules/movement/ClickTP.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java index b5c9a77fad..080985e2a3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java @@ -48,6 +48,7 @@ private void onTick(TickEvent.Post event) { if (mc.options.useKey.isPressed()) { + // ensure compatibility to freecam mods which change the cameraEntity Entity rayStart = mc.cameraEntity == null ? mc.player : mc.cameraEntity; Vec3d startPos = rayStart.getCameraPosVec(1f/20f);