-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into 1.20-recode
# Conflicts: # gradle.properties
- Loading branch information
Showing
30 changed files
with
204 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...florianmichael/viafabricplus/injection/mixin/base/MixinMultiplayerServerListPinger_1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...hael/viafabricplus/injection/mixin/base/MixinMultiplayerServerListWidget_ServerEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.translatable("words.viafabricplus.serverversion", server.version.getString() + " (" + server.protocolVersion + ")")); | ||
} | ||
} | ||
instance.setMultiplayerScreenTooltip(tooltipOverwrite); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.