Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit cd4c4c2

Browse files
committed
Add passive mod toggle and fly kick bypass to worldguard
1 parent a42a9e0 commit cd4c4c2

File tree

6 files changed

+121
-82
lines changed

6 files changed

+121
-82
lines changed

src/main/java/com/jorianwoltjer/liveoverflowmod/client/Keybinds.java

Lines changed: 82 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
44
import net.minecraft.client.MinecraftClient;
55
import net.minecraft.client.network.ClientPlayNetworkHandler;
6-
import net.minecraft.client.option.GameOptions;
76
import net.minecraft.client.option.KeyBinding;
7+
import net.minecraft.entity.Entity;
88
import net.minecraft.entity.player.PlayerEntity;
99
import net.minecraft.network.Packet;
1010
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
@@ -28,26 +28,31 @@ public class Keybinds {
2828
public static ClientPlayNetworkHandler networkHandler;
2929

3030
private static final KeyBinding worldGuardBypassToggle = new KeyBinding("key.liveoverflowmod.worldguardbypass_toggle",
31-
GLFW.GLFW_KEY_SEMICOLON, LIVEOVERFLOW_CATEGORY); // Bypass WorldGuard region protection
31+
GLFW.GLFW_KEY_SEMICOLON, LIVEOVERFLOW_CATEGORY); // Bypass WorldGuard region protection
3232
private static final KeyBinding reachKeybind = new KeyBinding("key.liveoverflowmod.reach",
3333
GLFW.GLFW_KEY_BACKSLASH, LIVEOVERFLOW_CATEGORY); // Hit the nearest player from far away
3434
private static final KeyBinding panicKeybind = new KeyBinding("key.liveoverflowmod.panic",
3535
GLFW.GLFW_KEY_COMMA, LIVEOVERFLOW_CATEGORY); // Fly up as fast as possible
36+
private static final KeyBinding modToggle = new KeyBinding("key.liveoverflowmod.passive_toggle",
37+
GLFW.GLFW_KEY_MINUS, LIVEOVERFLOW_CATEGORY); // Toggle passive mods on/off
3638

3739
public static LinkedList<Packet<?>> packetQueue = new LinkedList<>();
3840
public static boolean worldGuardBypassEnabled = false;
41+
public static boolean passiveModsEnabled = true;
3942
public static boolean needsHitPacket = false;
43+
public static int flyingTimer = 0;
4044
public static int panicTimer = 0;
41-
public static PlayerEntity targetPlayer;
45+
public static Entity reachTarget;
4246
public static Vec3d virtualPosition;
4347

4448
public static void registerKeybinds() {
4549
KeyBindingHelper.registerKeyBinding(worldGuardBypassToggle);
4650
KeyBindingHelper.registerKeyBinding(reachKeybind);
4751
KeyBindingHelper.registerKeyBinding(panicKeybind);
52+
KeyBindingHelper.registerKeyBinding(modToggle);
4853
}
4954

50-
public static PlayerEntity getClosestPlayer() {
55+
public static Entity getClosestPlayer() {
5156
if (mc.player == null || mc.world == null) {
5257
return null;
5358
}
@@ -79,9 +84,19 @@ public static <T> void addToMiddle(LinkedList<T> list, T object) {
7984

8085
public static void checkKeybinds(MinecraftClient client) {
8186
networkHandler = client.getNetworkHandler();
82-
if (client.player != null && client.world != null && networkHandler != null) {
87+
if (client.player != null && client.world != null && networkHandler != null && client.interactionManager != null) {
88+
while (modToggle.wasPressed()) { // Toggle whole mod
89+
passiveModsEnabled = !passiveModsEnabled;
90+
if (passiveModsEnabled) {
91+
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §aEnabled"), false);
92+
} else {
93+
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §cDisabled"), false);
94+
}
95+
}
96+
8397
// Toggle WorldGuard Bypass
8498
while (worldGuardBypassToggle.wasPressed()) {
99+
flyingTimer = 0;
85100
if (worldGuardBypassEnabled) {
86101
worldGuardBypassEnabled = false;
87102
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §rWorldGuard Bypass: §cDisabled"), false);
@@ -93,65 +108,71 @@ public static void checkKeybinds(MinecraftClient client) {
93108

94109
// WorldGuard bypass
95110
if (worldGuardBypassEnabled) {
96-
client.player.setVelocity(0, 0, 0);
97-
98-
Vec3d vec = new Vec3d(0, 0, 0);
99-
100-
// Key presses changing position
101-
if (client.player.input.jumping) { // Move up
102-
vec = vec.add(new Vec3d(0, 1, 0));
103-
} else if (client.player.input.sneaking) { // Move down
104-
vec = vec.add(new Vec3d(0, -1, 0));
111+
if (++flyingTimer > 30) { // Max 80, to bypass "Flying is not enabled"
112+
networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(client.player.getX(),
113+
client.player.getY() - 0.04, client.player.getZ(), client.player.isOnGround()));
114+
flyingTimer = 0; // Reset
105115
} else {
106-
// Horizontal movement (not at the same time as vertical)
107-
if (client.player.input.pressingForward) {
108-
vec = vec.add(new Vec3d(0, 0, 1));
109-
}
110-
if (client.player.input.pressingRight) {
111-
vec = vec.add(new Vec3d(1, 0, 0));
112-
}
113-
if (client.player.input.pressingBack) {
114-
vec = vec.add(new Vec3d(0, 0, -1));
115-
}
116-
if (client.player.input.pressingLeft) {
117-
vec = vec.add(new Vec3d(-1, 0, 0));
116+
client.player.setVelocity(0, 0, 0);
117+
118+
Vec3d vec = new Vec3d(0, 0, 0);
119+
120+
// Key presses changing position
121+
if (client.player.input.jumping) { // Move up
122+
vec = vec.add(new Vec3d(0, 1, 0));
123+
} else if (client.player.input.sneaking) { // Move down
124+
vec = vec.add(new Vec3d(0, -1, 0));
125+
} else {
126+
// Horizontal movement (not at the same time as vertical)
127+
if (client.player.input.pressingForward) {
128+
vec = vec.add(new Vec3d(0, 0, 1));
129+
}
130+
if (client.player.input.pressingRight) {
131+
vec = vec.add(new Vec3d(1, 0, 0));
132+
}
133+
if (client.player.input.pressingBack) {
134+
vec = vec.add(new Vec3d(0, 0, -1));
135+
}
136+
if (client.player.input.pressingLeft) {
137+
vec = vec.add(new Vec3d(-1, 0, 0));
138+
}
118139
}
119-
}
120140

121-
if (vec.length() > 0) {
122-
vec = vec.normalize(); // Normalize to length 1
141+
if (vec.length() > 0) {
142+
vec = vec.normalize(); // Normalize to length 1
123143

124-
if (!(vec.x == 0 && vec.z == 0)) { // Rotate by looking yaw (won't change length)
125-
double moveAngle = Math.atan2(vec.x, vec.z) + Math.toRadians(client.player.getYaw() + 90);
126-
double x = Math.cos(moveAngle);
127-
double z = Math.sin(moveAngle);
128-
vec = new Vec3d(x, vec.y, z);
129-
}
144+
if (!(vec.x == 0 && vec.z == 0)) { // Rotate by looking yaw (won't change length)
145+
double moveAngle = Math.atan2(vec.x, vec.z) + Math.toRadians(client.player.getYaw() + 90);
146+
double x = Math.cos(moveAngle);
147+
double z = Math.sin(moveAngle);
148+
vec = new Vec3d(x, vec.y, z);
149+
}
130150

131-
vec = vec.multiply(MAX_DELTA); // Scale to maxDelta
151+
vec = vec.multiply(MAX_DELTA); // Scale to maxDelta
132152

133-
Vec3d newPos = new Vec3d(client.player.getX() + vec.x, client.player.getY() + vec.y, client.player.getZ() + vec.z);
134-
// If able to add more without going over a block boundary, add more
135-
boolean extra = false;
136-
if (client.options.sprintKey.isPressed()) { // Trigger by sprinting
137-
while (inSameBlock(newPos.add(vec.multiply(1.5)), new Vec3d(client.player.prevX, client.player.prevY, client.player.prevZ))) {
138-
newPos = newPos.add(vec);
139-
extra = true;
153+
Vec3d newPos = new Vec3d(client.player.getX() + vec.x, client.player.getY() + vec.y, client.player.getZ() + vec.z);
154+
// If able to add more without going over a block boundary, add more
155+
boolean extra = false;
156+
if (client.options.sprintKey.isPressed()) { // Trigger by sprinting
157+
while (inSameBlock(newPos.add(vec.multiply(1.5)), new Vec3d(client.player.prevX, client.player.prevY, client.player.prevZ))) {
158+
newPos = newPos.add(vec);
159+
extra = true;
160+
}
140161
}
141-
}
142162

143-
client.player.setPosition(newPos);
163+
client.player.setPosition(newPos);
144164

145-
// Send tiny movement so delta is small enough
146-
PlayerMoveC2SPacket.Full smallMovePacket = new PlayerMoveC2SPacket.Full(client.player.getX(), client.player.getY(),
147-
client.player.getZ(), client.player.getYaw(), client.player.getPitch(), client.player.isOnGround());
148-
networkHandler.getConnection().send(smallMovePacket);
165+
// Send tiny movement so delta is small enough
166+
PlayerMoveC2SPacket.Full smallMovePacket = new PlayerMoveC2SPacket.Full(client.player.getX(), client.player.getY(),
167+
client.player.getZ(), client.player.getYaw(), client.player.getPitch(), client.player.isOnGround());
168+
networkHandler.getConnection().send(smallMovePacket);
149169

150-
// Send far away packet for "moving too quickly!" to reset position
151-
if (!extra) {
152-
PlayerMoveC2SPacket.Full farPacket = new PlayerMoveC2SPacket.Full(client.player.getX() + 1337.0, client.player.getY() + 1337.0,
153-
client.player.getZ() + 1337.0, client.player.getYaw(), client.player.getPitch(), client.player.isOnGround());
154-
networkHandler.getConnection().send(farPacket);
170+
// Send far away packet for "moving too quickly!" to reset position
171+
if (!extra) {
172+
PlayerMoveC2SPacket.Full farPacket = new PlayerMoveC2SPacket.Full(client.player.getX() + 1337.0, client.player.getY() + 1337.0,
173+
client.player.getZ() + 1337.0, client.player.getYaw(), client.player.getPitch(), client.player.isOnGround());
174+
networkHandler.getConnection().send(farPacket);
175+
}
155176
}
156177
}
157178
}
@@ -161,16 +182,16 @@ public static void checkKeybinds(MinecraftClient client) {
161182
if (packetQueue.size() > 0) {
162183
break; // Already running
163184
}
164-
targetPlayer = getClosestPlayer();
165-
if (targetPlayer != null) {
166-
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §rReach: §a" + targetPlayer.getEntityName()), false);
185+
reachTarget = getClosestPlayer();
186+
if (reachTarget != null) {
187+
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §rReach: §a" + reachTarget.getEntityName()), false);
167188
needsHitPacket = true;
168189
virtualPosition = client.player.getPos();
169190
// Move close enough to player
170191
for (int i = 0; i < 5; i++) { // Max 5 packets per tick
171192
// If player is too far away, move closer
172-
if (targetPlayer.squaredDistanceTo(virtualPosition.add(0, client.player.getStandingEyeHeight(), 0)) >= MAX_BREAK_SQUARED_DISTANCE) {
173-
Vec3d movementNeeded = targetPlayer.getPos().subtract(virtualPosition);
193+
if (reachTarget.squaredDistanceTo(virtualPosition.add(0, client.player.getStandingEyeHeight(), 0)) >= MAX_BREAK_SQUARED_DISTANCE) {
194+
Vec3d movementNeeded = reachTarget.getPos().subtract(virtualPosition);
174195
double length = movementNeeded.lengthSquared();
175196

176197
LOGGER.info(String.format("Movement needed: %s (%f)", movementNeeded, length));
@@ -191,10 +212,10 @@ public static void checkKeybinds(MinecraftClient client) {
191212
}
192213
}
193214
// Add hit packet and back to original position
194-
addToMiddle(packetQueue, PlayerInteractEntityC2SPacket.attack(targetPlayer, client.player.isSneaking()));
215+
addToMiddle(packetQueue, PlayerInteractEntityC2SPacket.attack(reachTarget, client.player.isSneaking()));
195216
packetQueue.add(new PlayerMoveC2SPacket.PositionAndOnGround(client.player.getX(), client.player.getY(), client.player.getZ(), true));
196217
} else {
197-
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §rReach: §cNo players found"), false);
218+
client.player.sendMessage(Text.of("§7[LiveOverflowMod] §rReach: §cNo targets found"), false);
198219
}
199220
}
200221

@@ -228,4 +249,3 @@ public static void checkKeybinds(MinecraftClient client) {
228249
}
229250
}
230251
}
231-
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.jorianwoltjer.liveoverflowmod.mixin;
22

3-
import com.jorianwoltjer.liveoverflowmod.LiveOverflowMod;
43
import net.minecraft.block.BlockState;
54
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
65
import net.minecraft.util.math.BlockPos;
@@ -10,24 +9,24 @@
109
import org.spongepowered.asm.mixin.injection.Inject;
1110
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1211

13-
import static com.jorianwoltjer.liveoverflowmod.client.Keybinds.mc;
14-
import static com.jorianwoltjer.liveoverflowmod.client.Keybinds.networkHandler;
12+
import static com.jorianwoltjer.liveoverflowmod.client.Keybinds.*;
1513

1614
@Mixin(net.minecraft.client.network.ClientPlayerInteractionManager.class)
1715
public class ClientPlayerInteractionMixin {
1816
// Insta-Mine hack
1917
@Inject(method = "attackBlock", at = @At(value = "HEAD"), cancellable = true)
2018
private void attackBlock(BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) {
21-
assert mc.world != null;
22-
assert mc.player != null;
23-
BlockState blockState = mc.world.getBlockState(pos);
24-
double speed = blockState.calcBlockBreakingDelta(mc.player, mc.world, pos);
25-
LiveOverflowMod.LOGGER.info("Block breaking speed: " + speed);
26-
if (!blockState.isAir() && speed > 0.5F) { // If you can break the block fast enough, break it instantly
27-
mc.world.breakBlock(pos, true, mc.player);
28-
networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, direction));
29-
networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, direction));
30-
cir.setReturnValue(true); // Return true to break the block on the client-side
19+
if (passiveModsEnabled) {
20+
assert mc.world != null;
21+
assert mc.player != null;
22+
BlockState blockState = mc.world.getBlockState(pos);
23+
double speed = blockState.calcBlockBreakingDelta(mc.player, mc.world, pos);
24+
if (!blockState.isAir() && speed > 0.5F) { // If you can break the block fast enough, break it instantly
25+
mc.world.breakBlock(pos, true, mc.player);
26+
networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, direction));
27+
networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, direction));
28+
cir.setReturnValue(true); // Return true to break the block on the client-side
29+
}
3130
}
3231
}
3332
}

src/main/java/com/jorianwoltjer/liveoverflowmod/mixin/PlayerPositionFullPacketMixin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
import org.spongepowered.asm.mixin.injection.ModifyArgs;
88
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
99

10+
import static com.jorianwoltjer.liveoverflowmod.client.Keybinds.passiveModsEnabled;
11+
1012
@Mixin(PlayerMoveC2SPacket.Full.class)
1113
public abstract class PlayerPositionFullPacketMixin {
1214
// Anti-human bypass
1315
@ModifyArgs(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;<init>(DDDFFZZZ)V"))
1416
private static void init(Args args) {
15-
RoundPosition.onPositionPacket(args);
17+
if (passiveModsEnabled) {
18+
RoundPosition.onPositionPacket(args);
19+
}
1620
}
1721

1822
}

src/main/java/com/jorianwoltjer/liveoverflowmod/mixin/PlayerPositionPacketMixin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
import org.spongepowered.asm.mixin.injection.ModifyArgs;
88
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
99

10+
import static com.jorianwoltjer.liveoverflowmod.client.Keybinds.passiveModsEnabled;
11+
1012
@Mixin(PlayerMoveC2SPacket.PositionAndOnGround.class)
1113
public class PlayerPositionPacketMixin {
1214
// Anti-human bypass
1315
@ModifyArgs(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;<init>(DDDFFZZZ)V"))
1416
private static void init(Args args) {
15-
RoundPosition.onPositionPacket(args);
17+
if (passiveModsEnabled) {
18+
RoundPosition.onPositionPacket(args);
19+
}
1620
}
1721

1822
}

src/main/java/com/jorianwoltjer/liveoverflowmod/mixin/VehicleMovePacketMixin.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,27 @@
77
import org.spongepowered.asm.mixin.injection.At;
88
import org.spongepowered.asm.mixin.injection.Redirect;
99

10+
import static com.jorianwoltjer.liveoverflowmod.client.Keybinds.passiveModsEnabled;
11+
1012
@Mixin(VehicleMoveC2SPacket.class)
1113
public class VehicleMovePacketMixin {
1214
// Anti-human bypass for X
1315
@Redirect(method = "<init>(Lnet/minecraft/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getX()D"))
14-
public double getX(Entity instance) {
15-
return RoundPosition.roundCoordinate(instance.getX());
16+
public double getX(Entity instance)
17+
{
18+
if (passiveModsEnabled) {
19+
return RoundPosition.roundCoordinate(instance.getX());
20+
} else {
21+
return instance.getX();
22+
}
1623
}
1724
// Anti-human bypass for Z
1825
@Redirect(method = "<init>(Lnet/minecraft/entity/Entity;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getZ()D"))
1926
public double getZ(Entity instance) {
20-
return RoundPosition.roundCoordinate(instance.getZ());
27+
if (passiveModsEnabled) {
28+
return RoundPosition.roundCoordinate(instance.getZ());
29+
} else {
30+
return instance.getX();
31+
}
2132
}
22-
}
33+
}

src/main/resources/assets/liveoverflowmod/lang/en_us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"category.liveoverflowmod": "LiveOverflowMod",
33
"key.liveoverflowmod.worldguardbypass_toggle": "WorldGuard Bypass",
44
"key.liveoverflowmod.reach": "Reach",
5-
"key.liveoverflowmod.panic": "Panic"
5+
"key.liveoverflowmod.panic": "Panic",
6+
"key.liveoverflowmod.passive_toggle": "Toggle Passive Mods"
67
}

0 commit comments

Comments
 (0)