mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2025-02-16 01:21:21 +01:00
reimplement #35 for 1.17, very cursed code
This commit is contained in:
parent
dfcf9cf354
commit
9f528c6e4e
@ -0,0 +1,11 @@
|
||||
package com.viaversion.fabric.common.gui;
|
||||
|
||||
public interface ViaServerInfo {
|
||||
boolean isViaTranslating();
|
||||
|
||||
void setViaTranslating(boolean via);
|
||||
|
||||
int getViaServerVer();
|
||||
|
||||
void setViaServerVer(int ver);
|
||||
}
|
BIN
src/main/resources/assets/viafabric/textures/gui/icons.png
Normal file
BIN
src/main/resources/assets/viafabric/textures/gui/icons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 794 B |
@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Mixin(targets = "net/minecraft/client/gui/screen/ConnectScreen$1", priority = 2000)
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreenThread {
|
||||
@Redirect(method = "run()V", at = @At(value = "INVOKE",
|
||||
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
|
||||
|
@ -10,6 +10,6 @@
|
||||
"client.MixinServerPinger"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
"defaultRequire": 0
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Mixin(targets = "net/minecraft/client/gui/screen/ConnectScreen$1", priority = 2000)
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreenThread {
|
||||
@Redirect(method = "run()V", at = @At(value = "INVOKE",
|
||||
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
|
||||
|
@ -10,6 +10,6 @@
|
||||
"client.MixinServerPinger"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
"defaultRequire": 0
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Mixin(targets = "net/minecraft/client/gui/screen/ConnectScreen$1", priority = 2000)
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreenThread {
|
||||
@Redirect(method = "run()V", at = @At(value = "INVOKE",
|
||||
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
|
||||
|
@ -10,6 +10,6 @@
|
||||
"client.MixinServerPinger"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
"defaultRequire": 0
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.viaversion.fabric.mc117.mixin.gui.client;
|
||||
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import com.viaversion.fabric.common.handler.FabricDecodeHandler;
|
||||
import com.viaversion.fabric.mc117.mixin.debug.client.MixinClientConnectionAccessor;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.listener.ClientQueryPacketListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(targets = "net.minecraft.client.network.MultiplayerServerListPinger$1")
|
||||
public abstract class MixinMultiplayerServerListPingerListener implements ClientQueryPacketListener {
|
||||
@Shadow
|
||||
public abstract ClientConnection getConnection();
|
||||
|
||||
@Redirect(method = "onResponse(Lnet/minecraft/network/packet/s2c/query/QueryResponseS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ServerInfo;getIcon()Ljava/lang/String;"))
|
||||
private String onResponseCaptureServerInfo(ServerInfo serverInfo) {
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getConnection()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) serverInfo).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) serverInfo).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
return serverInfo.getIcon();
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.viaversion.fabric.mc117.mixin.gui.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(MultiplayerServerListWidget.ServerEntry.class)
|
||||
public class MixinServerEntry {
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerInfo server;
|
||||
|
||||
// todo fix this intermediary
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0,
|
||||
target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/class_2960;)V"))
|
||||
private void redirectPingIcon(int i, Identifier identifier) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).isViaTranslating()) {
|
||||
RenderSystem.setShaderTexture(i, new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
RenderSystem.setShaderTexture(i, identifier);
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V"))
|
||||
private void addServerVer(MultiplayerScreen multiplayerScreen, List<Text> tooltipText) {
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
|
||||
List<Text> lines = new ArrayList<>(tooltipText);
|
||||
lines.add(new TranslatableText("gui.ping_version.translated", proto.getName()));
|
||||
multiplayerScreen.setTooltip(lines);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.viaversion.fabric.mc117.mixin.gui.client;
|
||||
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
}
|
||||
}
|
@ -8,6 +8,6 @@
|
||||
"client.MixinAllowedAddressResolver"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
"defaultRequire": 0
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,10 @@
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"client.MixinMultiplayerScreen"
|
||||
"client.MixinMultiplayerScreen",
|
||||
"client.MixinMultiplayerServerListPingerListener",
|
||||
"client.MixinServerEntry",
|
||||
"client.MixinServerInfo"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 0
|
||||
|
@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
@Mixin(targets = "net/minecraft/client/gui/screen/ConnectScreen$1", priority = 2000)
|
||||
@Mixin(targets = "net.minecraft.client.gui.screen.ConnectScreen$1")
|
||||
public class MixinConnectScreenThread {
|
||||
@Redirect(method = "run()V", at = @At(value = "INVOKE",
|
||||
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"))
|
||||
|
@ -10,6 +10,6 @@
|
||||
"client.MixinServerPinger"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
"defaultRequire": 0
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user