Skip to content

Commit 007dbbe

Browse files
committed
Fix shuffling window title for 1.15.2
1 parent 364c161 commit 007dbbe

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/main/java/net/earthcomputer/clientcommands/mixin/MixinMinecraftClient.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import org.spongepowered.asm.mixin.Shadow;
1515
import org.spongepowered.asm.mixin.injection.At;
1616
import org.spongepowered.asm.mixin.injection.Inject;
17-
import org.spongepowered.asm.mixin.injection.ModifyArg;
1817
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
18+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1919

2020
import java.util.ArrayList;
2121
import java.util.Collections;
@@ -63,18 +63,17 @@ public void onDisconnect(Screen screen, CallbackInfo ci) {
6363
}
6464

6565
// Earth annoying his friends <3 nothing to see here
66-
@ModifyArg(method = "<init>", index = 2, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/WindowProvider;createWindow(Lnet/minecraft/client/WindowSettings;Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/client/util/Window;"))
67-
private String modifyWindowTitle(String title) {
66+
@Inject(method = "getWindowTitle", at = @At("RETURN"), cancellable = true)
67+
private void modifyWindowTitle(CallbackInfoReturnable<String> ci) {
6868
String playerName = MinecraftClient.getInstance().getSession().getProfile().getName();
69-
if (!"Earthcomputer".equals(playerName)
70-
&& !"Azteched".equals(playerName)
71-
&& !"samnrad".equals(playerName)
72-
&& !"allocator".equals(playerName))
73-
return title;
74-
75-
List<Character> chars = title.chars().mapToObj(c -> (char)c).collect(Collectors.toCollection(ArrayList::new));
76-
Collections.shuffle(chars);
77-
return chars.stream().map(String::valueOf).collect(Collectors.joining());
69+
if ("Earthcomputer".equals(playerName)
70+
|| "Azteched".equals(playerName)
71+
|| "samnrad".equals(playerName)
72+
|| "allocator".equals(playerName)) {
73+
List<Character> chars = ci.getReturnValue().chars().mapToObj(c -> (char) c).collect(Collectors.toCollection(ArrayList::new));
74+
Collections.shuffle(chars);
75+
ci.setReturnValue(chars.stream().map(String::valueOf).collect(Collectors.joining()));
76+
}
7877
}
7978

8079
@Override

0 commit comments

Comments
 (0)