|
20 | 20 | import com.google.common.collect.Lists; |
21 | 21 | import com.viaversion.fabric.common.gui.ViaServerData; |
22 | 22 | import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; |
23 | | -import org.spongepowered.asm.mixin.Final; |
24 | | -import org.spongepowered.asm.mixin.Mixin; |
25 | | -import org.spongepowered.asm.mixin.Shadow; |
26 | | -import org.spongepowered.asm.mixin.injection.At; |
27 | | -import org.spongepowered.asm.mixin.injection.ModifyArg; |
28 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
29 | | - |
30 | 23 | import java.util.ArrayList; |
31 | 24 | import java.util.List; |
32 | 25 | import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; |
33 | 26 | import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList; |
34 | 27 | import net.minecraft.client.multiplayer.ServerData; |
35 | 28 | import net.minecraft.network.chat.Component; |
36 | 29 | import net.minecraft.resources.ResourceLocation; |
| 30 | +import org.spongepowered.asm.mixin.Final; |
| 31 | +import org.spongepowered.asm.mixin.Mixin; |
| 32 | +import org.spongepowered.asm.mixin.Shadow; |
| 33 | +import org.spongepowered.asm.mixin.injection.At; |
| 34 | +import org.spongepowered.asm.mixin.injection.ModifyArg; |
| 35 | +import org.spongepowered.asm.mixin.injection.Redirect; |
37 | 36 |
|
38 | 37 | @Mixin(ServerSelectionList.OnlineServerEntry.class) |
39 | | -public class MixinServerEntry { |
| 38 | +public class MixinOnlineServerEntry { |
| 39 | + |
40 | 40 | @Shadow |
41 | 41 | @Final |
42 | | - private ServerData server; |
| 42 | + private ServerData serverData; |
43 | 43 |
|
44 | 44 | @ModifyArg(method = "render", at = @At(value = "INVOKE", ordinal = 0, |
45 | | - target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V")) |
| 45 | + target = "Lnet/minecraft/client/gui/GuiGraphics;blitSprite(Lnet/minecraft/resources/ResourceLocation;IIII)V")) |
46 | 46 | private ResourceLocation redirectPingIcon(ResourceLocation texture) { |
47 | | - if (((ViaServerData) this.server).viaFabric$translating() && texture.getPath().startsWith("server_list/ping")) { |
48 | | - return ResourceLocation.fromNamespaceAndPath("viafabric", texture.getPath()); |
| 47 | + if (((ViaServerData) this.serverData).viaFabric$translating() && texture.getPath().startsWith("server_list/ping")) { |
| 48 | + return ResourceLocation.tryBuild("viafabric", texture.getPath()); |
49 | 49 | } |
50 | 50 | return texture; |
51 | 51 | } |
52 | 52 |
|
53 | | - @Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V")) |
54 | | - private void addServerVer(JoinMultiplayerScreen instance, Component text) { |
55 | | - ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerData) this.server).viaFabric$getServerVer()); |
| 53 | + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen;setTooltipForNextRenderPass(Lnet/minecraft/network/chat/Component;)V")) |
| 54 | + private void addServerVer(JoinMultiplayerScreen instance, Component component) { |
| 55 | + ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerData) this.serverData).viaFabric$getServerVer()); |
56 | 56 | List<Component> lines = new ArrayList<>(); |
57 | | - lines.add(text); |
| 57 | + lines.add(component); |
58 | 58 | lines.add(Component.translatable("gui.ping_version.translated", proto.getName(), proto.getVersion())); |
59 | 59 | instance.setTooltipForNextRenderPass(Lists.transform(lines, Component::getVisualOrderText)); |
60 | 60 | } |
|
0 commit comments