From 89c1d907429a3c0e9d168b9b8d277e8df40cc723 Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 05:55:52 +0200 Subject: [PATCH] Upload files to "src/openonyx/features/player/internal/internal" --- .../internal/internal/ScaffoldClutch.java | 56 ++++ .../internal/internal/ScaffoldClutchPart.java | 32 +++ .../internal/internal/ScaffoldPrediction.java | 103 ++++++++ .../internal/ScaffoldSprintControl.java | 240 ++++++++++++++++++ .../internal/ScaffoldSprintControlMode.java | 35 +++ 5 files changed, 466 insertions(+) create mode 100644 src/openonyx/features/player/internal/internal/ScaffoldClutch.java create mode 100644 src/openonyx/features/player/internal/internal/ScaffoldClutchPart.java create mode 100644 src/openonyx/features/player/internal/internal/ScaffoldPrediction.java create mode 100644 src/openonyx/features/player/internal/internal/ScaffoldSprintControl.java create mode 100644 src/openonyx/features/player/internal/internal/ScaffoldSprintControlMode.java diff --git a/src/openonyx/features/player/internal/internal/ScaffoldClutch.java b/src/openonyx/features/player/internal/internal/ScaffoldClutch.java new file mode 100644 index 0000000..acb459b --- /dev/null +++ b/src/openonyx/features/player/internal/internal/ScaffoldClutch.java @@ -0,0 +1,56 @@ +package openonyx.features.player.internal.internal; + +import java.util.List; +import openonyx.core.MinecraftAccess; +import openonyx.history.Setting; +import openonyx.history.SettingSection; +import openonyx.history.internal.NumberSetting; +import openonyx.protocol.RotationHandler; +import openonyx.protocol.RotationRequest; +import openonyx.protocol.group_m.Angles; +import openonyx.utilities.PlayerUtils; + +public class ScaffoldClutch extends SettingSection implements MinecraftAccess { + public static final ScaffoldClutch INSTANCE = new ScaffoldClutch(); + public NumberSetting clutchSpeed = new NumberSetting("Clutch speed", 90.0, 1.0, 180.0, 1.0) + .withSuffix("°/t") + .describe( + "How fast the aim may move while clutching a fall. Higher lands more placements but looks less like the slow rotation; lower keeps more of the slow rotation at the cost of the odd fall." + ); + public NumberSetting clutchDistance = new NumberSetting("Clutch distance", 0.2, 0.05, 0.6, 0.01) + .describe("How close to the fall-off edge the aim starts clutching. Larger engages earlier, so the aim is ready before the edge is reached."); + + public boolean L(Angles angles) { + if (!this.isEnabled() || mc.thePlayer == null || angles == null) { + return false; + } else if (!PlayerUtils.L(mc.thePlayer)) { + return false; + } else { + return !PlayerUtils.L(mc.thePlayer, this.clutchDistance.getFloat()) ? false : RotationHandler.INSTANCE.getAngles().L(angles) > 1.0F; + } + } + + private ScaffoldClutch() { + super("Clutch", true); + this.visibleWhen(Setting.BOOLEAN_SUPPLIER); + } + + public int L(Angles angles) { + return (int)Math.ceil(RotationHandler.INSTANCE.getAngles().L(angles) / Math.max(1.0F, this.clutchSpeed.getFloat())); + } + + public RotationRequest L(RotationRequest rotationRequest) { + return !this.isEnabled() + ? rotationRequest + : new RotationRequest( + rotationRequest.getAngles(), + rotationRequest.getEntity(), + List.of(new ScaffoldClutchPart(this, rotationRequest.getRotationSmoothers())), + rotationRequest.L(), + rotationRequest.L(), + rotationRequest.L(), + rotationRequest.getMovementFixMode(), + rotationRequest.getConditionalAction() + ); + } +} diff --git a/src/openonyx/features/player/internal/internal/ScaffoldClutchPart.java b/src/openonyx/features/player/internal/internal/ScaffoldClutchPart.java new file mode 100644 index 0000000..c785b2d --- /dev/null +++ b/src/openonyx/features/player/internal/internal/ScaffoldClutchPart.java @@ -0,0 +1,32 @@ +package openonyx.features.player.internal.internal; + +import java.util.Iterator; +import java.util.List; +import openonyx.protocol.RotationRequest; +import openonyx.protocol.group_m.Angles; +import openonyx.protocol.internal.internal.RotationSmoother; + +final class ScaffoldClutchPart implements RotationSmoother { + private final List rotationSmoothers; + + private ScaffoldClutchPart(ScaffoldClutch scaffoldClutch, List list) { + this.scaffoldClutch = scaffoldClutchx; + this.rotationSmoothers = list; + } + + @Override + public Angles L(RotationRequest rotationRequest, Angles angles, Angles angles1) { + if (this.scaffoldClutch.L(angles1)) { + float f = Math.min(this.scaffoldClutch.clutchSpeed.getFloat(), angles.L(angles1)); + return angles.L(angles1, f, f); + } + + Angles angles2 = angles1; + + for (Iterator iterator1 = iterator = this.rotationSmoothers.iterator(); iterator1.hasNext(); iterator1 = iterator) { + angles2 = ((RotationSmoother)iterator.next()).L(rotationRequest, angles, angles2); + } + + return angles2; + } +} diff --git a/src/openonyx/features/player/internal/internal/ScaffoldPrediction.java b/src/openonyx/features/player/internal/internal/ScaffoldPrediction.java new file mode 100644 index 0000000..944d44a --- /dev/null +++ b/src/openonyx/features/player/internal/internal/ScaffoldPrediction.java @@ -0,0 +1,103 @@ +package openonyx.features.player.internal.internal; + +import java.util.ArrayDeque; +import net.minecraft.entity.Entity; +import net.minecraft.util.Vec3; +import openonyx.core.MinecraftAccess; +import openonyx.features.player.internal.ScaffoldPathfinder; +import openonyx.features.player.internal.ScaffoldPathfinderData; +import openonyx.history.Setting; +import openonyx.history.SettingSection; +import openonyx.history.internal.NumberSetting; +import openonyx.utilities.EdgeCollision; +import openonyx.utilities.PlayerUtils; +import openonyx.utilities.VecUtils; +import openonyx.utilities.internal.Line3; + +public class ScaffoldPrediction extends SettingSection implements MinecraftAccess { + public static final ScaffoldPrediction INSTANCE = new ScaffoldPrediction(); + public NumberSetting warmupPlacements; + public NumberSetting bootstrapBackoff; + private final transient ArrayDeque vec3s = new ArrayDeque<>(5); + private static final int H = 4; + public NumberSetting predictionCutoffDistance; + + @Override + protected void d() { + this.i(); + } + + private Vec3 L(Vec3 vec3, Vec3 vec31) { + return this.bootstrapBackoff.getFloat() <= 0.0F ? vec3 : vec3.subtract(VecUtils.D(vec31, this.bootstrapBackoff.getFloat())); + } + + public Vec3 d(Line3 line3) { + ScaffoldPrediction scaffoldPrediction1 = this; + if (line3 != null && scaffoldPrediction1.isEnabled()) { + if (PlayerUtils.L(mc.thePlayer, scaffoldPrediction1.predictionCutoffDistance.getFloat())) { + return null; + } else { + Vec3 vec31; + if ((vec31 = scaffoldPrediction1.L(line3)) == null) { + return null; + } else { + Vec3 vec32 = PlayerUtils.D((Entity)mc.thePlayer); + Vec3 vec33 = vec31.subtract(vec32); + Vec3 vec34 = scaffoldPrediction1.L(vec31, vec33); + Vec3 vec3; + if ((vec3 = scaffoldPrediction1.L()) == null) { + ScaffoldPathfinderData scaffoldPathfinderData; + return (scaffoldPathfinderData = ScaffoldPathfinder.getScaffoldPathfinderData()) != null + ? vec34.add(scaffoldPathfinderData.offsetX(), 0.0, scaffoldPathfinderData.offsetZ()) + : vec34; + } else { + float f = (float)Math.atan2(line3.direction().zCoord, line3.direction().xCoord); + Vec3 vec35 = vec31.add(vec3.rotateYaw(-f)); + return vec34.lerp(vec35, scaffoldPrediction1.L()); + } + } + } + } else { + return null; + } + } + + public void L(Line3 line3, Vec3 vec3) { + if (line3 != null && this.isEnabled()) { + if (vec3 != null) { + float f = (float)Math.atan2(line3.direction().zCoord, line3.direction().xCoord); + Vec3 vec31 = PlayerUtils.D((Entity)mc.thePlayer).subtract(vec3).rotateYaw(f); + this.vec3s.addLast(vec31); + if (this.vec3s.size() > 4) { + this.vec3s.removeFirst(); + } + } + } + } + + public Vec3 L() { + return this.vec3s.isEmpty() ? null : VecUtils.L(this.vec3s); + } + + public void i() { + this.vec3s.clear(); + } + + public Vec3 L(Line3 line3) { + Vec3 vec31 = line3.L(PlayerUtils.D((Entity)mc.thePlayer)).add(0.0, -0.1, 0.0); + Vec3 vec3; + return (vec3 = EdgeCollision.L(vec31, vec31.add(VecUtils.D(line3.direction(), 3.0)))) == null ? null : VecUtils.i(vec3, mc.thePlayer.posY); + } + + private ScaffoldPrediction() { + super("Prediction", false); + this.bootstrapBackoff = new NumberSetting("Bootstrap backoff", 0.2, 0.0, 0.4, 0.01); + this.predictionCutoffDistance = new NumberSetting("Prediction cutoff distance", 0.05, 0.0, 0.3, 0.01); + this.warmupPlacements = new NumberSetting("Warmup placements", 2.0, 0.0, 4.0, 1.0); + this.visibleWhen(Setting.BOOLEAN_SUPPLIER); + } + + private double L() { + return this.warmupPlacements.getInt() <= 0 ? 1.0 : Math.clamp((double)this.vec3s.size() / this.warmupPlacements.getInt(), 0.0, 1.0); + } +} diff --git a/src/openonyx/features/player/internal/internal/ScaffoldSprintControl.java b/src/openonyx/features/player/internal/internal/ScaffoldSprintControl.java new file mode 100644 index 0000000..9e547d5 --- /dev/null +++ b/src/openonyx/features/player/internal/internal/ScaffoldSprintControl.java @@ -0,0 +1,240 @@ +package openonyx.features.player.internal.internal; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ThreadLocalRandom; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.entity.Entity; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import openonyx.configuration.internal.MovementInputEvent; +import openonyx.configuration.internal.PacketDirection; +import openonyx.configuration.internal.PacketEvent; +import openonyx.configuration.internal.PostJumpEvent; +import openonyx.configuration.internal.PreTickEvent; +import openonyx.configuration.internal.SprintEvent; +import openonyx.configuration.internal.WorldChangeEvent; +import openonyx.core.MinecraftAccess; +import openonyx.features.movement.NoSlow; +import openonyx.features.player.Scaffold; +import openonyx.features.player.internal.FeatureSupport_419; +import openonyx.history.Setting; +import openonyx.history.SettingSection; +import openonyx.history.internal.BooleanSetting; +import openonyx.history.internal.EnumSetting; +import openonyx.history.internal.NumberSetting; +import openonyx.protocol.RotationHandler; +import openonyx.protocol.RotationRequest; +import openonyx.protocol.group_d.RotationAngleMath; +import openonyx.protocol.group_m.Angles; +import openonyx.protocol.internal.MovementFixMode; +import openonyx.utilities.PlayerUtils; +import openonyx.utilities.Timer; + +public class ScaffoldSprintControl extends SettingSection implements MinecraftAccess { + private final transient Timer timer; + private final transient List packets; + private transient boolean j; + public BooleanSetting blinkJump; + public NumberSetting maxFlick; + public EnumSetting mode; + public static final ScaffoldSprintControl INSTANCE = new ScaffoldSprintControl(); + private transient boolean d; + private static final long i = 329L; + private transient boolean f; + public NumberSetting jumpForwardChance; + private final transient FeatureSupport_419 featureSupport_419; + + @EventHandler(priority = -10) + private void onSprint(SprintEvent sprintEvent) { + switch ((ScaffoldSprintControlMode)this.mode.getValue()) { + case NO_SPRINT_ON_PLACE: + default: + break; + case DO_NOT_CHANGE: + while (false) { + } + + if (sprintEvent.getMovementInputState().i()) { + sprintEvent.L(true); + return; + } + break; + case FORCE_SPRINT: + sprintEvent.L(false); + return; + case FORCE_NO_SPRINT: + if (this.d && !mc.thePlayer.willJumpThisTick()) { + sprintEvent.L(false); + return; + } + break; + case NO_SPRINT_ON_GROUND: + sprintEvent.L(!mc.thePlayer.onGround); + return; + case KEEP_Y: + if (!sprintEvent.getMovementInputState().i()) { + return; + } + + if (this.d && !mc.thePlayer.willJumpThisTick()) { + sprintEvent.L(false); + return; + } + + if (mc.thePlayer.movementInput.moveForward >= NoSlow.L()) { + sprintEvent.L(true); + return; + } + } + } + + // $VF: Could not inline inconsistent finally blocks + // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!) + private void h() { + ScaffoldSprintControl scaffoldSprintControl1 = this; + scaffoldSprintControl1.f = false; + if (!scaffoldSprintControl1.packets.isEmpty()) { + ArrayList arrayList = new ArrayList<>(scaffoldSprintControl1.packets); + scaffoldSprintControl1.packets.clear(); + if (mc.getNetHandler() != null) { + scaffoldSprintControl1.j = true; + + try { + mc.getNetHandler().getNetworkManager().sendGrouped(arrayList); + } catch (Throwable throwable) { + scaffoldSprintControl1.j = false; + throw throwable; + } + + scaffoldSprintControl1.j = false; + } + } + } + + @Override + protected void d() { + this.h(); + } + + public boolean l() { + return this.isToggled() && (this.mode.is(ScaffoldSprintControlMode.FORCE_SPRINT) || this.mode.is(ScaffoldSprintControlMode.KEEP_Y)); + } + + @Override + protected void D() { + this.d = false; + this.I(); + } + + @EventHandler(priority = -500) + private void onMovementInput(MovementInputEvent movementInputEvent) { + if (this.mode.is(ScaffoldSprintControlMode.KEEP_Y) && mc.thePlayer != null) { + if (!this.d) { + if (movementInputEvent.getMovementInputState().i()) { + if (mc.thePlayer.willJumpThisTick(movementInputEvent.D())) { + RotationRequest rotationRequest; + if ((rotationRequest = RotationHandler.INSTANCE.d()) != null && rotationRequest.getMovementFixMode() != MovementFixMode.OFF) { + if (ThreadLocalRandom.current().nextInt(100) < this.jumpForwardChance.getInt()) { + float fx = PlayerUtils.L(mc.thePlayer, movementInputEvent.getMovementInputState()); + Angles angles; + if ((angles = RotationHandler.INSTANCE.getAngles3()) == null) { + angles = PlayerUtils.L((Entity)mc.thePlayer); + } + + if (!(Math.abs(RotationAngleMath.L(fx, angles.yaw2())) > this.maxFlick.getFloat())) { + float h = (float)ThreadLocalRandom.current().nextDouble(60.0, 70.0); + float g = this.featureSupport_419.L(fx, Scaffold.INSTANCE.scaffoldRotationSettings.rotationVariance.getValue()); + RotationHandler.INSTANCE.L(new Angles(g, h).L()); + } + } + } + } + } + } + } + } + + private ScaffoldSprintControl() { + super("Sprint control", false); + ScaffoldSprintControlMode scaffoldSprintControlMode = ScaffoldSprintControlMode.DO_NOT_CHANGE; + ScaffoldSprintControlMode[] scaffoldSprintControlModes = new ScaffoldSprintControlMode[4]; + boolean bl = true; + scaffoldSprintControlModes[0] = ScaffoldSprintControlMode.DO_NOT_CHANGE; + scaffoldSprintControlModes[1] = ScaffoldSprintControlMode.FORCE_SPRINT; + scaffoldSprintControlModes[2] = ScaffoldSprintControlMode.FORCE_NO_SPRINT; + scaffoldSprintControlModes[3] = ScaffoldSprintControlMode.KEEP_Y; + this.mode = new EnumSetting<>("Mode", scaffoldSprintControlMode, scaffoldSprintControlModes); + this.jumpForwardChance = new NumberSetting("Jump forward chance", 100.0, 0.0, 100.0, 1.0) + .withSuffix("%") + .describe("Chance to redirect the sprint jump impulse along the movement direction") + .visibleWhen(() -> this.mode.is(ScaffoldSprintControlMode.KEEP_Y)); + this.maxFlick = new NumberSetting("Max flick", 75.0, 0.0, 180.0, 1.0) + .withSuffix("°") + .describe("Skips the jump-forward snap when it would flick the sent yaw further than this") + .visibleWhen(() -> this.mode.is(ScaffoldSprintControlMode.KEEP_Y)); + this.blinkJump = new BooleanSetting("Blink jump", true) + .describe("Holds outgoing packets from the jump until the next placement, so the rotation flip and the ascent arrive as one lag burst") + .visibleWhen(Setting.BOOLEAN_SUPPLIER); + this.featureSupport_419 = new FeatureSupport_419(); + this.packets = new CopyOnWriteArrayList<>(); + this.timer = new Timer(System.currentTimeMillis()); + } + + private void I() { + this.f = false; + this.j = false; + this.packets.clear(); + } + + @EventHandler + private void onPostJump(PostJumpEvent postJumpEvent) { + if (this.mode.is(ScaffoldSprintControlMode.KEEP_Y) && this.blinkJump.getValue()) { + if (mc.thePlayer != null && PlayerUtils.L(mc.thePlayer)) { + this.h(); + this.f = true; + this.timer.reset(); + } + } + } + + public void i() { + this.d = true; + } + + @EventHandler + private void onWorldChange(WorldChangeEvent worldChangeEvent) { + this.I(); + } + + @EventHandler(priority = 500) + private void onPacket(PacketEvent packetEvent) { + if (!this.j && !packetEvent.isCancelled()) { + if (packetEvent.getPacketDirection() == PacketDirection.INCOMING) { + if (packetEvent.getPacket() instanceof S08PacketPlayerPosLook) { + this.h(); + } + } else if (this.f) { + if (packetEvent.getPacket() instanceof C08PacketPlayerBlockPlacement) { + this.h(); + } else { + this.packets.add(packetEvent.getPacket()); + packetEvent.cancel(); + } + } + } + } + + @EventHandler(priority = 1000) + private void onPreTick(PreTickEvent preTickEvent) { + if (this.d) { + this.d = false; + } + + if (this.f && mc.thePlayer != null && (mc.thePlayer.onGround || this.timer.hasElapsed(329L))) { + this.h(); + } + } +} diff --git a/src/openonyx/features/player/internal/internal/ScaffoldSprintControlMode.java b/src/openonyx/features/player/internal/internal/ScaffoldSprintControlMode.java new file mode 100644 index 0000000..be52fe3 --- /dev/null +++ b/src/openonyx/features/player/internal/internal/ScaffoldSprintControlMode.java @@ -0,0 +1,35 @@ +package openonyx.features.player.internal.internal; + +import openonyx.history.DisplayNamed; + +public enum ScaffoldSprintControlMode implements DisplayNamed { + NO_SPRINT_ON_PLACE("No sprint on place"), + DO_NOT_CHANGE("Do not change"), + FORCE_SPRINT("Force sprint"), + FORCE_NO_SPRINT("Force no sprint"), + NO_SPRINT_ON_GROUND("No sprint on ground"), + KEEP_Y("Keep Y"); + + private final String l; + + private static ScaffoldSprintControlMode[] L() { + ScaffoldSprintControlMode[] scaffoldSprintControlModes = new ScaffoldSprintControlMode[6]; + boolean bl = true; + scaffoldSprintControlModes[0] = DO_NOT_CHANGE; + scaffoldSprintControlModes[1] = FORCE_SPRINT; + scaffoldSprintControlModes[2] = FORCE_NO_SPRINT; + scaffoldSprintControlModes[3] = NO_SPRINT_ON_PLACE; + scaffoldSprintControlModes[4] = NO_SPRINT_ON_GROUND; + scaffoldSprintControlModes[5] = KEEP_Y; + return scaffoldSprintControlModes; + } + + @Override + public String getDisplayName() { + return this.l; + } + + ScaffoldSprintControlMode(String string1) { + this.l = string1; + } +}