Skip to content

Commit

Permalink
Fix Open to LAN replacement not updating when friends are toggled in …
Browse files Browse the repository at this point in the history
…1.19.4+
  • Loading branch information
Gaming32 committed May 28, 2024
1 parent 6968245 commit aeb904d
Showing 1 changed file with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package io.github.gaming32.worldhost.mixin;

import io.github.gaming32.worldhost.WorldHost;
import io.github.gaming32.worldhost.gui.widget.OnlineStatusButton;
import io.github.gaming32.worldhost.gui.OnlineStatusLocation;
import io.github.gaming32.worldhost.gui.widget.OnlineStatusButton;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(PauseScreen.class)
Expand All @@ -19,18 +19,26 @@ protected MixinPauseScreen(Component component) {
super(component);
}

@ModifyConstant(
method =
//#if MC >= 1.19.4
"<clinit>",
//#else
//$$ "createPauseMenu",
//#endif
constant = @Constant(stringValue = "menu.shareToLan")
//#if MC >= 1.19.4
@Redirect(
method = "createPauseMenu",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/gui/screens/PauseScreen;SHARE_TO_LAN:Lnet/minecraft/network/chat/Component;",
opcode = Opcodes.GETSTATIC
)
)
private static String changeLabel(String constant) {
return WorldHost.CONFIG.isEnableFriends() ? "world-host.open_world" : "world-host.open_world_no_friends";
private Component changeLabel() {
return Component.translatable(
WorldHost.CONFIG.isEnableFriends() ? "world-host.open_world" : "world-host.open_world_no_friends"
);
}
//#else
//$$ @ModifyConstant(method = "createPauseMenu", constant = @Constant(stringValue = "menu.shareToLan"))
//$$ private static String changeLabel(String constant) {
//$$ return WorldHost.CONFIG.isEnableFriends() ? "world-host.open_world" : "world-host.open_world_no_friends";
//$$ }
//#endif

@Inject(method = "init", at = @At("RETURN"))
private void onlineStatus(CallbackInfo ci) {
Expand Down

0 comments on commit aeb904d

Please sign in to comment.