Skip to content

Commit

Permalink
fixed CamClip
Browse files Browse the repository at this point in the history
  • Loading branch information
stefexec committed Jun 15, 2023
1 parent e0baaa6 commit 04609af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ yarn_mappings=1.20+build.1
loader_version=0.14.21

# Mod Properties
mod_version=1.2.0
mod_version=1.2.2
maven_group=de.gurkenwerfer
archives_base_name=gurkens-gadgetry

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/gurkenwerfer/toolkit/GurkensGadgetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void onInitialize() {
// Commands

// just use meteor until I fix this
// Commands.add(new CamClip());
Commands.add(new CamClip());

}
@Override
Expand Down
29 changes: 4 additions & 25 deletions src/main/java/de/gurkenwerfer/toolkit/commands/CamClip.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,35 @@
package de.gurkenwerfer.toolkit.commands;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import de.gurkenwerfer.toolkit.mixins.ClientConnectionAccessor;
import de.gurkenwerfer.toolkit.modules.Gurkwalk;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.systems.modules.Modules;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandSource;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.text.Text;
import net.minecraft.util.math.Vec3d;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import static meteordevelopment.meteorclient.MeteorClient.mc;

public class CamClip extends Command {
public CamClip() {
super("CamClip", "Gets your camera's Y position and tries to clip there vertically.");
super("camclip", "Gets your camera's Y position and tries to clip there vertically.");
}

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
// int y = (int) mc.player.getY();

//int y = (int) mc.cameraEntity.getY();
assert mc.crosshairTarget != null;
int y = (int) mc.crosshairTarget.getPos().getY();

assert mc.player != null;
mc.player.sendMessage(Text.of("Clipping to y = " + y), false);
for (int i = 0; i < 13; i++) {
sendPositionPacket(mc.player.getPos());
for (int i = 0; i < 9; i++) {
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(true));
}
sendPositionPacket(new Vec3d(mc.player.getX(), y, mc.player.getZ()));
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), y, mc.player.getZ(), true));

return SINGLE_SUCCESS;
});
}

public static void sendPositionPacket(Vec3d pos) {

MinecraftClient mc = MinecraftClient.getInstance();
// Check if coords should be rounded
Gurkwalk gw = Modules.get().get(Gurkwalk.class);
if (gw.isActive()) {
Packet<?> positionPacket = new PlayerMoveC2SPacket.PositionAndOnGround(gw.round(pos.getX()), pos.getY(), gw.round(pos.getZ()), true);
((ClientConnectionAccessor) mc.getNetworkHandler().getConnection())._sendImmediately(positionPacket, null);
} else {
Packet<?> positionPacket = new PlayerMoveC2SPacket.PositionAndOnGround(pos.getX(), pos.getY(), pos.getZ(), true);
((ClientConnectionAccessor) mc.getNetworkHandler().getConnection())._sendImmediately(positionPacket, null);
}
}
}

0 comments on commit 04609af

Please sign in to comment.