mirror of
https://github.com/AutismDevelopment/Autism-Client.git
synced 2026-10-28 17:29:46 +00:00
Refactor: extract MacroRender from MacroExecutor (upstream #4)
Move 13 render/rotation/stopAll/packet-burst methods verbatim into MacroRender. onRender, hasRenderWork and stopAll kept as public delegates for mixin and external callers. Shared members referenced as MacroExecutor.xxx (mechanical qualification only); burst-helper call sites re-pointed across helpers. All bodies verified identical against HEAD modulo that qualification.
This commit is contained in:
parent
295688beda
commit
ad5826df73
5 changed files with 303 additions and 277 deletions
|
|
@ -55,7 +55,7 @@ final class MacroActionRunner {
|
||||||
int count, Minecraft mc) {
|
int count, Minecraft mc) {
|
||||||
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
||||||
if (context == null || context.macro() == null) return new java.util.ArrayList<>();
|
if (context == null || context.macro() == null) return new java.util.ArrayList<>();
|
||||||
return MacroExecutor.preGeneratePackets(context.macro(), context.startIdx(), count, context.endIdx());
|
return MacroRender.preGeneratePackets(context.macro(), context.startIdx(), count, context.endIdx());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTargetWaitInteractionAction(MacroAction action) {
|
public static boolean isTargetWaitInteractionAction(MacroAction action) {
|
||||||
|
|
|
||||||
|
|
@ -221,14 +221,14 @@ final class MacroDispatcher {
|
||||||
}
|
}
|
||||||
} else if (action instanceof LookAtBlockAction) {
|
} else if (action instanceof LookAtBlockAction) {
|
||||||
LookAtBlockAction la = (LookAtBlockAction) action;
|
LookAtBlockAction la = (LookAtBlockAction) action;
|
||||||
LookAtBlockAction.RotationTarget rotationTarget = MacroExecutor.resolveLookAtTargetOnClient(mc, la);
|
LookAtBlockAction.RotationTarget rotationTarget = MacroRender.resolveLookAtTargetOnClient(mc, la);
|
||||||
if (rotationTarget == null) {
|
if (rotationTarget == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (la.smooth) {
|
if (la.smooth) {
|
||||||
MacroExecutor.startSmoothRotation(rotationTarget.yaw(), rotationTarget.pitch(), la.getRotationStep());
|
MacroRender.startSmoothRotation(rotationTarget.yaw(), rotationTarget.pitch(), la.getRotationStep());
|
||||||
if (la.waitForCompletion) {
|
if (la.waitForCompletion) {
|
||||||
MacroExecutor.waitForSmoothRotationCompletion();
|
MacroRender.waitForSmoothRotationCompletion();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mc.execute(() -> {
|
mc.execute(() -> {
|
||||||
|
|
@ -240,9 +240,9 @@ final class MacroDispatcher {
|
||||||
} else if (action instanceof RotateAction) {
|
} else if (action instanceof RotateAction) {
|
||||||
RotateAction ra = (RotateAction) action;
|
RotateAction ra = (RotateAction) action;
|
||||||
if (ra.smooth) {
|
if (ra.smooth) {
|
||||||
MacroExecutor.startSmoothRotation(ra.yaw, ra.pitch, ra.getRotationStep());
|
MacroRender.startSmoothRotation(ra.yaw, ra.pitch, ra.getRotationStep());
|
||||||
if (ra.waitForCompletion) {
|
if (ra.waitForCompletion) {
|
||||||
MacroExecutor.waitForSmoothRotationCompletion();
|
MacroRender.waitForSmoothRotationCompletion();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mc.execute(() -> action.execute(mc));
|
mc.execute(() -> action.execute(mc));
|
||||||
|
|
@ -419,9 +419,9 @@ final class MacroDispatcher {
|
||||||
java.util.concurrent.locks.LockSupport.parkNanos(1_000_000L);
|
java.util.concurrent.locks.LockSupport.parkNanos(1_000_000L);
|
||||||
}
|
}
|
||||||
if (MacroExecutor.isCurrentRunActive()) {
|
if (MacroExecutor.isCurrentRunActive()) {
|
||||||
MacroExecutor.executePreGeneratedBurst(mc, preGenerated);
|
MacroRender.executePreGeneratedBurst(mc, preGenerated);
|
||||||
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
||||||
if (context != null) MacroExecutor.REPEAT_PACKET_SKIP.set(MacroExecutor.countPreGeneratedActions(context.macro(), context.startIdx(), preGenerated.size(), context.endIdx()));
|
if (context != null) MacroExecutor.REPEAT_PACKET_SKIP.set(MacroRender.countPreGeneratedActions(context.macro(), context.startIdx(), preGenerated.size(), context.endIdx()));
|
||||||
AutismClientMessaging.sendPrefixed("Tick sync: " + preGenerated.size() + " pkts sent");
|
AutismClientMessaging.sendPrefixed("Tick sync: " + preGenerated.size() + " pkts sent");
|
||||||
}
|
}
|
||||||
} else if (action instanceof RevisionSyncAction rsa) {
|
} else if (action instanceof RevisionSyncAction rsa) {
|
||||||
|
|
@ -437,9 +437,9 @@ final class MacroDispatcher {
|
||||||
java.util.concurrent.locks.LockSupport.parkNanos(500_000L);
|
java.util.concurrent.locks.LockSupport.parkNanos(500_000L);
|
||||||
}
|
}
|
||||||
if (MacroExecutor.isCurrentRunActive() && mc.player != null && mc.player.containerMenu != null) {
|
if (MacroExecutor.isCurrentRunActive() && mc.player != null && mc.player.containerMenu != null) {
|
||||||
MacroExecutor.executePreGeneratedBurst(mc, preGenerated);
|
MacroRender.executePreGeneratedBurst(mc, preGenerated);
|
||||||
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
||||||
if (context != null) MacroExecutor.REPEAT_PACKET_SKIP.set(MacroExecutor.countPreGeneratedActions(context.macro(), context.startIdx(), preGenerated.size(), context.endIdx()));
|
if (context != null) MacroExecutor.REPEAT_PACKET_SKIP.set(MacroRender.countPreGeneratedActions(context.macro(), context.startIdx(), preGenerated.size(), context.endIdx()));
|
||||||
AutismClientMessaging.sendPrefixed("Rev sync: " + preGenerated.size() + " pkts sent");
|
AutismClientMessaging.sendPrefixed("Rev sync: " + preGenerated.size() + " pkts sent");
|
||||||
}
|
}
|
||||||
} else if (action instanceof ServerTickSyncAction stsa) {
|
} else if (action instanceof ServerTickSyncAction stsa) {
|
||||||
|
|
@ -474,9 +474,9 @@ final class MacroDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MacroExecutor.isCurrentRunActive()) {
|
if (MacroExecutor.isCurrentRunActive()) {
|
||||||
MacroExecutor.executePreGeneratedBurst(mc, preGenerated);
|
MacroRender.executePreGeneratedBurst(mc, preGenerated);
|
||||||
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
MacroExecutor.RepeatPacketContext context = MacroExecutor.REPEAT_PACKET_CONTEXT.get();
|
||||||
if (context != null) MacroExecutor.REPEAT_PACKET_SKIP.set(MacroExecutor.countPreGeneratedActions(context.macro(), context.startIdx(), preGenerated.size(), context.endIdx()));
|
if (context != null) MacroExecutor.REPEAT_PACKET_SKIP.set(MacroRender.countPreGeneratedActions(context.macro(), context.startIdx(), preGenerated.size(), context.endIdx()));
|
||||||
long actualDelay = (System.nanoTime() - optimalTime) / 1_000_000L;
|
long actualDelay = (System.nanoTime() - optimalTime) / 1_000_000L;
|
||||||
AutismClientMessaging.sendPrefixed("ServerSync: " + preGenerated.size() + " pkts (+" + actualDelay + "ms)");
|
AutismClientMessaging.sendPrefixed("ServerSync: " + preGenerated.size() + " pkts (+" + actualDelay + "ms)");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,12 +135,12 @@ public class MacroExecutor {
|
||||||
private static volatile CompletableFuture<Void> activeBaritoneGoalFuture = null;
|
private static volatile CompletableFuture<Void> activeBaritoneGoalFuture = null;
|
||||||
static final AtomicReference<RunState> BARITONE_OWNER = new AtomicReference<>();
|
static final AtomicReference<RunState> BARITONE_OWNER = new AtomicReference<>();
|
||||||
|
|
||||||
private static final AtomicBoolean isRotating = new AtomicBoolean(false);
|
static final AtomicBoolean isRotating = new AtomicBoolean(false);
|
||||||
private static final AtomicReference<RunState> ROTATION_OWNER = new AtomicReference<>();
|
static final AtomicReference<RunState> ROTATION_OWNER = new AtomicReference<>();
|
||||||
private static final Object ROTATION_STATE_LOCK = new Object();
|
static final Object ROTATION_STATE_LOCK = new Object();
|
||||||
private static volatile float targetYaw, targetPitch;
|
static volatile float targetYaw, targetPitch;
|
||||||
private static volatile double rotationSpeed;
|
static volatile double rotationSpeed;
|
||||||
private static volatile int rotationAlignedFrames;
|
static volatile int rotationAlignedFrames;
|
||||||
|
|
||||||
private static final java.util.concurrent.CopyOnWriteArrayList<MacroAction> persistentActions =
|
private static final java.util.concurrent.CopyOnWriteArrayList<MacroAction> persistentActions =
|
||||||
new java.util.concurrent.CopyOnWriteArrayList<>();
|
new java.util.concurrent.CopyOnWriteArrayList<>();
|
||||||
|
|
@ -659,7 +659,7 @@ public class MacroExecutor {
|
||||||
PacketGateManager.clearOwnerAndFlushConfigured(run.id, mc == null ? null : mc.getConnection());
|
PacketGateManager.clearOwnerAndFlushConfigured(run.id, mc == null ? null : mc.getConnection());
|
||||||
FpsLimitController.clear(run.id);
|
FpsLimitController.clear(run.id);
|
||||||
PingSpoofController.clearMacro(run.id);
|
PingSpoofController.clearMacro(run.id);
|
||||||
cancelRotation(run);
|
MacroRender.cancelRotation(run);
|
||||||
MacroWorldActions.requestOwnedBaritoneStop(run, mc);
|
MacroWorldActions.requestOwnedBaritoneStop(run, mc);
|
||||||
Thread thread = run.macroThread;
|
Thread thread = run.macroThread;
|
||||||
if (interruptThread && thread != null && thread != Thread.currentThread()) {
|
if (interruptThread && thread != null && thread != Thread.currentThread()) {
|
||||||
|
|
@ -1207,251 +1207,15 @@ public class MacroExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onRender(float tickDelta) {
|
public static void onRender(float tickDelta) {
|
||||||
if (!isRotating.get()) return;
|
MacroRender.onRender(tickDelta);
|
||||||
RunState owner = ROTATION_OWNER.get();
|
|
||||||
if (owner != null && !owner.running.get()) {
|
|
||||||
cancelRotation(owner);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (owner == null && !isRunning.get()) {
|
|
||||||
synchronized (ROTATION_STATE_LOCK) {
|
|
||||||
if (ROTATION_OWNER.get() == null) isRotating.set(false);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
if (mc.player == null) return;
|
|
||||||
|
|
||||||
float currentYaw = mc.player.getYRot();
|
|
||||||
float currentPitch = mc.player.getXRot();
|
|
||||||
|
|
||||||
double deltaYaw = net.minecraft.util.Mth.wrapDegrees(targetYaw - currentYaw);
|
|
||||||
double deltaPitch = targetPitch - currentPitch;
|
|
||||||
double diagonalDistance = Math.hypot(deltaYaw, deltaPitch);
|
|
||||||
if (diagonalDistance <= 0.35) {
|
|
||||||
mc.player.setYRot(targetYaw);
|
|
||||||
mc.player.setXRot(targetPitch);
|
|
||||||
rotationAlignedFrames++;
|
|
||||||
if (rotationAlignedFrames >= 2) {
|
|
||||||
synchronized (ROTATION_STATE_LOCK) {
|
|
||||||
if (ROTATION_OWNER.get() == owner) {
|
|
||||||
isRotating.set(false);
|
|
||||||
ROTATION_OWNER.set(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rotationAlignedFrames = 0;
|
|
||||||
|
|
||||||
double frameStep = Math.min(diagonalDistance, rotationSpeed * Math.max(tickDelta, 1.0f));
|
|
||||||
double stepYaw = (deltaYaw / diagonalDistance) * frameStep;
|
|
||||||
double stepPitch = (deltaPitch / diagonalDistance) * frameStep;
|
|
||||||
|
|
||||||
mc.player.setYRot(currentYaw + (float) stepYaw);
|
|
||||||
mc.player.setXRot(currentPitch + (float) stepPitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasRenderWork() {
|
public static boolean hasRenderWork() {
|
||||||
return isRotating.get();
|
return MacroRender.hasRenderWork();
|
||||||
}
|
|
||||||
|
|
||||||
static void startSmoothRotation(float yaw, float pitch, double speed) {
|
|
||||||
RunState run = CURRENT_RUN.get();
|
|
||||||
while (run != null && run.running.get()) {
|
|
||||||
synchronized (ROTATION_STATE_LOCK) {
|
|
||||||
RunState owner = ROTATION_OWNER.get();
|
|
||||||
if (owner == null || owner == run || !owner.running.get()) {
|
|
||||||
ROTATION_OWNER.set(run);
|
|
||||||
targetYaw = yaw;
|
|
||||||
targetPitch = pitch;
|
|
||||||
rotationSpeed = speed;
|
|
||||||
rotationAlignedFrames = 0;
|
|
||||||
isRotating.set(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
java.util.concurrent.locks.LockSupport.parkNanos(MACRO_WAIT_POLL_NANOS);
|
|
||||||
}
|
|
||||||
if (run == null) {
|
|
||||||
synchronized (ROTATION_STATE_LOCK) {
|
|
||||||
if (ROTATION_OWNER.get() != null) return;
|
|
||||||
targetYaw = yaw;
|
|
||||||
targetPitch = pitch;
|
|
||||||
rotationSpeed = speed;
|
|
||||||
rotationAlignedFrames = 0;
|
|
||||||
isRotating.set(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void waitForSmoothRotationCompletion() {
|
|
||||||
RunState run = CURRENT_RUN.get();
|
|
||||||
while (isCurrentRunActive() && isRotating.get()
|
|
||||||
&& (run == null || ROTATION_OWNER.get() == run)) {
|
|
||||||
java.util.concurrent.locks.LockSupport.parkNanos(1_000_000L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cancelRotation(RunState run) {
|
|
||||||
if (run == null) return;
|
|
||||||
synchronized (ROTATION_STATE_LOCK) {
|
|
||||||
if (ROTATION_OWNER.get() != run) return;
|
|
||||||
isRotating.set(false);
|
|
||||||
rotationAlignedFrames = 0;
|
|
||||||
ROTATION_OWNER.set(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static LookAtBlockAction.RotationTarget resolveLookAtTargetOnClient(Minecraft mc, LookAtBlockAction action) {
|
|
||||||
if (mc == null || action == null) return null;
|
|
||||||
java.util.concurrent.atomic.AtomicReference<LookAtBlockAction.RotationTarget> targetRef = new java.util.concurrent.atomic.AtomicReference<>();
|
|
||||||
java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1);
|
|
||||||
mc.execute(() -> {
|
|
||||||
try {
|
|
||||||
targetRef.set(action.resolveRotationTarget(mc));
|
|
||||||
} finally {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
while (isCurrentRunActive()) {
|
|
||||||
try {
|
|
||||||
if (latch.await(10, java.util.concurrent.TimeUnit.MILLISECONDS)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return targetRef.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopAll() {
|
public static void stopAll() {
|
||||||
stop();
|
MacroRender.stopAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void executeBurstPackets(Minecraft mc, java.util.List<SendPacketAction> batch) {
|
|
||||||
if (mc.getConnection() == null) {
|
|
||||||
AutismClientMessaging.sendPrefixed("\u00a7cNo network connection for burst!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
java.util.List<autismclient.util.AutismSharedState.QueuedPacket> allQueuedPackets = new java.util.ArrayList<>();
|
|
||||||
for (SendPacketAction action : batch) {
|
|
||||||
allQueuedPackets.addAll(action.getPackets());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allQueuedPackets.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
java.util.List<Packet<?>> regeneratedPackets = new java.util.ArrayList<>(allQueuedPackets.size());
|
|
||||||
for (autismclient.util.AutismSharedState.QueuedPacket qp : allQueuedPackets) {
|
|
||||||
if (qp.packet == null) continue;
|
|
||||||
regeneratedPackets.add(qp.packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regeneratedPackets.isEmpty()) {
|
|
||||||
AutismClientMessaging.sendPrefixed("\u00a7cBurst: All packets failed to regenerate!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
net.minecraft.client.multiplayer.ClientPacketListener handler = mc.getConnection();
|
|
||||||
|
|
||||||
for (Packet<?> packet : regeneratedPackets) {
|
|
||||||
Packet<?> toSend = packet;
|
|
||||||
|
|
||||||
if (packet instanceof ServerboundContainerClickPacket) {
|
|
||||||
toSend = PacketRegenerator.regenerate(packet);
|
|
||||||
if (toSend == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handler.send(toSend);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regeneratedPackets.size() > 1) {
|
|
||||||
AutismClientMessaging.sendPrefixed("\u00a7a Burst sent " + regeneratedPackets.size() + " packets");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static java.util.List<Packet<?>> preGeneratePackets(AutismMacro macro, int startIdx, int count) {
|
|
||||||
java.util.List<Packet<?>> result = new java.util.ArrayList<>();
|
|
||||||
int maxIdx = count < 0 ? macro.actions.size() : Math.min(startIdx + count, macro.actions.size());
|
|
||||||
return preGeneratePackets(macro, startIdx, count, maxIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static java.util.List<Packet<?>> preGeneratePackets(AutismMacro macro, int startIdx, int count, int endIdx) {
|
|
||||||
java.util.List<Packet<?>> result = new java.util.ArrayList<>();
|
|
||||||
int maxIdx = Math.min(endIdx, count < 0 ? macro.actions.size() : Math.min(startIdx + count, macro.actions.size()));
|
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
|
|
||||||
for (int j = startIdx; j < maxIdx; j++) {
|
|
||||||
MacroAction act = macro.actions.get(j);
|
|
||||||
if (!(act instanceof SendPacketAction)) break;
|
|
||||||
|
|
||||||
SendPacketAction spa = (SendPacketAction) act;
|
|
||||||
for (autismclient.util.AutismSharedState.QueuedPacket qp : spa.getPackets()) {
|
|
||||||
if (qp.packet == null) continue;
|
|
||||||
|
|
||||||
result.add(qp.packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void executePreGeneratedBurst(Minecraft mc, java.util.List<Packet<?>> packets) {
|
|
||||||
if (packets.isEmpty() || mc.getConnection() == null) return;
|
|
||||||
|
|
||||||
net.minecraft.client.multiplayer.ClientPacketListener handler = mc.getConnection();
|
|
||||||
|
|
||||||
for (Packet<?> p : packets) {
|
|
||||||
Packet<?> toSend = p;
|
|
||||||
|
|
||||||
if (p instanceof ServerboundContainerClickPacket) {
|
|
||||||
toSend = PacketRegenerator.regenerate(p);
|
|
||||||
if (toSend == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handler.send(toSend);
|
|
||||||
}
|
|
||||||
|
|
||||||
AutismModule module = AutismModule.get();
|
|
||||||
if (module.shouldForceChannelFlush()) {
|
|
||||||
try {
|
|
||||||
net.minecraft.network.Connection connection = handler.getConnection();
|
|
||||||
if (connection != null) {
|
|
||||||
|
|
||||||
connection.flushChannel();
|
|
||||||
}
|
|
||||||
} catch (Exception e) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int countPreGeneratedActions(AutismMacro macro, int startIdx, int packetCount) {
|
|
||||||
return countPreGeneratedActions(macro, startIdx, packetCount, macro.actions.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
static int countPreGeneratedActions(AutismMacro macro, int startIdx, int packetCount, int endIdx) {
|
|
||||||
int actionsToSkip = 0;
|
|
||||||
int packetsRemaining = packetCount;
|
|
||||||
|
|
||||||
for (int j = startIdx; j < endIdx && packetsRemaining > 0; j++) {
|
|
||||||
MacroAction act = macro.actions.get(j);
|
|
||||||
if (!(act instanceof SendPacketAction)) break;
|
|
||||||
|
|
||||||
SendPacketAction spa = (SendPacketAction) act;
|
|
||||||
int actionPackets = spa.getPackets().size();
|
|
||||||
packetsRemaining -= actionPackets;
|
|
||||||
actionsToSkip++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return actionsToSkip;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
262
src/main/java/autismclient/util/macro/MacroRender.java
Normal file
262
src/main/java/autismclient/util/macro/MacroRender.java
Normal file
|
|
@ -0,0 +1,262 @@
|
||||||
|
package autismclient.util.macro;
|
||||||
|
|
||||||
|
import autismclient.modules.AutismModule;
|
||||||
|
import autismclient.util.AutismClientMessaging;
|
||||||
|
import autismclient.util.AutismMacro;
|
||||||
|
import autismclient.util.PacketRegenerator;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||||
|
|
||||||
|
final class MacroRender {
|
||||||
|
private MacroRender() {
|
||||||
|
}
|
||||||
|
public static void onRender(float tickDelta) {
|
||||||
|
if (!MacroExecutor.isRotating.get()) return;
|
||||||
|
MacroExecutor.RunState owner = MacroExecutor.ROTATION_OWNER.get();
|
||||||
|
if (owner != null && !owner.running.get()) {
|
||||||
|
cancelRotation(owner);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (owner == null && !MacroExecutor.isRunning.get()) {
|
||||||
|
synchronized (MacroExecutor.ROTATION_STATE_LOCK) {
|
||||||
|
if (MacroExecutor.ROTATION_OWNER.get() == null) MacroExecutor.isRotating.set(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
if (mc.player == null) return;
|
||||||
|
|
||||||
|
float currentYaw = mc.player.getYRot();
|
||||||
|
float currentPitch = mc.player.getXRot();
|
||||||
|
|
||||||
|
double deltaYaw = net.minecraft.util.Mth.wrapDegrees(MacroExecutor.targetYaw - currentYaw);
|
||||||
|
double deltaPitch = MacroExecutor.targetPitch - currentPitch;
|
||||||
|
double diagonalDistance = Math.hypot(deltaYaw, deltaPitch);
|
||||||
|
if (diagonalDistance <= 0.35) {
|
||||||
|
mc.player.setYRot(MacroExecutor.targetYaw);
|
||||||
|
mc.player.setXRot(MacroExecutor.targetPitch);
|
||||||
|
MacroExecutor.rotationAlignedFrames++;
|
||||||
|
if (MacroExecutor.rotationAlignedFrames >= 2) {
|
||||||
|
synchronized (MacroExecutor.ROTATION_STATE_LOCK) {
|
||||||
|
if (MacroExecutor.ROTATION_OWNER.get() == owner) {
|
||||||
|
MacroExecutor.isRotating.set(false);
|
||||||
|
MacroExecutor.ROTATION_OWNER.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MacroExecutor.rotationAlignedFrames = 0;
|
||||||
|
|
||||||
|
double frameStep = Math.min(diagonalDistance, MacroExecutor.rotationSpeed * Math.max(tickDelta, 1.0f));
|
||||||
|
double stepYaw = (deltaYaw / diagonalDistance) * frameStep;
|
||||||
|
double stepPitch = (deltaPitch / diagonalDistance) * frameStep;
|
||||||
|
|
||||||
|
mc.player.setYRot(currentYaw + (float) stepYaw);
|
||||||
|
mc.player.setXRot(currentPitch + (float) stepPitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasRenderWork() {
|
||||||
|
return MacroExecutor.isRotating.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void startSmoothRotation(float yaw, float pitch, double speed) {
|
||||||
|
MacroExecutor.RunState run = MacroExecutor.CURRENT_RUN.get();
|
||||||
|
while (run != null && run.running.get()) {
|
||||||
|
synchronized (MacroExecutor.ROTATION_STATE_LOCK) {
|
||||||
|
MacroExecutor.RunState owner = MacroExecutor.ROTATION_OWNER.get();
|
||||||
|
if (owner == null || owner == run || !owner.running.get()) {
|
||||||
|
MacroExecutor.ROTATION_OWNER.set(run);
|
||||||
|
MacroExecutor.targetYaw = yaw;
|
||||||
|
MacroExecutor.targetPitch = pitch;
|
||||||
|
MacroExecutor.rotationSpeed = speed;
|
||||||
|
MacroExecutor.rotationAlignedFrames = 0;
|
||||||
|
MacroExecutor.isRotating.set(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
java.util.concurrent.locks.LockSupport.parkNanos(MacroExecutor.MACRO_WAIT_POLL_NANOS);
|
||||||
|
}
|
||||||
|
if (run == null) {
|
||||||
|
synchronized (MacroExecutor.ROTATION_STATE_LOCK) {
|
||||||
|
if (MacroExecutor.ROTATION_OWNER.get() != null) return;
|
||||||
|
MacroExecutor.targetYaw = yaw;
|
||||||
|
MacroExecutor.targetPitch = pitch;
|
||||||
|
MacroExecutor.rotationSpeed = speed;
|
||||||
|
MacroExecutor.rotationAlignedFrames = 0;
|
||||||
|
MacroExecutor.isRotating.set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void waitForSmoothRotationCompletion() {
|
||||||
|
MacroExecutor.RunState run = MacroExecutor.CURRENT_RUN.get();
|
||||||
|
while (MacroExecutor.isCurrentRunActive() && MacroExecutor.isRotating.get()
|
||||||
|
&& (run == null || MacroExecutor.ROTATION_OWNER.get() == run)) {
|
||||||
|
java.util.concurrent.locks.LockSupport.parkNanos(1_000_000L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cancelRotation(MacroExecutor.RunState run) {
|
||||||
|
if (run == null) return;
|
||||||
|
synchronized (MacroExecutor.ROTATION_STATE_LOCK) {
|
||||||
|
if (MacroExecutor.ROTATION_OWNER.get() != run) return;
|
||||||
|
MacroExecutor.isRotating.set(false);
|
||||||
|
MacroExecutor.rotationAlignedFrames = 0;
|
||||||
|
MacroExecutor.ROTATION_OWNER.set(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static LookAtBlockAction.RotationTarget resolveLookAtTargetOnClient(Minecraft mc, LookAtBlockAction action) {
|
||||||
|
if (mc == null || action == null) return null;
|
||||||
|
java.util.concurrent.atomic.AtomicReference<LookAtBlockAction.RotationTarget> targetRef = new java.util.concurrent.atomic.AtomicReference<>();
|
||||||
|
java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(1);
|
||||||
|
mc.execute(() -> {
|
||||||
|
try {
|
||||||
|
targetRef.set(action.resolveRotationTarget(mc));
|
||||||
|
} finally {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
while (MacroExecutor.isCurrentRunActive()) {
|
||||||
|
try {
|
||||||
|
if (latch.await(10, java.util.concurrent.TimeUnit.MILLISECONDS)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return targetRef.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stopAll() {
|
||||||
|
MacroExecutor.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void executeBurstPackets(Minecraft mc, java.util.List<SendPacketAction> batch) {
|
||||||
|
if (mc.getConnection() == null) {
|
||||||
|
AutismClientMessaging.sendPrefixed("\u00a7cNo network connection for burst!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
java.util.List<autismclient.util.AutismSharedState.QueuedPacket> allQueuedPackets = new java.util.ArrayList<>();
|
||||||
|
for (SendPacketAction action : batch) {
|
||||||
|
allQueuedPackets.addAll(action.getPackets());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allQueuedPackets.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
java.util.List<Packet<?>> regeneratedPackets = new java.util.ArrayList<>(allQueuedPackets.size());
|
||||||
|
for (autismclient.util.AutismSharedState.QueuedPacket qp : allQueuedPackets) {
|
||||||
|
if (qp.packet == null) continue;
|
||||||
|
regeneratedPackets.add(qp.packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regeneratedPackets.isEmpty()) {
|
||||||
|
AutismClientMessaging.sendPrefixed("\u00a7cBurst: All packets failed to regenerate!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
net.minecraft.client.multiplayer.ClientPacketListener handler = mc.getConnection();
|
||||||
|
|
||||||
|
for (Packet<?> packet : regeneratedPackets) {
|
||||||
|
Packet<?> toSend = packet;
|
||||||
|
|
||||||
|
if (packet instanceof ServerboundContainerClickPacket) {
|
||||||
|
toSend = PacketRegenerator.regenerate(packet);
|
||||||
|
if (toSend == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.send(toSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regeneratedPackets.size() > 1) {
|
||||||
|
AutismClientMessaging.sendPrefixed("\u00a7a Burst sent " + regeneratedPackets.size() + " packets");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static java.util.List<Packet<?>> preGeneratePackets(AutismMacro macro, int startIdx, int count) {
|
||||||
|
java.util.List<Packet<?>> result = new java.util.ArrayList<>();
|
||||||
|
int maxIdx = count < 0 ? macro.actions.size() : Math.min(startIdx + count, macro.actions.size());
|
||||||
|
return preGeneratePackets(macro, startIdx, count, maxIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static java.util.List<Packet<?>> preGeneratePackets(AutismMacro macro, int startIdx, int count, int endIdx) {
|
||||||
|
java.util.List<Packet<?>> result = new java.util.ArrayList<>();
|
||||||
|
int maxIdx = Math.min(endIdx, count < 0 ? macro.actions.size() : Math.min(startIdx + count, macro.actions.size()));
|
||||||
|
|
||||||
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
|
||||||
|
for (int j = startIdx; j < maxIdx; j++) {
|
||||||
|
MacroAction act = macro.actions.get(j);
|
||||||
|
if (!(act instanceof SendPacketAction)) break;
|
||||||
|
|
||||||
|
SendPacketAction spa = (SendPacketAction) act;
|
||||||
|
for (autismclient.util.AutismSharedState.QueuedPacket qp : spa.getPackets()) {
|
||||||
|
if (qp.packet == null) continue;
|
||||||
|
|
||||||
|
result.add(qp.packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void executePreGeneratedBurst(Minecraft mc, java.util.List<Packet<?>> packets) {
|
||||||
|
if (packets.isEmpty() || mc.getConnection() == null) return;
|
||||||
|
|
||||||
|
net.minecraft.client.multiplayer.ClientPacketListener handler = mc.getConnection();
|
||||||
|
|
||||||
|
for (Packet<?> p : packets) {
|
||||||
|
Packet<?> toSend = p;
|
||||||
|
|
||||||
|
if (p instanceof ServerboundContainerClickPacket) {
|
||||||
|
toSend = PacketRegenerator.regenerate(p);
|
||||||
|
if (toSend == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.send(toSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
AutismModule module = AutismModule.get();
|
||||||
|
if (module.shouldForceChannelFlush()) {
|
||||||
|
try {
|
||||||
|
net.minecraft.network.Connection connection = handler.getConnection();
|
||||||
|
if (connection != null) {
|
||||||
|
|
||||||
|
connection.flushChannel();
|
||||||
|
}
|
||||||
|
} catch (Exception e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int countPreGeneratedActions(AutismMacro macro, int startIdx, int packetCount) {
|
||||||
|
return countPreGeneratedActions(macro, startIdx, packetCount, macro.actions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
static int countPreGeneratedActions(AutismMacro macro, int startIdx, int packetCount, int endIdx) {
|
||||||
|
int actionsToSkip = 0;
|
||||||
|
int packetsRemaining = packetCount;
|
||||||
|
|
||||||
|
for (int j = startIdx; j < endIdx && packetsRemaining > 0; j++) {
|
||||||
|
MacroAction act = macro.actions.get(j);
|
||||||
|
if (!(act instanceof SendPacketAction)) break;
|
||||||
|
|
||||||
|
SendPacketAction spa = (SendPacketAction) act;
|
||||||
|
int actionPackets = spa.getPackets().size();
|
||||||
|
packetsRemaining -= actionPackets;
|
||||||
|
actionsToSkip++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsToSkip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -214,7 +214,7 @@ final class MacroRunLoop {
|
||||||
batchEnd++;
|
batchEnd++;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroExecutor.executeBurstPackets(mc, packetBatch);
|
MacroRender.executeBurstPackets(mc, packetBatch);
|
||||||
|
|
||||||
i = batchEnd - 1;
|
i = batchEnd - 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -577,14 +577,14 @@ final class MacroRunLoop {
|
||||||
}
|
}
|
||||||
else if (action instanceof LookAtBlockAction) {
|
else if (action instanceof LookAtBlockAction) {
|
||||||
LookAtBlockAction la = (LookAtBlockAction) action;
|
LookAtBlockAction la = (LookAtBlockAction) action;
|
||||||
LookAtBlockAction.RotationTarget rotationTarget = MacroExecutor.resolveLookAtTargetOnClient(mc, la);
|
LookAtBlockAction.RotationTarget rotationTarget = MacroRender.resolveLookAtTargetOnClient(mc, la);
|
||||||
if (rotationTarget == null) {
|
if (rotationTarget == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (la.smooth) {
|
if (la.smooth) {
|
||||||
MacroExecutor.startSmoothRotation(rotationTarget.yaw(), rotationTarget.pitch(), la.getRotationStep());
|
MacroRender.startSmoothRotation(rotationTarget.yaw(), rotationTarget.pitch(), la.getRotationStep());
|
||||||
if (la.waitForCompletion) {
|
if (la.waitForCompletion) {
|
||||||
MacroExecutor.waitForSmoothRotationCompletion();
|
MacroRender.waitForSmoothRotationCompletion();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mc.execute(() -> {
|
mc.execute(() -> {
|
||||||
|
|
@ -752,7 +752,7 @@ final class MacroRunLoop {
|
||||||
if (mc.level == null) continue;
|
if (mc.level == null) continue;
|
||||||
|
|
||||||
java.util.List<net.minecraft.network.protocol.Packet<?>> preGenerated =
|
java.util.List<net.minecraft.network.protocol.Packet<?>> preGenerated =
|
||||||
MacroExecutor.preGeneratePackets(macro, i + 1, tsa.preGenCount);
|
MacroRender.preGeneratePackets(macro, i + 1, tsa.preGenCount);
|
||||||
|
|
||||||
long targetTick = mc.level.getGameTime() + tsa.tickOffset;
|
long targetTick = mc.level.getGameTime() + tsa.tickOffset;
|
||||||
MacroExecutor.setCurrentStatus("Tick Sync -> " + targetTick + " (" + preGenerated.size() + " pkts)");
|
MacroExecutor.setCurrentStatus("Tick Sync -> " + targetTick + " (" + preGenerated.size() + " pkts)");
|
||||||
|
|
@ -762,8 +762,8 @@ final class MacroRunLoop {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MacroExecutor.isCurrentRunActive()) {
|
if (MacroExecutor.isCurrentRunActive()) {
|
||||||
MacroExecutor.executePreGeneratedBurst(mc, preGenerated);
|
MacroRender.executePreGeneratedBurst(mc, preGenerated);
|
||||||
i += MacroExecutor.countPreGeneratedActions(macro, i + 1, preGenerated.size());
|
i += MacroRender.countPreGeneratedActions(macro, i + 1, preGenerated.size());
|
||||||
AutismClientMessaging.sendPrefixed("Tick sync: " + preGenerated.size() + " pkts sent");
|
AutismClientMessaging.sendPrefixed("Tick sync: " + preGenerated.size() + " pkts sent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -773,7 +773,7 @@ final class MacroRunLoop {
|
||||||
if (mc.player == null || mc.player.containerMenu == null) continue;
|
if (mc.player == null || mc.player.containerMenu == null) continue;
|
||||||
|
|
||||||
java.util.List<net.minecraft.network.protocol.Packet<?>> preGenerated =
|
java.util.List<net.minecraft.network.protocol.Packet<?>> preGenerated =
|
||||||
MacroExecutor.preGeneratePackets(macro, i + 1, rsa.preGenCount);
|
MacroRender.preGeneratePackets(macro, i + 1, rsa.preGenCount);
|
||||||
|
|
||||||
int baseRevision = mc.player.containerMenu.getStateId();
|
int baseRevision = mc.player.containerMenu.getStateId();
|
||||||
int targetRevision = baseRevision + rsa.revisionOffset;
|
int targetRevision = baseRevision + rsa.revisionOffset;
|
||||||
|
|
@ -786,8 +786,8 @@ final class MacroRunLoop {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MacroExecutor.isCurrentRunActive() && mc.player != null && mc.player.containerMenu != null) {
|
if (MacroExecutor.isCurrentRunActive() && mc.player != null && mc.player.containerMenu != null) {
|
||||||
MacroExecutor.executePreGeneratedBurst(mc, preGenerated);
|
MacroRender.executePreGeneratedBurst(mc, preGenerated);
|
||||||
i += MacroExecutor.countPreGeneratedActions(macro, i + 1, preGenerated.size());
|
i += MacroRender.countPreGeneratedActions(macro, i + 1, preGenerated.size());
|
||||||
AutismClientMessaging.sendPrefixed("Rev sync: " + preGenerated.size() + " pkts sent");
|
AutismClientMessaging.sendPrefixed("Rev sync: " + preGenerated.size() + " pkts sent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -797,7 +797,7 @@ final class MacroRunLoop {
|
||||||
if (mc.getConnection() == null) continue;
|
if (mc.getConnection() == null) continue;
|
||||||
|
|
||||||
java.util.List<net.minecraft.network.protocol.Packet<?>> preGenerated =
|
java.util.List<net.minecraft.network.protocol.Packet<?>> preGenerated =
|
||||||
MacroExecutor.preGeneratePackets(macro, i + 1, stsa.preGenCount);
|
MacroRender.preGeneratePackets(macro, i + 1, stsa.preGenCount);
|
||||||
|
|
||||||
int sampleWaitMs = 0;
|
int sampleWaitMs = 0;
|
||||||
while (MacroExecutor.isCurrentRunActive() && !ServerTickTracker.isReady() && sampleWaitMs < stsa.maxWaitMs) {
|
while (MacroExecutor.isCurrentRunActive() && !ServerTickTracker.isReady() && sampleWaitMs < stsa.maxWaitMs) {
|
||||||
|
|
@ -834,8 +834,8 @@ final class MacroRunLoop {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MacroExecutor.isCurrentRunActive()) {
|
if (MacroExecutor.isCurrentRunActive()) {
|
||||||
MacroExecutor.executePreGeneratedBurst(mc, preGenerated);
|
MacroRender.executePreGeneratedBurst(mc, preGenerated);
|
||||||
i += MacroExecutor.countPreGeneratedActions(macro, i + 1, preGenerated.size());
|
i += MacroRender.countPreGeneratedActions(macro, i + 1, preGenerated.size());
|
||||||
long actualDelay = (System.nanoTime() - optimalTime) / 1_000_000L;
|
long actualDelay = (System.nanoTime() - optimalTime) / 1_000_000L;
|
||||||
AutismClientMessaging.sendPrefixed("ServerSync: " + preGenerated.size() + " pkts (+" + actualDelay + "ms)");
|
AutismClientMessaging.sendPrefixed("ServerSync: " + preGenerated.size() + " pkts (+" + actualDelay + "ms)");
|
||||||
}
|
}
|
||||||
|
|
@ -843,9 +843,9 @@ final class MacroRunLoop {
|
||||||
else if (action instanceof RotateAction) {
|
else if (action instanceof RotateAction) {
|
||||||
RotateAction ra = (RotateAction) action;
|
RotateAction ra = (RotateAction) action;
|
||||||
if (ra.smooth) {
|
if (ra.smooth) {
|
||||||
MacroExecutor.startSmoothRotation(ra.yaw, ra.pitch, ra.getRotationStep());
|
MacroRender.startSmoothRotation(ra.yaw, ra.pitch, ra.getRotationStep());
|
||||||
if (ra.waitForCompletion) {
|
if (ra.waitForCompletion) {
|
||||||
MacroExecutor.waitForSmoothRotationCompletion();
|
MacroRender.waitForSmoothRotationCompletion();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mc.execute(() -> action.execute(mc));
|
mc.execute(() -> action.execute(mc));
|
||||||
|
|
@ -855,14 +855,14 @@ final class MacroRunLoop {
|
||||||
runPacedTpAction(mc, pacedTp);
|
runPacedTpAction(mc, pacedTp);
|
||||||
}
|
}
|
||||||
else if (action instanceof LookAtBlockAction la) {
|
else if (action instanceof LookAtBlockAction la) {
|
||||||
LookAtBlockAction.RotationTarget rotationTarget = MacroExecutor.resolveLookAtTargetOnClient(mc, la);
|
LookAtBlockAction.RotationTarget rotationTarget = MacroRender.resolveLookAtTargetOnClient(mc, la);
|
||||||
if (rotationTarget == null) {
|
if (rotationTarget == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (la.smooth) {
|
if (la.smooth) {
|
||||||
MacroExecutor.startSmoothRotation(rotationTarget.yaw(), rotationTarget.pitch(), la.getRotationStep());
|
MacroRender.startSmoothRotation(rotationTarget.yaw(), rotationTarget.pitch(), la.getRotationStep());
|
||||||
if (la.waitForCompletion) {
|
if (la.waitForCompletion) {
|
||||||
MacroExecutor.waitForSmoothRotationCompletion();
|
MacroRender.waitForSmoothRotationCompletion();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mc.execute(() -> {
|
mc.execute(() -> {
|
||||||
|
|
@ -1159,7 +1159,7 @@ final class MacroRunLoop {
|
||||||
}
|
}
|
||||||
PacketGateManager.clearOwnerAndFlushConfigured(runState.id, mc == null ? null : mc.getConnection());
|
PacketGateManager.clearOwnerAndFlushConfigured(runState.id, mc == null ? null : mc.getConnection());
|
||||||
MacroExecutor.finishCurrentRun();
|
MacroExecutor.finishCurrentRun();
|
||||||
MacroExecutor.cancelRotation(runState);
|
MacroRender.cancelRotation(runState);
|
||||||
if (!MacroExecutor.isRunning.get()) MacroConditionRegistry.cancelAll();
|
if (!MacroExecutor.isRunning.get()) MacroConditionRegistry.cancelAll();
|
||||||
|
|
||||||
MacroExecutor.broadcastStepProgress(runState, -1, 0, "");
|
MacroExecutor.broadcastStepProgress(runState, -1, 0, "");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue