mirror of
https://github.com/AntiCope/meteor-rejects.git
synced 2025-09-07 05:28:05 +00:00
Improve RoboWalk (#228)
This commit is contained in:
@@ -15,13 +15,8 @@ public class RoboWalk extends Module {
|
||||
}
|
||||
|
||||
private double smooth(double d) {
|
||||
return Math.round(d * 100.0d) / 100.0d;
|
||||
}
|
||||
|
||||
private boolean skip(double x, double z) {
|
||||
long dx = ((long) (x * 1000)) % 10;
|
||||
long dz = ((long) (z * 1000)) % 10;
|
||||
return dx != 0 || dz != 0;
|
||||
double temp = (double) Math.round(d * 100) / 100;
|
||||
return Math.nextAfter(temp, temp + Math.signum(d));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -32,16 +27,12 @@ public class RoboWalk extends Module {
|
||||
double x = smooth(packet.getX(0));
|
||||
double z = smooth(packet.getZ(0));
|
||||
|
||||
if (skip(x, z)) return;
|
||||
|
||||
((PlayerMoveC2SPacketAccessor) packet).setX(x);
|
||||
((PlayerMoveC2SPacketAccessor) packet).setZ(z);
|
||||
} else if (event.packet instanceof VehicleMoveC2SPacket packet) {
|
||||
double x = smooth(packet.getX());
|
||||
double z = smooth(packet.getZ());
|
||||
|
||||
if (skip(x, z)) return;
|
||||
|
||||
((VehicleMoveC2SPacketAccessor) packet).setX(x);
|
||||
((VehicleMoveC2SPacketAccessor) packet).setZ(z);
|
||||
}
|
||||
|
Reference in New Issue
Block a user