1.19.3, remove 1.19 chat patch

This commit is contained in:
creeper123123321 2022-12-07 16:17:15 -03:00
parent c8e9132e68
commit 7265dcffb7
19 changed files with 26 additions and 296 deletions

View File

@ -162,7 +162,7 @@ processResources {
}
List<String> mcReleases = new ArrayList<>(
Arrays.asList("1.19.2", "1.19.1", "1.18.2", "1.17.1", "1.16.5", "1.15.2", "1.14.4", "1.8.9"))
Arrays.asList("1.19.3", "1.18.2", "1.17.1", "1.16.5", "1.15.2", "1.14.4", "1.8.9"))
List<String> javaVersions = IntStream.rangeClosed(8, 18)
.mapToObj { n -> (String) "Java $n" }
.collect(Collectors.toList())

View File

@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xms32M -Xmx3G -XX:+UseG1GC -XX:+UseStringDeduplication
loader_version=0.14.10
viaver_version=4.4.3-SNAPSHOT
viaver_version=4.5.0
yaml_version=1.33
# example: 1.19.1-rc2

View File

@ -36,10 +36,6 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
multiconnectIntegration();
}
// This method indicates the correct clientside version, in case Auto Detect is used you still need the version that ViaVersion uses
public void onFinallySetVersion(final int realClientsideVersion) {
}
private void multiconnectIntegration() {
if (!FabricLoader.getInstance().isModLoaded("multiconnect")) return;
try {
@ -106,7 +102,6 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider
if (blocked || !supported) serverVer = info.getProtocolVersion();
this.onFinallySetVersion(serverVer);
return serverVer;
}
NativeVersionProvider natProvider = Via.getManager().getProviders().get(NativeVersionProvider.class);

View File

@ -13,7 +13,7 @@
},
"depends": {
"fabricloader": ">=0.10.0",
"minecraft": ["1.8.x", "1.14.4", "1.15.2", "~1.16.4", "1.17.1", "1.18.2", "~1.19.1"],
"minecraft": ["1.8.x", "1.14.4", "1.15.2", "~1.16.4", "1.17.1", "1.18.2", "~1.19.3"],
"viaversion": ">=4.0.0"
},
"environment": "*",

View File

@ -1,9 +1,9 @@
dependencies {
minecraft("com.mojang:minecraft:1.19.2")
mappings("net.fabricmc:yarn:1.19.2+build.8:v2")
minecraft("com.mojang:minecraft:1.19.3")
mappings("net.fabricmc:yarn:1.19.3+build.2:v2")
modImplementation("net.fabricmc.fabric-api:fabric-api:0.60.0+1.19.2")
modImplementation("com.terraformersmc:modmenu:4.0.6")
modImplementation("net.fabricmc.fabric-api:fabric-api:0.68.1+1.19.3")
modImplementation("com.terraformersmc:modmenu:5.0.0-alpha.4")
}
tasks.compileJava {

View File

@ -12,7 +12,6 @@ import com.viaversion.fabric.common.util.JLoggerToLog4j;
import com.viaversion.fabric.mc119.commands.VRCommandHandler;
import com.viaversion.fabric.mc119.platform.FabricPlatform;
import com.viaversion.fabric.mc119.platform.VFLoader;
import com.viaversion.fabric.mc119.signatures1_19.ProtocolPatcher1_19;
import com.viaversion.viaversion.ViaManagerImpl;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
@ -84,8 +83,6 @@ public class ViaFabric implements ModInitializer {
config = new VFConfig(FabricLoader.getInstance().getConfigDir().resolve("ViaFabric")
.resolve("viafabric.yml").toFile());
ProtocolPatcher1_19.patchIfClient();
INIT_FUTURE.complete(null);
}

View File

@ -31,14 +31,18 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
protected void init() {
int entries = 0;
this.addDrawableChild(new ButtonWidget(calculatePosX(this.width, entries),
calculatePosY(this.height, entries),
150, 20, getClientSideText(), this::onClickClientSide));
this.addDrawableChild(ButtonWidget
.builder(getClientSideText(), this::onClickClientSide)
.dimensions(calculatePosX(this.width, entries),
calculatePosY(this.height, entries), 150, 20)
.build());
entries++;
this.addDrawableChild(new ButtonWidget(calculatePosX(this.width, entries),
calculatePosY(this.height, entries),
150, 20, getHideViaButtonText(), this::onHideViaButton));
this.addDrawableChild(ButtonWidget
.builder(getHideViaButtonText(), this::onHideViaButton)
.dimensions(calculatePosX(this.width, entries),
calculatePosY(this.height, entries), 150, 20)
.build());
entries++;
protocolVersion = new TextFieldWidget(this.textRenderer,
@ -54,7 +58,10 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
this.addDrawableChild(protocolVersion);
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 40, 200, 20, ScreenTexts.DONE, (buttonWidget) -> this.client.setScreen(this.parent)));
this.addDrawableChild(ButtonWidget
.builder(ScreenTexts.DONE, (it) -> close())
.dimensions(this.width / 2 - 100, this.height - 40, 200, 20)
.build());
}
private void onChangeVersionField(String text) {

View File

@ -34,11 +34,11 @@ public class MixinServerEntry {
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"))
@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());
List<Text> lines = new ArrayList<>(tooltipText);
lines.add(Text.translatable("gui.ping_version.translated", proto.getName()));
multiplayerScreen.setTooltip(lines);
multiplayerScreen.setMultiplayerScreenTooltip(lines);
}
}

View File

@ -1,36 +0,0 @@
package com.viaversion.fabric.mc119.mixin.signatures1_19.client;
import com.viaversion.fabric.mc119.signatures1_19.MessageSigner1_19;
import com.viaversion.fabric.mc119.signatures1_19.ProtocolPatcher1_19;
import net.minecraft.command.argument.DecoratableArgumentList;
import net.minecraft.network.encryption.Signer;
import net.minecraft.network.message.ArgumentSignatureDataMap;
import net.minecraft.network.message.MessageMetadata;
import net.minecraft.network.message.MessageSignatureData;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Collectors;
@Mixin(ArgumentSignatureDataMap.class)
public class ArgumentSignatureDataMapMixin {
@Inject(method = "sign", at = @At("HEAD"), cancellable = true)
private static void injectSign(DecoratableArgumentList<?> arguments, ArgumentSignatureDataMap.ArgumentSigner signer, CallbackInfoReturnable<ArgumentSignatureDataMap> cir) {
if (!ProtocolPatcher1_19.shouldPatchKeys) return;
final List<ArgumentSignatureDataMap.Entry> list = ArgumentSignatureDataMap.toNameValuePairs(arguments)
.stream().map(entry -> {
final MessageMetadata metadata = MessageSigner1_19.pollLastMetadata();
final MessageSignatureData messageSignatureData = MessageSigner1_19.sign((Signer) signer,
Text.literal(entry.getFirst()), metadata.sender(), metadata.timestamp(), metadata.salt());
return new ArgumentSignatureDataMap.Entry(entry.getFirst(), messageSignatureData);
}).collect(Collectors.toList());
cir.setReturnValue(new ArgumentSignatureDataMap(list));
}
}

View File

@ -1,46 +0,0 @@
package com.viaversion.fabric.mc119.mixin.signatures1_19.client;
import com.mojang.brigadier.ParseResults;
import com.viaversion.fabric.mc119.signatures1_19.MessageSigner1_19;
import com.viaversion.fabric.mc119.signatures1_19.ProtocolPatcher1_19;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.command.CommandSource;
import net.minecraft.network.encryption.Signer;
import net.minecraft.network.message.*;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
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.CallbackInfoReturnable;
@Mixin(ClientPlayerEntity.class)
public class ClientPlayerEntityMixin {
@Shadow
@Final
protected MinecraftClient client;
@Inject(method = "signChatMessage", at = @At("HEAD"), cancellable = true)
public void injectSignChatMessage(MessageMetadata metadata, DecoratedContents content, LastSeenMessageList lastSeenMessages, CallbackInfoReturnable<MessageSignatureData> cir) {
if (!ProtocolPatcher1_19.shouldPatchKeys) return;
try {
final Signer signer = this.client.getProfileKeys().getSigner();
if (signer != null) {
cir.setReturnValue(MessageSigner1_19.sign(signer, content.decorated(), metadata.sender(),
metadata.timestamp(), metadata.salt()));
}
} catch (Exception ignored) {
}
cir.cancel();
}
@Inject(method = "signArguments", at = @At(value = "HEAD"))
public void injectSignArguments(MessageMetadata signer, ParseResults<CommandSource> parseResults, @Nullable Text preview, LastSeenMessageList lastSeenMessages, CallbackInfoReturnable<ArgumentSignatureDataMap> cir) {
MessageSigner1_19.track(signer);
}
}

View File

@ -1,56 +0,0 @@
package com.viaversion.fabric.mc119.mixin.signatures1_19.client;
import com.viaversion.fabric.mc119.signatures1_19.IPublicKeyData;
import com.viaversion.fabric.mc119.signatures1_19.ProtocolPatcher1_19;
import net.minecraft.network.encryption.NetworkEncryptionUtils;
import net.minecraft.network.encryption.PlayerPublicKey;
import org.spongepowered.asm.mixin.Final;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.PublicKey;
import java.time.Instant;
import java.util.UUID;
@Mixin(PlayerPublicKey.PublicKeyData.class)
public class PlayerPublicKeyChPublicKeyDataMixin implements IPublicKeyData {
@Shadow
@Final
private Instant expiresAt;
@Shadow
@Final
PublicKey key;
@Unique
private byte[] key1_19_0;
@Redirect(method = {"write", "verifyKey"}, at = @At(value = "FIELD", target = "Lnet/minecraft/network/encryption/PlayerPublicKey$PublicKeyData;keySignature:[B"))
public byte[] replaceKeys(PlayerPublicKey.PublicKeyData instance) {
if (this.key1_19_0 != null && ProtocolPatcher1_19.shouldPatchKeys) {
return this.key1_19_0;
}
return instance.keySignature();
}
@Inject(method = "toSerializedString", at = @At(value = "HEAD"), cancellable = true)
public void injectToSerializedString(UUID playerUuid, CallbackInfoReturnable<byte[]> cir) {
if (ProtocolPatcher1_19.shouldPatchKeys) {
cir.setReturnValue((this.expiresAt.toEpochMilli() + NetworkEncryptionUtils.encodeRsaPublicKey(this.key)).getBytes(StandardCharsets.UTF_8));
}
}
@Override
public void set1_19_0Key(ByteBuffer byteBuffer) {
this.key1_19_0 = byteBuffer.array();
}
}

View File

@ -1,18 +0,0 @@
package com.viaversion.fabric.mc119.mixin.signatures1_19.client;
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
import com.viaversion.fabric.mc119.signatures1_19.IPublicKeyData;
import net.minecraft.client.util.ProfileKeys;
import net.minecraft.network.encryption.PlayerPublicKey;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ProfileKeys.class)
public class ProfileKeysMixin {
@Inject(method = "decodeKeyPairResponse", at = @At("RETURN"))
private static void trackLegacyKey(KeyPairResponse keyPairResponse, CallbackInfoReturnable<PlayerPublicKey.PublicKeyData> cir) {
((IPublicKeyData) (Object) cir.getReturnValue()).set1_19_0Key(keyPairResponse.getLegacyPublicKeySignature());
}
}

View File

@ -4,7 +4,6 @@ import com.viaversion.fabric.common.config.VFConfig;
import com.viaversion.fabric.common.provider.AbstractFabricVersionProvider;
import com.viaversion.fabric.mc119.ViaFabric;
import com.viaversion.fabric.mc119.service.ProtocolAutoDetector;
import com.viaversion.fabric.mc119.signatures1_19.ProtocolPatcher1_19;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import io.netty.channel.ChannelPipeline;
import net.minecraft.network.ClientConnection;
@ -29,11 +28,6 @@ public class FabricVersionProvider extends AbstractFabricVersionProvider {
return ProtocolAutoDetector.detectVersion(address);
}
@Override
public void onFinallySetVersion(int realClientsideVersion) {
ProtocolPatcher1_19.shouldPatchKeys = realClientsideVersion <= ProtocolVersion.v1_19.getVersion();
}
@Override
protected boolean isMulticonnectHandler(ChannelPipeline pipe) {
return pipe.get(ClientConnection.class).getPacketListener().getClass().getName().startsWith("net.earthcomputer.multiconnect");

View File

@ -12,8 +12,8 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class VRHandItemProvider extends HandItemProvider {
public Item clientItem = null;
@ -50,7 +50,7 @@ public class VRHandItemProvider extends HandItemProvider {
}
private Item fromNative(ItemStack original) {
Identifier iid = Registry.ITEM.getId(original.getItem());
Identifier iid = Registries.ITEM.getId(original.getItem());
int id = RemappingUtil.swordId(iid.toString());
return new DataItem(id, (byte) original.getCount(), (short) original.getDamage(), null);
}

View File

@ -1,7 +0,0 @@
package com.viaversion.fabric.mc119.signatures1_19;
import java.nio.ByteBuffer;
public interface IPublicKeyData {
void set1_19_0Key(final ByteBuffer byteBuffer);
}

View File

@ -1,39 +0,0 @@
package com.viaversion.fabric.mc119.signatures1_19;
import net.minecraft.network.encryption.Signer;
import net.minecraft.network.message.MessageMetadata;
import net.minecraft.network.message.MessageSignatureData;
import net.minecraft.text.Text;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.*;
public class MessageSigner1_19 {
public static final Deque<MessageMetadata> TRACKED_METADATA_LIST = new ArrayDeque<>();
public static MessageMetadata pollLastMetadata() {
return TRACKED_METADATA_LIST.pollLast();
}
public static void track(final MessageMetadata metadata) {
TRACKED_METADATA_LIST.add(metadata);
}
public static MessageSignatureData sign(Signer signer, Text decorateText, final UUID sender, final Instant timeStamp, final long salt) {
return new MessageSignatureData(signer.sign((sign -> {
final byte[] data = new byte[32];
final ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN);
buffer.putLong(salt);
buffer.putLong(sender.getMostSignificantBits()).putLong(sender.getLeastSignificantBits());
buffer.putLong(timeStamp.getEpochSecond());
sign.update(data);
sign.update(Text.Serializer.toSortedJsonString(decorateText).getBytes(StandardCharsets.UTF_8));
})));
}
}

View File

@ -1,44 +0,0 @@
package com.viaversion.fabric.mc119.signatures1_19;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.Protocol1_19_1To1_19;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
// This class modifies the 1.19.1 -> 1.19.0 transformers so that they simply pass through the original Minecraft key.
public class ProtocolPatcher1_19 {
public static boolean shouldPatchKeys = false;
public static void patchIfClient() {
if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) return;
Protocol1_19_1To1_19 protocol = Via.getManager().getProtocolManager().getProtocol(Protocol1_19_1To1_19.class);
if (protocol == null) throw new AssertionError();
protocol.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
@Override
public void registerMap() {
this.map(Type.STRING);
this.map(Type.OPTIONAL_PROFILE_KEY);
this.read(Type.OPTIONAL_UUID);
}
}, true);
protocol.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
@Override
public void registerMap() {
}
}, true);
protocol.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
@Override
public void registerMap() {
}
}, true);
}
}

View File

@ -50,8 +50,7 @@
"mixins.viafabric119.address.json",
"mixins.viafabric119.gui.json",
"mixins.viafabric119.debug.json",
"mixins.viafabric119.pipeline.json",
"mixins.viafabric119.signatures.json"
"mixins.viafabric119.pipeline.json"
],
"custom": {
"modmenu": {

View File

@ -1,16 +0,0 @@
{
"required": true,
"compatibilityLevel": "JAVA_16",
"package": "com.viaversion.fabric.mc119.mixin.signatures1_19",
"mixins": [
],
"client": [
"client.ArgumentSignatureDataMapMixin",
"client.PlayerPublicKeyChPublicKeyDataMixin",
"client.ClientPlayerEntityMixin",
"client.ProfileKeysMixin"
],
"injectors": {
"defaultRequire": 0
}
}