mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-23 16:58:30 +01:00
This commit is contained in:
parent
a251ff00c7
commit
6e19aa6534
@ -37,6 +37,7 @@ public class GeneralSettings extends SettingGroup {
|
|||||||
public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, Text.translatable("general.viafabricplus.extrainformation"), true);
|
public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, Text.translatable("general.viafabricplus.extrainformation"), true);
|
||||||
public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, Text.translatable("general.viafabricplus.classicloading"), true);
|
public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, Text.translatable("general.viafabricplus.classicloading"), true);
|
||||||
public final BooleanSetting autoDetectVersion = new BooleanSetting(this, Text.translatable("general.viafabricplus.autodetect"), false);
|
public final BooleanSetting autoDetectVersion = new BooleanSetting(this, Text.translatable("general.viafabricplus.autodetect"), false);
|
||||||
|
public final BooleanSetting showAdvertisedServerVersion = new BooleanSetting(this, Text.translatable("general.viafabricplus.advertised"), true);
|
||||||
|
|
||||||
public GeneralSettings() {
|
public GeneralSettings() {
|
||||||
super(Text.translatable("settings.viafabricplus.general"));
|
super(Text.translatable("settings.viafabricplus.general"));
|
||||||
|
@ -23,4 +23,10 @@ public interface IServerInfo {
|
|||||||
|
|
||||||
VersionEnum viafabricplus_forcedVersion();
|
VersionEnum viafabricplus_forcedVersion();
|
||||||
void viafabricplus_forceVersion(VersionEnum version);
|
void viafabricplus_forceVersion(VersionEnum version);
|
||||||
|
|
||||||
|
boolean viafabricplus_enabled();
|
||||||
|
void viafabricplus_enable();
|
||||||
|
|
||||||
|
int viafabricplus_translatingVersion();
|
||||||
|
void viafabricplus_setTranslatingVersion(final int version);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||||
|
|
||||||
|
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||||
|
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||||
|
import net.minecraft.client.network.ServerInfo;
|
||||||
|
import net.minecraft.network.ClientConnection;
|
||||||
|
import net.minecraft.network.listener.ClientQueryPacketListener;
|
||||||
|
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
|
||||||
|
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.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(targets = "net.minecraft.client.network.MultiplayerServerListPinger$1")
|
||||||
|
public abstract class MixinMultiplayerServerListPinger_1 implements ClientQueryPacketListener {
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
ClientConnection field_3774;
|
||||||
|
|
||||||
|
@Final
|
||||||
|
@Shadow
|
||||||
|
ServerInfo field_3776;
|
||||||
|
|
||||||
|
@Inject(method = "onResponse(Lnet/minecraft/network/packet/s2c/query/QueryResponseS2CPacket;)V", at = @At("HEAD"))
|
||||||
|
public void trackTranslatingState(QueryResponseS2CPacket packet, CallbackInfo ci) {
|
||||||
|
if (field_3774.channel.hasAttr(ProtocolHack.LOCAL_VIA_CONNECTION)) {
|
||||||
|
((IServerInfo) field_3776).viafabricplus_enable();
|
||||||
|
|
||||||
|
final var userConnection = field_3774.channel.attr(ProtocolHack.LOCAL_VIA_CONNECTION).get();
|
||||||
|
((IServerInfo) field_3776).viafabricplus_setTranslatingVersion(userConnection.getProtocolInfo().getServerProtocolVersion());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||||
|
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.florianmichael.viafabricplus.injection.mixin.base;
|
||||||
|
|
||||||
|
import de.florianmichael.viafabricplus.base.settings.groups.GeneralSettings;
|
||||||
|
import de.florianmichael.viafabricplus.injection.access.IServerInfo;
|
||||||
|
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.raphimc.vialoader.util.VersionEnum;
|
||||||
|
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 MixinMultiplayerServerListWidget_ServerEntry {
|
||||||
|
|
||||||
|
@Shadow @Final private ServerInfo server;
|
||||||
|
|
||||||
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V", ordinal = 0))
|
||||||
|
public void showTranslatingInformation(MultiplayerScreen instance, List<Text> tooltip) {
|
||||||
|
final List<Text> tooltipOverwrite = new ArrayList<>(tooltip);
|
||||||
|
if (GeneralSettings.INSTANCE.showAdvertisedServerVersion.getValue()) {
|
||||||
|
final IServerInfo accessor = ((IServerInfo) server);
|
||||||
|
if (accessor.viafabricplus_enabled()) {
|
||||||
|
final var versionEnum = VersionEnum.fromProtocolId(accessor.viafabricplus_translatingVersion());
|
||||||
|
|
||||||
|
tooltipOverwrite.add(Text.translatable("words.viafabricplus.translate", versionEnum != VersionEnum.UNKNOWN ? versionEnum.getName() + " (" + versionEnum.getVersion() + ")" : accessor.viafabricplus_translatingVersion()));
|
||||||
|
tooltipOverwrite.add(Text.of("Server version: " + server.version.getString() + " (" + server.protocolVersion + ")"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
instance.setMultiplayerScreenTooltip(tooltipOverwrite);
|
||||||
|
}
|
||||||
|
}
|
@ -70,4 +70,30 @@ public class MixinServerInfo implements IServerInfo {
|
|||||||
public void trackForcedVersion(ServerInfo serverInfo, CallbackInfo ci) {
|
public void trackForcedVersion(ServerInfo serverInfo, CallbackInfo ci) {
|
||||||
viafabricplus_forceVersion(((IServerInfo) serverInfo).viafabricplus_forcedVersion());
|
viafabricplus_forceVersion(((IServerInfo) serverInfo).viafabricplus_forcedVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private boolean viafabricplus_enabled;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean viafabricplus_enabled() {
|
||||||
|
return viafabricplus_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void viafabricplus_enable() {
|
||||||
|
viafabricplus_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private int viafabricplus_translatingVersion;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int viafabricplus_translatingVersion() {
|
||||||
|
return viafabricplus_translatingVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void viafabricplus_setTranslatingVersion(int version) {
|
||||||
|
viafabricplus_translatingVersion = version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"words.viafabricplus.reset": "Reset",
|
"words.viafabricplus.reset": "Reset",
|
||||||
"words.viafabricplus.copy": "Copy code",
|
"words.viafabricplus.copy": "Copy code",
|
||||||
"words.viafabricplus.error": "Something went wrong! Please try again later",
|
"words.viafabricplus.error": "Something went wrong! Please try again later",
|
||||||
|
"words.viafabricplus.translate": "Via translates to: %s",
|
||||||
|
|
||||||
"settings.viafabricplus.authentication": "Authentication",
|
"settings.viafabricplus.authentication": "Authentication",
|
||||||
"settings.viafabricplus.experimental": "Experimental",
|
"settings.viafabricplus.experimental": "Experimental",
|
||||||
@ -27,6 +28,7 @@
|
|||||||
"general.viafabricplus.creative": "Remove not available items from creative tab",
|
"general.viafabricplus.creative": "Remove not available items from creative tab",
|
||||||
"general.viafabricplus.protocolsync": "Automatically change Settings based on the current version",
|
"general.viafabricplus.protocolsync": "Automatically change Settings based on the current version",
|
||||||
"general.viafabricplus.autodetect": "Auto detect version",
|
"general.viafabricplus.autodetect": "Auto detect version",
|
||||||
|
"general.viafabricplus.advertised": "Show advertised/server version in Multiplayer",
|
||||||
|
|
||||||
"experimental.viafabricplus.chunkborderfix": "Fix Chunk borders",
|
"experimental.viafabricplus.chunkborderfix": "Fix Chunk borders",
|
||||||
"experimental.viafabricplus.watermovement": "Water movement edge detection",
|
"experimental.viafabricplus.watermovement": "Water movement edge detection",
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
"base.MixinMinecraftClient",
|
"base.MixinMinecraftClient",
|
||||||
"base.MixinMultiplayerScreen",
|
"base.MixinMultiplayerScreen",
|
||||||
"base.MixinMultiplayerServerListPinger",
|
"base.MixinMultiplayerServerListPinger",
|
||||||
|
"base.MixinMultiplayerServerListPinger_1",
|
||||||
|
"base.MixinMultiplayerServerListWidget_ServerEntry",
|
||||||
"base.MixinOptionsScreen",
|
"base.MixinOptionsScreen",
|
||||||
"base.MixinServerInfo",
|
"base.MixinServerInfo",
|
||||||
"base.MixinSharedConstants",
|
"base.MixinSharedConstants",
|
||||||
|
Loading…
Reference in New Issue
Block a user