Skip to content

Commit

Permalink
update clickTP to work in freecam
Browse files Browse the repository at this point in the history
  • Loading branch information
RiederBernhard committed Oct 16, 2023
1 parent 47b95b6 commit 9ae6d0a
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@
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;
import net.minecraft.util.hit.EntityHitResult;
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();
Expand All @@ -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;

Expand All @@ -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));
}
}

0 comments on commit 9ae6d0a

Please sign in to comment.