Skip to content

Commit 7d489bc

Browse files
Wide-CatNot-a-Tyler
andcommitted
Update ClickTP
- add the paperclip exploit - make the module work while using freecam - fix the conditions where you shouldn't tp (using an item, placing a block, etc.) closes #4549 closes #4146 closes #2775 closes #5595 Co-authored-by: tyler <[email protected]>
1 parent 1472997 commit 7d489bc

File tree

1 file changed

+47
-24
lines changed
  • src/main/java/meteordevelopment/meteorclient/systems/modules/movement

1 file changed

+47
-24
lines changed

src/main/java/meteordevelopment/meteorclient/systems/modules/movement/ClickTP.java

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,83 @@
66
package meteordevelopment.meteorclient.systems.modules.movement;
77

88
import meteordevelopment.meteorclient.events.world.TickEvent;
9-
import meteordevelopment.meteorclient.settings.DoubleSetting;
10-
import meteordevelopment.meteorclient.settings.Setting;
11-
import meteordevelopment.meteorclient.settings.SettingGroup;
129
import meteordevelopment.meteorclient.systems.modules.Categories;
1310
import meteordevelopment.meteorclient.systems.modules.Module;
1411
import meteordevelopment.orbit.EventHandler;
1512
import net.minecraft.block.BlockState;
13+
import net.minecraft.client.render.Camera;
14+
import net.minecraft.item.BlockItem;
15+
import net.minecraft.item.consume.UseAction;
16+
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
1617
import net.minecraft.util.ActionResult;
1718
import net.minecraft.util.Hand;
1819
import net.minecraft.util.hit.BlockHitResult;
1920
import net.minecraft.util.hit.EntityHitResult;
2021
import net.minecraft.util.hit.HitResult;
2122
import net.minecraft.util.math.BlockPos;
2223
import net.minecraft.util.math.Direction;
24+
import net.minecraft.util.math.Vec3d;
2325
import net.minecraft.util.shape.VoxelShape;
26+
import net.minecraft.world.RaycastContext;
2427

2528
public class ClickTP extends Module {
26-
private final SettingGroup sgGeneral = settings.getDefaultGroup();
27-
28-
private final Setting<Double> maxDistance = sgGeneral.add(new DoubleSetting.Builder()
29-
.name("max-distance")
30-
.description("The maximum distance you can teleport.")
31-
.defaultValue(5)
32-
.build()
33-
);
3429

3530
public ClickTP() {
3631
super(Categories.Movement, "click-tp", "Teleports you to the block you click on.");
3732
}
3833

3934
@EventHandler
4035
private void onTick(TickEvent.Post event) {
41-
if (mc.player.isUsingItem()) return;
36+
if (mc.player.getInventory().getSelectedStack().getUseAction() != UseAction.NONE) return;
37+
if (!mc.options.useKey.isPressed()) return;
38+
39+
if (mc.crosshairTarget != null) {
40+
if (mc.crosshairTarget.getType() == HitResult.Type.ENTITY && mc.player.interact(((EntityHitResult) mc.crosshairTarget).getEntity(), Hand.MAIN_HAND) != ActionResult.PASS) return;
41+
if (mc.crosshairTarget.getType() == HitResult.Type.BLOCK && mc.player.getMainHandStack().getItem() instanceof BlockItem) return;
42+
}
43+
44+
Camera camera = mc.gameRenderer.getCamera();
45+
Vec3d cameraPos = camera.getPos();
4246

43-
if (mc.options.useKey.isPressed()) {
44-
HitResult hitResult = mc.player.raycast(maxDistance.get(), 1f / 20f, false);
47+
// Calculate the direction the camera is looking based on its pitch and yaw, and extend this direction 210 units away from the camera position
48+
// 210 is used here as the maximum distance for this exploit is 200 blocks
49+
// This is done to be able to click tp while in freecam
50+
Vec3d direction = Vec3d.fromPolar(camera.getPitch(), camera.getYaw()).multiply(210);
51+
Vec3d targetPos = cameraPos.add(direction);
4552

46-
if (hitResult.getType() == HitResult.Type.ENTITY && mc.player.interact(((EntityHitResult) hitResult).getEntity(), Hand.MAIN_HAND) != ActionResult.PASS) return;
53+
RaycastContext context = new RaycastContext(
54+
cameraPos, // start position of the ray
55+
targetPos, // end position of the ray
56+
RaycastContext.ShapeType.OUTLINE,
57+
RaycastContext.FluidHandling.NONE,
58+
mc.player
59+
);
4760

48-
if (hitResult.getType() == HitResult.Type.BLOCK) {
49-
BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
50-
Direction side = ((BlockHitResult) hitResult).getSide();
61+
BlockHitResult hitResult = mc.world.raycast(context);
5162

52-
if (mc.world.getBlockState(pos).onUse(mc.world, mc.player, (BlockHitResult) hitResult) != ActionResult.PASS) return;
63+
if (hitResult.getType() == HitResult.Type.BLOCK) {
64+
BlockPos pos = hitResult.getBlockPos();
65+
Direction side = hitResult.getSide();
5366

54-
BlockState state = mc.world.getBlockState(pos);
67+
if (mc.world.getBlockState(pos).onUse(mc.world, mc.player, hitResult) != ActionResult.PASS) return;
5568

56-
VoxelShape shape = state.getCollisionShape(mc.world, pos);
57-
if (shape.isEmpty()) shape = state.getOutlineShape(mc.world, pos);
69+
BlockState state = mc.world.getBlockState(pos);
5870

59-
double height = shape.isEmpty() ? 1 : shape.getMax(Direction.Axis.Y);
71+
VoxelShape shape = state.getCollisionShape(mc.world, pos);
72+
if (shape.isEmpty()) shape = state.getOutlineShape(mc.world, pos);
6073

61-
mc.player.setPosition(pos.getX() + 0.5 + side.getOffsetX(), pos.getY() + height, pos.getZ() + 0.5 + side.getOffsetZ());
74+
double height = shape.isEmpty() ? 1 : shape.getMax(Direction.Axis.Y);
75+
76+
Vec3d newPos = new Vec3d(pos.getX() + 0.5 + side.getOffsetX(), pos.getY() + height, pos.getZ() + 0.5 + side.getOffsetZ());
77+
int packetsRequired = (int) Math.ceil(mc.player.getPos().distanceTo(newPos) / 10) - 1; // subtract 1 to account for the final packet with movement
78+
if (packetsRequired > 19) packetsRequired = 0;
79+
80+
for (int packetNumber = 0; packetNumber < (packetsRequired); packetNumber++) {
81+
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true, true));
6282
}
83+
84+
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(newPos.x, newPos.y, newPos.z, true, true));
85+
mc.player.setPosition(newPos);
6386
}
6487
}
6588
}

0 commit comments

Comments
 (0)