Skip to content

Commit d74597e

Browse files
authored
Replace old mixin fields with @Local and @Share (#5821)
1 parent b8d3ea9 commit d74597e

3 files changed

Lines changed: 13 additions & 27 deletions

File tree

src/main/java/meteordevelopment/meteorclient/mixin/CameraMixin.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package meteordevelopment.meteorclient.mixin;
77

8+
import com.llamalad7.mixinextras.sugar.Local;
89
import meteordevelopment.meteorclient.mixininterface.ICamera;
910
import meteordevelopment.meteorclient.systems.modules.Modules;
1011
import meteordevelopment.meteorclient.systems.modules.render.CameraTweaks;
@@ -37,9 +38,6 @@ public abstract class CameraMixin implements ICamera {
3738

3839
@Shadow protected abstract void setRotation(float yaw, float pitch);
3940

40-
@Unique
41-
private float tickDelta;
42-
4341
@Inject(method = "getSubmersionType", at = @At("HEAD"), cancellable = true)
4442
private void getSubmergedFluidState(CallbackInfoReturnable<CameraSubmersionType> ci) {
4543
if (Modules.get().get(NoRender.class).noLiquidOverlay()) ci.setReturnValue(CameraSubmersionType.NONE);
@@ -60,11 +58,6 @@ private void onClipToSpace(float desiredCameraDistance, CallbackInfoReturnable<F
6058
}
6159
}
6260

63-
@Inject(method = "update", at = @At("HEAD"))
64-
private void onUpdateHead(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo info) {
65-
this.tickDelta = tickDelta;
66-
}
67-
6861
@Inject(method = "update", at = @At("TAIL"))
6962
private void onUpdateTail(BlockView area, Entity focusedEntity, boolean thirdPerson, boolean inverseView, float tickDelta, CallbackInfo info) {
7063
if (Modules.get().isActive(Freecam.class)) {
@@ -73,7 +66,7 @@ private void onUpdateTail(BlockView area, Entity focusedEntity, boolean thirdPer
7366
}
7467

7568
@ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setPos(DDD)V"))
76-
private void onUpdateSetPosArgs(Args args) {
69+
private void onUpdateSetPosArgs(Args args, @Local(argsOnly = true) float tickDelta) {
7770
Freecam freecam = Modules.get().get(Freecam.class);
7871

7972
if (freecam.isActive()) {
@@ -84,7 +77,7 @@ private void onUpdateSetPosArgs(Args args) {
8477
}
8578

8679
@ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setRotation(FF)V"))
87-
private void onUpdateSetRotationArgs(Args args) {
80+
private void onUpdateSetRotationArgs(Args args, @Local(argsOnly = true) float tickDelta) {
8881
Freecam freecam = Modules.get().get(Freecam.class);
8982
FreeLook freeLook = Modules.get().get(FreeLook.class);
9083

src/main/java/meteordevelopment/meteorclient/mixin/ChatHudMixin.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
99
import com.llamalad7.mixinextras.injector.ModifyReceiver;
1010
import com.llamalad7.mixinextras.sugar.Local;
11+
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
1112
import meteordevelopment.meteorclient.MeteorClient;
1213
import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent;
1314
import meteordevelopment.meteorclient.mixininterface.IChatHud;
@@ -53,8 +54,6 @@ public abstract class ChatHudMixin implements IChatHud {
5354
private BetterChat betterChat;
5455
@Unique
5556
private int nextId;
56-
@Unique
57-
private boolean skipOnAddMessage;
5857

5958
@Shadow
6059
public abstract void addMessage(Text message, @Nullable MessageSignatureData signatureData, @Nullable MessageIndicator indicator);
@@ -103,9 +102,7 @@ private ChatHudLine onAddMessage_modifyChatHudLine(ChatHudLine line) {
103102
}
104103

105104
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", cancellable = true)
106-
private void onAddMessage(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci) {
107-
if (skipOnAddMessage) return;
108-
105+
private void onAddMessage(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci, @Local(argsOnly = true) LocalRef<Text> messageRef, @Local(argsOnly = true) LocalRef<MessageIndicator> indicatorRef) {
109106
ReceiveMessageEvent event = MeteorClient.EVENT_BUS.post(ReceiveMessageEvent.get(message, indicator, nextId));
110107

111108
if (event.isCancelled()) ci.cancel();
@@ -120,11 +117,8 @@ private void onAddMessage(Text message, MessageSignatureData signatureData, Mess
120117
}
121118

122119
if (event.isModified()) {
123-
ci.cancel();
124-
125-
skipOnAddMessage = true;
126-
addMessage(event.getMessage(), signatureData, event.getIndicator());
127-
skipOnAddMessage = false;
120+
messageRef.set(event.getMessage());
121+
indicatorRef.set(event.getIndicator());
128122
}
129123
}
130124
}

src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package meteordevelopment.meteorclient.mixin;
77

88
import com.llamalad7.mixinextras.sugar.Local;
9+
import com.llamalad7.mixinextras.sugar.Share;
10+
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
911
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
1012
import com.mojang.brigadier.exceptions.CommandSyntaxException;
1113
import meteordevelopment.meteorclient.MeteorClient;
@@ -49,9 +51,6 @@ public abstract class ClientPlayNetworkHandlerMixin extends ClientCommonNetworkH
4951
@Shadow
5052
private ClientWorld world;
5153

52-
@Unique
53-
private boolean worldNotNull;
54-
5554
protected ClientPlayNetworkHandlerMixin(MinecraftClient client, ClientConnection connection, ClientConnectionState connectionState) {
5655
super(client, connection, connectionState);
5756
}
@@ -66,13 +65,13 @@ private void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo info) {
6665
}
6766

6867
@Inject(method = "onGameJoin", at = @At("HEAD"))
69-
private void onGameJoinHead(GameJoinS2CPacket packet, CallbackInfo info) {
70-
worldNotNull = world != null;
68+
private void onGameJoinHead(GameJoinS2CPacket packet, CallbackInfo info, @Share("worldNotNull") LocalBooleanRef worldNotNull) {
69+
worldNotNull.set(world != null);
7170
}
7271

7372
@Inject(method = "onGameJoin", at = @At("TAIL"))
74-
private void onGameJoinTail(GameJoinS2CPacket packet, CallbackInfo info) {
75-
if (worldNotNull) {
73+
private void onGameJoinTail(GameJoinS2CPacket packet, CallbackInfo info, @Share("worldNotNull") LocalBooleanRef worldNotNull) {
74+
if (worldNotNull.get()) {
7675
MeteorClient.EVENT_BUS.post(GameLeftEvent.get());
7776
}
7877

0 commit comments

Comments
 (0)