mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-21 11:35:16 +01:00
Normalize Unique fields in mixins
This commit is contained in:
parent
08f153f434
commit
68ecd55d8c
@ -1,11 +1,11 @@
|
||||
package com.viaversion.fabric.common.gui;
|
||||
|
||||
public interface ViaServerInfo {
|
||||
boolean isViaTranslating();
|
||||
boolean viaFabric$translating();
|
||||
|
||||
void setViaTranslating(boolean via);
|
||||
void viaFabric$setTranslating(boolean via);
|
||||
|
||||
int getViaServerVer();
|
||||
int viaFabric$getServerVer();
|
||||
|
||||
void setViaServerVer(int ver);
|
||||
void viaFabric$setServerVer(int ver);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getField_3774()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/texture/TextureManager;bindTexture(Lnet/minecraft/util/Identifier;)V"))
|
||||
private void redirectPingIcon(TextureManager textureManager, Identifier identifier) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_LOCATION) && ((ViaServerInfo) this.server).isViaTranslating()) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_LOCATION) && ((ViaServerInfo) this.server).viaFabric$translating()) {
|
||||
textureManager.bindTexture(new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
@ -32,7 +32,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/lang/String;)V"))
|
||||
private void addServerVer(MultiplayerScreen multiplayerScreen, String text) {
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
StringBuilder builder = new StringBuilder(text);
|
||||
builder.append("\n");
|
||||
builder.append((new TranslatableText("gui.ping_version.translated", proto.getName(), proto.getVersion())).asString());
|
||||
|
@ -1,30 +1,35 @@
|
||||
package com.viaversion.fabric.mc114.mixin.gui.client;
|
||||
|
||||
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getField_3774()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/texture/TextureManager;bindTexture(Lnet/minecraft/util/Identifier;)V"))
|
||||
private void redirectPingIcon(TextureManager textureManager, Identifier identifier) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_LOCATION) && ((ViaServerInfo) this.server).isViaTranslating()) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_LOCATION) && ((ViaServerInfo) this.server).viaFabric$translating()) {
|
||||
textureManager.bindTexture(new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
@ -32,7 +32,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/lang/String;)V"))
|
||||
private void addServerVer(MultiplayerScreen multiplayerScreen, String text) {
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
StringBuilder builder = new StringBuilder(text);
|
||||
builder.append("\n");
|
||||
builder.append((new TranslatableText("gui.ping_version.translated", proto.getName(), proto.getVersion())).asString());
|
||||
|
@ -1,30 +1,35 @@
|
||||
package com.viaversion.fabric.mc115.mixin.gui.client;
|
||||
|
||||
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getField_3774()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/texture/TextureManager;bindTexture(Lnet/minecraft/util/Identifier;)V"))
|
||||
private void redirectPingIcon(TextureManager textureManager, Identifier identifier) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).isViaTranslating()) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).viaFabric$translating()) {
|
||||
textureManager.bindTexture(new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class MixinServerEntry {
|
||||
|
||||
@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());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
List<Text> lines = new ArrayList<>(tooltipText);
|
||||
lines.add(new TranslatableText("gui.ping_version.translated", proto.getName(), proto.getVersion()));
|
||||
lines.add(this.server.version.copy());
|
||||
|
@ -1,30 +1,35 @@
|
||||
package com.viaversion.fabric.mc116.mixin.gui.client;
|
||||
|
||||
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@ -29,10 +30,11 @@ public abstract class MixinAllowedAddressResolver {
|
||||
|
||||
ServerAddress realAddress = new ServerAddress(viaAddr.serverAddress, address.getPort());
|
||||
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabricAddSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabric$addSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
}
|
||||
|
||||
private Address viaFabricAddSuffix(Address it, String viaSuffix) {
|
||||
@Unique
|
||||
private Address viaFabric$addSuffix(Address it, String viaSuffix) {
|
||||
try {
|
||||
return Address.create(new InetSocketAddress(
|
||||
InetAddress.getByAddress(it.getHostName() + "." + viaSuffix,
|
||||
|
@ -22,8 +22,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getConnection()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class MixinServerEntry {
|
||||
@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()) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).viaFabric$translating()) {
|
||||
RenderSystem.setShaderTexture(i, new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class MixinServerEntry {
|
||||
|
||||
@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());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
List<Text> lines = new ArrayList<>(tooltipText);
|
||||
lines.add(new TranslatableText("gui.ping_version.translated", proto.getName(), proto.getVersion()));
|
||||
lines.add(this.server.version.copy());
|
||||
|
@ -3,27 +3,33 @@ 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;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@ -29,10 +30,11 @@ public abstract class MixinAllowedAddressResolver {
|
||||
|
||||
ServerAddress realAddress = new ServerAddress(viaAddr.serverAddress, address.getPort());
|
||||
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabricAddSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabric$addSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
}
|
||||
|
||||
private Address viaFabricAddSuffix(Address it, String viaSuffix) {
|
||||
@Unique
|
||||
private Address viaFabric$addSuffix(Address it, String viaSuffix) {
|
||||
try {
|
||||
return Address.create(new InetSocketAddress(
|
||||
InetAddress.getByAddress(it.getHostName() + "." + viaSuffix,
|
||||
|
@ -22,8 +22,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getConnection()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class MixinServerEntry {
|
||||
@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()) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).viaFabric$translating()) {
|
||||
RenderSystem.setShaderTexture(i, new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class MixinServerEntry {
|
||||
|
||||
@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());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
List<Text> lines = new ArrayList<>(tooltipText);
|
||||
lines.add(new TranslatableText("gui.ping_version.translated", proto.getName(), proto.getVersion()));
|
||||
lines.add(this.server.version.copy());
|
||||
|
@ -3,27 +3,33 @@ package com.viaversion.fabric.mc118.mixin.gui.client;
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@ -29,10 +30,11 @@ public abstract class MixinAllowedAddressResolver {
|
||||
|
||||
ServerAddress realAddress = new ServerAddress(viaAddr.serverAddress, address.getPort());
|
||||
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabricAddSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabric$addSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
}
|
||||
|
||||
private Address viaFabricAddSuffix(Address it, String viaSuffix) {
|
||||
@Unique
|
||||
private Address viaFabric$addSuffix(Address it, String viaSuffix) {
|
||||
try {
|
||||
return Address.create(new InetSocketAddress(
|
||||
InetAddress.getByAddress(it.getHostName() + "." + viaSuffix,
|
||||
|
@ -26,8 +26,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getField_3774()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class MixinServerEntry {
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0,
|
||||
target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderTexture(ILnet/minecraft/util/Identifier;)V"))
|
||||
private void redirectPingIcon(int i, Identifier identifier) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).isViaTranslating()) {
|
||||
if (identifier.equals(DrawableHelper.GUI_ICONS_TEXTURE) && ((ViaServerInfo) this.server).viaFabric$translating()) {
|
||||
RenderSystem.setShaderTexture(i, new Identifier("viafabric:textures/gui/icons.png"));
|
||||
return;
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V"))
|
||||
private void addServerVer(MultiplayerScreen multiplayerScreen, List<Text> tooltipText) {
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
List<Text> lines = new ArrayList<>(tooltipText);
|
||||
lines.add(Text.translatable("gui.ping_version.translated", proto.getName(), proto.getVersion()));
|
||||
lines.add(this.server.version.copy());
|
||||
|
@ -3,27 +3,33 @@ package com.viaversion.fabric.mc119.mixin.gui.client;
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minecraft.client.network.AllowedAddressResolver;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@ -29,10 +30,11 @@ public abstract class MixinAllowedAddressResolver {
|
||||
|
||||
ServerAddress realAddress = new ServerAddress(viaAddr.serverAddress, address.getPort());
|
||||
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabricAddSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
cir.setReturnValue(resolve(realAddress).map(it -> viaFabric$addSuffix(it, viaAddr.getSuffixWithOptions())));
|
||||
}
|
||||
|
||||
private Address viaFabricAddSuffix(Address it, String viaSuffix) {
|
||||
@Unique
|
||||
private Address viaFabric$addSuffix(Address it, String viaSuffix) {
|
||||
try {
|
||||
return Address.create(new InetSocketAddress(
|
||||
InetAddress.getByAddress(it.getHostName() + "." + viaSuffix,
|
||||
|
@ -26,8 +26,8 @@ public abstract class MixinMultiplayerServerListPingerListener implements Client
|
||||
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getField_3774()).getChannel()
|
||||
.pipeline().get(FabricDecodeHandler.class);
|
||||
if (decoder != null) {
|
||||
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setTranslating(decoder.getInfo().isActive());
|
||||
((ViaServerInfo) getField_3776()).viaFabric$setServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class MixinServerEntry {
|
||||
@ModifyArg(method = "render", at = @At(value = "INVOKE", ordinal = 0,
|
||||
target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"))
|
||||
private Identifier redirectPingIcon(Identifier texture) {
|
||||
if (((ViaServerInfo) this.server).isViaTranslating() && texture.getPath().startsWith("server_list/ping")) {
|
||||
if (((ViaServerInfo) this.server).viaFabric$translating() && texture.getPath().startsWith("server_list/ping")) {
|
||||
return new Identifier("viafabric", texture.getPath());
|
||||
}
|
||||
return texture;
|
||||
@ -33,7 +33,7 @@ public class MixinServerEntry {
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V"))
|
||||
private void addServerVer(MultiplayerScreen multiplayerScreen, List<Text> tooltipText) {
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).getViaServerVer());
|
||||
ProtocolVersion proto = ProtocolVersion.getProtocol(((ViaServerInfo) this.server).viaFabric$getServerVer());
|
||||
List<Text> lines = new ArrayList<>(tooltipText);
|
||||
lines.add(Text.translatable("gui.ping_version.translated", proto.getName(), proto.getVersion()));
|
||||
multiplayerScreen.setMultiplayerScreenTooltip(lines);
|
||||
|
@ -3,27 +3,33 @@ package com.viaversion.fabric.mc120.mixin.gui.client;
|
||||
import com.viaversion.fabric.common.gui.ViaServerInfo;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ServerInfo.class)
|
||||
public class MixinServerInfo implements ViaServerInfo {
|
||||
private boolean viaTranslating;
|
||||
private int viaServerVer;
|
||||
@Unique
|
||||
private boolean viaFabric$translating;
|
||||
|
||||
public int getViaServerVer() {
|
||||
return viaServerVer;
|
||||
}
|
||||
@Unique
|
||||
private int viaFabric$serverVer;
|
||||
|
||||
public void setViaServerVer(int viaServerVer) {
|
||||
this.viaServerVer = viaServerVer;
|
||||
@Override
|
||||
public int viaFabric$getServerVer() {
|
||||
return viaFabric$serverVer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViaTranslating() {
|
||||
return viaTranslating;
|
||||
public void viaFabric$setServerVer(int ver) {
|
||||
this.viaFabric$serverVer = ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setViaTranslating(boolean via) {
|
||||
this.viaTranslating = via;
|
||||
public boolean viaFabric$translating() {
|
||||
return viaFabric$translating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viaFabric$setTranslating(boolean via) {
|
||||
this.viaFabric$translating = via;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user