Upload files to "src/openonyx/protocol"
This commit is contained in:
1 parent
6263083ef7
commit
0c381ae21e
3 files changed
+457
No files matched your search
@@ -0,0 +1,279 @@
|
||||
package openonyx.protocol;
|
||||
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.client.C03PacketPlayer;
|
||||
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
|
||||
import openonyx.configuration.internal.PacketEvent;
|
||||
import openonyx.configuration.internal.PreTickEvent;
|
||||
import openonyx.configuration.internal.RotationTickEvent;
|
||||
import openonyx.configuration.internal.StrafeEvent;
|
||||
import openonyx.core.MinecraftAccess;
|
||||
import openonyx.core.OnyxClient;
|
||||
import openonyx.events.RotationManager;
|
||||
import openonyx.protocol.group_d.RotationAngleMath;
|
||||
import openonyx.protocol.group_m.Angles;
|
||||
import openonyx.protocol.internal.MovementFixMode;
|
||||
import openonyx.utilities.ConditionalAction;
|
||||
import openonyx.utilities.ContainerTracker;
|
||||
import openonyx.utilities.ItemPriority;
|
||||
import openonyx.utilities.PlayerUtils;
|
||||
import openonyx.utilities.RequestQueue;
|
||||
import openonyx.utilities.RequestQueuePart;
|
||||
import openonyx.utilities.RotationRequester;
|
||||
|
||||
public class RotationHandler implements MinecraftAccess {
|
||||
private Angles angles;
|
||||
private final RequestQueue<RotationRequest> requestQueue = new RequestQueue<>();
|
||||
public static final RotationHandler INSTANCE = new RotationHandler();
|
||||
private Angles angles2;
|
||||
private Angles angles3;
|
||||
private Angles angles4;
|
||||
private RotationRequest rotationRequest;
|
||||
private Angles angles5;
|
||||
|
||||
public void L(Angles angles) {
|
||||
RotationHandler rotationHandler1;
|
||||
if (anglesx == null) {
|
||||
this.angles2 = null;
|
||||
rotationHandler1 = this;
|
||||
} else if (this.angles3 != null) {
|
||||
this.angles2 = this.angles3;
|
||||
rotationHandler1 = this;
|
||||
} else {
|
||||
this.angles2 = mc.thePlayer != null ? PlayerUtils.L((Entity)mc.thePlayer) : Angles.INSTANCE;
|
||||
rotationHandler1 = this;
|
||||
}
|
||||
|
||||
rotationHandler1.angles3 = anglesx;
|
||||
}
|
||||
|
||||
public Angles getAngles() {
|
||||
return this.angles;
|
||||
}
|
||||
|
||||
public boolean L(RotationRequest rotationRequest) {
|
||||
if (!this.d()) {
|
||||
return false;
|
||||
} else {
|
||||
return !rotationRequestx.L() ? true : !ContainerTracker.INSTANCE.L() && !(mc.currentScreen instanceof GuiContainer);
|
||||
}
|
||||
}
|
||||
|
||||
public RotationRequest getRotationRequest() {
|
||||
return this.rotationRequest;
|
||||
}
|
||||
|
||||
public RotationRequest d() {
|
||||
RotationHandler rotationHandler1 = this;
|
||||
RotationRequest rotationRequestx;
|
||||
return (rotationRequestx = rotationHandler1.L()) != null ? rotationRequestx : rotationHandler1.rotationRequest;
|
||||
}
|
||||
|
||||
private boolean D() {
|
||||
return mc.thePlayer != null && mc.theWorld != null;
|
||||
}
|
||||
|
||||
private RotationRequest L() {
|
||||
return this.requestQueue.L();
|
||||
}
|
||||
|
||||
public Angles getAngles5() {
|
||||
return this.angles;
|
||||
}
|
||||
|
||||
public Angles getAngles3() {
|
||||
return this.angles3;
|
||||
}
|
||||
|
||||
@EventHandler(priority = -10)
|
||||
private void onStrafe(StrafeEvent strafeEvent) {
|
||||
RotationHandler rotationHandler1 = this;
|
||||
if (rotationHandler1.D()) {
|
||||
if (!RotationManager.d()) {
|
||||
RotationRequest rotationRequestx;
|
||||
if ((rotationRequestx = rotationHandler1.d()) == null || rotationRequestx.getMovementFixMode() != MovementFixMode.OFF) {
|
||||
if (rotationHandler1.angles3 != null) {
|
||||
strafeEvent.L(PlayerUtils.L(strafeEvent.getVec32(), strafeEvent.L(), rotationHandler1.angles3.yaw2()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void L(float f) {
|
||||
RotationHandler rotationHandler1 = this;
|
||||
if (rotationHandler1.D()) {
|
||||
RotationRequest rotationRequestx;
|
||||
if ((rotationRequestx = rotationHandler1.d()) != null) {
|
||||
if (rotationHandler1.L(rotationRequestx) && rotationRequestx.getMovementFixMode() == MovementFixMode.CHANGE_LOOK) {
|
||||
if (rotationHandler1.angles4 != null && rotationHandler1.angles3 != null) {
|
||||
RotationAngleMath.L(mc.thePlayer, rotationHandler1.angles4.L(rotationHandler1.angles3, f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void L(double d, double e) {
|
||||
RotationHandler rotationHandler1 = this;
|
||||
if (rotationHandler1.D()) {
|
||||
RotationRequest rotationRequestx;
|
||||
if ((rotationRequestx = rotationHandler1.d()) != null) {
|
||||
if (rotationHandler1.L(rotationRequestx) && rotationRequestx.getMovementFixMode() == MovementFixMode.CHANGE_LOOK) {
|
||||
if (rotationHandler1.angles4 != null) {
|
||||
rotationHandler1.angles4 = RotationAngleMath.L(rotationHandler1.angles4, d, e);
|
||||
}
|
||||
|
||||
if (rotationHandler1.angles3 != null) {
|
||||
rotationHandler1.L(RotationAngleMath.L(rotationHandler1.angles3, d, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void L() {
|
||||
RotationHandler rotationHandler1 = this;
|
||||
Angles anglesx = PlayerUtils.L((Entity)mc.thePlayer);
|
||||
rotationHandler1.angles4 = anglesx;
|
||||
RotationRequest rotationRequest1;
|
||||
if ((rotationRequest1 = rotationHandler1.d()) != null) {
|
||||
RotationHandler rotationHandler2;
|
||||
label57: {
|
||||
RotationRequest rotationRequestx = rotationHandler1.L();
|
||||
if (rotationHandler1.L(rotationRequest1)) {
|
||||
Angles angles1 = rotationHandler1.angles3 != null ? rotationHandler1.angles3 : anglesx;
|
||||
angles1 = rotationRequest1.L(angles1, rotationRequestx == null).L();
|
||||
float f = angles1.L(anglesx);
|
||||
if (rotationRequestx == null
|
||||
&& (
|
||||
rotationRequest1.getMovementFixMode() == MovementFixMode.CHANGE_LOOK
|
||||
|| rotationRequest1.getRotationSmoothers().isEmpty()
|
||||
|| f <= rotationRequest1.L()
|
||||
)) {
|
||||
if (rotationHandler1.angles3 != null) {
|
||||
mc.thePlayer.rotationYaw = RotationAngleMath.L(mc.thePlayer, rotationHandler1.angles3);
|
||||
mc.thePlayer.renderArmYaw = mc.thePlayer.rotationYaw;
|
||||
mc.thePlayer.prevRenderArmYaw = mc.thePlayer.rotationYaw;
|
||||
}
|
||||
|
||||
rotationHandler2 = rotationHandler1;
|
||||
rotationHandler1.L((Angles)null);
|
||||
rotationHandler1.rotationRequest = null;
|
||||
break label57;
|
||||
}
|
||||
|
||||
rotationHandler1.L(angles1);
|
||||
rotationHandler1.rotationRequest = rotationRequest1;
|
||||
if (rotationRequestx != null && rotationRequestx.getConditionalAction() != null) {
|
||||
rotationRequestx.getConditionalAction().L();
|
||||
}
|
||||
}
|
||||
|
||||
rotationHandler2 = rotationHandler1;
|
||||
}
|
||||
|
||||
rotationHandler2.requestQueue.L();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = -1000)
|
||||
private void onPacket(PacketEvent packetEvent) {
|
||||
RotationHandler rotationHandler1 = this;
|
||||
Packet packet = packetEvent.getPacket();
|
||||
Angles anglesx;
|
||||
PacketEvent packetEvent1;
|
||||
switch (packet) {
|
||||
case C03PacketPlayer c03PacketPlayer1:
|
||||
while (false) {
|
||||
}
|
||||
|
||||
C03PacketPlayer c03PacketPlayer;
|
||||
if (!(c03PacketPlayer = (C03PacketPlayer)packet).getRotating()) {
|
||||
return;
|
||||
}
|
||||
|
||||
anglesx = new Angles(c03PacketPlayer.getYaw(), c03PacketPlayer.getPitch(), true);
|
||||
packetEvent1 = packetEvent;
|
||||
break;
|
||||
case S08PacketPlayerPosLook s08PacketPlayerPosLook:
|
||||
anglesx = new Angles(s08PacketPlayerPosLook.getYaw(), s08PacketPlayerPosLook.getPitch(), true);
|
||||
packetEvent1 = packetEvent;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packetEvent1.isCancelled()) {
|
||||
RotationManager.L((rotationHandler1.angles = anglesx).yaw2(), anglesx.pitch2());
|
||||
}
|
||||
|
||||
rotationHandler1.angles5 = anglesx;
|
||||
}
|
||||
|
||||
private RotationHandler() {
|
||||
this.angles = Angles.INSTANCE;
|
||||
this.angles5 = Angles.INSTANCE;
|
||||
}
|
||||
|
||||
public void L(
|
||||
Angles angles,
|
||||
boolean bl,
|
||||
RotationConfig rotationConfig,
|
||||
ItemPriority itemPriority,
|
||||
RotationRequester rotationRequester,
|
||||
ConditionalAction conditionalAction
|
||||
) {
|
||||
this.L(rotationConfig.L(anglesx, null, bl, conditionalAction), itemPriority, rotationRequester);
|
||||
}
|
||||
|
||||
private boolean d() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Angles getAngles4() {
|
||||
return this.angles4;
|
||||
}
|
||||
|
||||
public Angles getAngles2() {
|
||||
return this.angles2;
|
||||
}
|
||||
|
||||
public boolean L() {
|
||||
if (mc.thePlayer == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.angles3 != null ? this.angles3.equals(this.angles2) : PlayerUtils.L((Entity)mc.thePlayer).equals(PlayerUtils.d((Entity)mc.thePlayer));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = 1000)
|
||||
private void onPreTick(PreTickEvent preTickEvent) {
|
||||
if (this.D()) {
|
||||
OnyxClient.EVENT_BUS.post(new RotationTickEvent());
|
||||
this.L();
|
||||
}
|
||||
}
|
||||
|
||||
public void L(RotationRequest rotationRequest, ItemPriority itemPriority, RotationRequester rotationRequester) {
|
||||
if (this.d()) {
|
||||
RequestQueue requestQueuex = this.requestQueue;
|
||||
RequestQueuePart requestQueuePart = new RequestQueuePart;
|
||||
int i;
|
||||
ItemPriority itemPriority1;
|
||||
if (rotationRequestx.getMovementFixMode() == MovementFixMode.CHANGE_LOOK) {
|
||||
i = 1;
|
||||
itemPriority1 = itemPriority;
|
||||
} else {
|
||||
i = rotationRequestx.L();
|
||||
itemPriority1 = itemPriority;
|
||||
}
|
||||
|
||||
requestQueuePart./* $VF: Unable to resugar constructor */<init>(i, itemPriority1.L(), rotationRequester, rotationRequestx);
|
||||
requestQueuex.L(requestQueuePart);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user