Upload files to "src/openonyx/features/player/internal/internal"

This commit is contained in:
winterflyt committed 2026-11-30 05:55:52 +02:00
1 parent f0dbd4615f
commit 89c1d90742
5 files changed
+466

No files matched your search

@@ -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()
);
}
}
@@ -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<RotationSmoother> 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;
}
}
@@ -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<Vec3> 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);
}
}
@@ -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<Packet> packets;
private transient boolean j;
public BooleanSetting blinkJump;
public NumberSetting maxFlick;
public EnumSetting<ScaffoldSprintControlMode> 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();
}
}
}
@@ -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;
}
}