|
10 | 10 | import ac.grim.grimac.utils.data.VectorData;
|
11 | 11 | import ac.grim.grimac.utils.lists.EvictingQueue;
|
12 | 12 | import ac.grim.grimac.utils.math.GrimMath;
|
| 13 | +import ac.grim.grimac.utils.vector.Vector3D; |
13 | 14 | import com.github.retrooper.packetevents.PacketEvents;
|
14 | 15 | import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
| 16 | +import com.github.retrooper.packetevents.util.Vector3d; |
15 | 17 | import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
16 | 18 | import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
17 | 19 | import lombok.AllArgsConstructor;
|
18 |
| -import org.bukkit.util.Vector; |
19 | 20 |
|
20 | 21 | import java.util.*;
|
21 | 22 |
|
| 23 | +import static ac.grim.grimac.utils.vector.VectorFactory.newVector3D; |
| 24 | + |
22 | 25 | public final class SuperDebug extends Check implements PostPredictionCheck {
|
23 | 26 | private static final StringBuilder[] flags = new StringBuilder[256]; // 17 MB of logs in memory
|
24 | 27 |
|
25 | 28 | Object2IntMap<StringBuilder> continuedDebug = new Object2IntOpenHashMap<>();
|
26 | 29 |
|
27 | 30 | List<VectorData> predicted = new EvictingQueue<>(60);
|
28 |
| - List<Vector> actually = new EvictingQueue<>(60); |
| 31 | + List<Vector3D> actually = new EvictingQueue<>(60); |
29 | 32 | List<Location> locations = new EvictingQueue<>(60);
|
30 |
| - List<Vector> startTickClientVel = new EvictingQueue<>(60); |
31 |
| - List<Vector> baseTickAddition = new EvictingQueue<>(60); |
32 |
| - List<Vector> baseTickWater = new EvictingQueue<>(60); |
| 33 | + List<Vector3D> startTickClientVel = new EvictingQueue<>(60); |
| 34 | + List<Vector3D> baseTickAddition = new EvictingQueue<>(60); |
| 35 | + List<Vector3D> baseTickWater = new EvictingQueue<>(60); |
33 | 36 |
|
34 | 37 | public SuperDebug(GrimPlayer player) {
|
35 | 38 | super(player);
|
@@ -80,11 +83,11 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
|
80 | 83 |
|
81 | 84 | for (int i = 0; i < predicted.size(); i++) {
|
82 | 85 | VectorData predict = predicted.get(i);
|
83 |
| - Vector actual = actually.get(i); |
| 86 | + Vector3D actual = actually.get(i); |
84 | 87 | Location loc = locations.get(i);
|
85 |
| - Vector startTickVel = startTickClientVel.get(i); |
86 |
| - Vector addition = baseTickAddition.get(i); |
87 |
| - Vector water = baseTickWater.get(i); |
| 88 | + Vector3D startTickVel = startTickClientVel.get(i); |
| 89 | + Vector3D addition = baseTickAddition.get(i); |
| 90 | + Vector3D water = baseTickWater.get(i); |
88 | 91 | appendDebug(sb, predict, actual, loc, startTickVel, addition, water);
|
89 | 92 | }
|
90 | 93 |
|
@@ -189,7 +192,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
|
189 | 192 | continuedDebug.put(sb, 40);
|
190 | 193 | }
|
191 | 194 |
|
192 |
| - private void appendDebug(StringBuilder sb, VectorData predict, Vector actual, Location location, Vector startTick, Vector addition, Vector water) { |
| 195 | + private void appendDebug(StringBuilder sb, VectorData predict, Vector3D actual, Location location, Vector3D startTick, Vector3D addition, Vector3D water) { |
193 | 196 | if (predict.isZeroPointZeroThree()) {
|
194 | 197 | sb.append("Movement threshold/tick skipping\n");
|
195 | 198 | }
|
@@ -225,11 +228,11 @@ private void appendDebug(StringBuilder sb, VectorData predict, Vector actual, Lo
|
225 | 228 | // Apply 0.003/0.005 to make numbers more accurate
|
226 | 229 | Set<VectorData> set = new HashSet<>(Collections.singletonList(new VectorData(startTick.clone(), VectorData.VectorType.BestVelPicked)));
|
227 | 230 | new PredictionEngine().applyMovementThreshold(player, set);
|
228 |
| - Vector trueStartVel = ((VectorData) set.toArray()[0]).vector; |
| 231 | + Vector3D trueStartVel = ((VectorData) set.toArray()[0]).vector; |
229 | 232 |
|
230 |
| - Vector clientMovement = getPlayerMathMovement(player, actual.clone().subtract(trueStartVel), location.xRot); |
231 |
| - Vector simulatedMovement = getPlayerMathMovement(player, predict.vector.clone().subtract(trueStartVel), location.xRot); |
232 |
| - Vector offset = actual.clone().subtract(predict.vector); |
| 233 | + Vector3D clientMovement = getPlayerMathMovement(player, actual.clone().subtract(trueStartVel), location.xRot); |
| 234 | + Vector3D simulatedMovement = getPlayerMathMovement(player, predict.vector.clone().subtract(trueStartVel), location.xRot); |
| 235 | + Vector3D offset = actual.clone().subtract(predict.vector); |
233 | 236 | trueStartVel.add(addition);
|
234 | 237 | trueStartVel.add(water);
|
235 | 238 |
|
@@ -268,14 +271,14 @@ private void appendDebug(StringBuilder sb, VectorData predict, Vector actual, Lo
|
268 | 271 | sb.append("\n\n");
|
269 | 272 | }
|
270 | 273 |
|
271 |
| - private Vector getPlayerMathMovement(GrimPlayer player, Vector wantedMovement, float f2) { |
| 274 | + private Vector3D getPlayerMathMovement(GrimPlayer player, Vector3D wantedMovement, float f2) { |
272 | 275 | float f3 = player.trigHandler.sin(f2 * 0.017453292f);
|
273 | 276 | float f4 = player.trigHandler.cos(f2 * 0.017453292f);
|
274 | 277 |
|
275 | 278 | float bestTheoreticalX = (float) (f3 * wantedMovement.getZ() + f4 * wantedMovement.getX()) / (f3 * f3 + f4 * f4);
|
276 | 279 | float bestTheoreticalZ = (float) (-f3 * wantedMovement.getX() + f4 * wantedMovement.getZ()) / (f3 * f3 + f4 * f4);
|
277 | 280 |
|
278 |
| - return new Vector(bestTheoreticalX, 0, bestTheoreticalZ); |
| 281 | + return newVector3D(bestTheoreticalX, 0, bestTheoreticalZ); |
279 | 282 | }
|
280 | 283 |
|
281 | 284 | @AllArgsConstructor
|
|
0 commit comments