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