Updated Via*

This commit is contained in:
RaphiMC 2023-02-12 15:48:36 +01:00
parent 3b0c557776
commit 54806174c3
13 changed files with 115 additions and 146 deletions

View File

@ -67,7 +67,7 @@ dependencies {
}
include "com.viaversion:viarewind-core:2.0.3-SNAPSHOT"
include "net.raphimc:ViaLegacy:2.2.4"
include "net.raphimc:ViaAprilFools:2.0.2"
include "net.raphimc:ViaAprilFools:2.0.3"
include("net.raphimc:ViaProtocolHack:2.1.3") {
exclude group: "org.slf4j", module: "slf4j-api"
}

View File

@ -6,4 +6,4 @@ org.gradle.configureondemand=true
# Project properties
maven_name=ViaProxy
maven_group=net.raphimc
maven_version=3.0.11
maven_version=3.0.12

View File

@ -21,7 +21,8 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
@ -40,12 +41,9 @@ import java.util.List;
public class ClassicWorldHeightInjection {
public static PacketRemapper handleJoinGame(final Protocol1_17To1_16_4 protocol, final PacketRemapper parentRemapper) {
return new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
parentRemapper.remap(wrapper);
public static PacketHandler handleJoinGame(final Protocol1_17To1_16_4 protocol, final PacketHandler parentHandler) {
return wrapper -> {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
@ -54,33 +52,23 @@ public class ClassicWorldHeightInjection {
}
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 1));
}
});
}
};
}
public static PacketRemapper handleRespawn(final Protocol1_17To1_16_4 protocol, final PacketRemapper parentRemapper) {
return new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
parentRemapper.remap(wrapper);
public static PacketHandler handleRespawn(final Protocol1_17To1_16_4 protocol, final PacketHandler parentHandler) {
return wrapper -> {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 0));
}
});
}
};
}
public static PacketRemapper handleChunkData(final Protocol1_17To1_16_4 protocol, final PacketRemapper parentRemapper) {
return new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
parentRemapper.remap(wrapper);
public static PacketHandler handleChunkData(final Protocol1_17To1_16_4 protocol, final PacketHandler parentHandler) {
return wrapper -> {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
@ -110,15 +98,13 @@ public class ClassicWorldHeightInjection {
chunk.setHeightMap(new CompoundTag()); // rip heightmap :(
}
});
}
};
}
public static PacketRemapper handleUpdateLight(final Protocol1_17To1_16_4 protocol, final PacketRemapper parentRemapper) {
final PacketRemapper classicLightHandler = new PacketRemapper() {
public static PacketHandler handleUpdateLight(final Protocol1_17To1_16_4 protocol, final PacketHandler parentHandler) {
final PacketHandler classicLightHandler = new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.VAR_INT); // x
map(Type.VAR_INT); // y
map(Type.BOOLEAN); // trust edges
@ -174,16 +160,11 @@ public class ClassicWorldHeightInjection {
}
};
return new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
return wrapper -> {
if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
classicLightHandler.remap(wrapper);
classicLightHandler.handle(wrapper);
} else {
parentRemapper.remap(wrapper);
}
});
parentHandler.handle(wrapper);
}
};
}

View File

@ -19,7 +19,7 @@ package net.raphimc.viaproxy.injection.mixins;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.EntityPackets;
@ -31,12 +31,12 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = EntityPackets.class, remap = false)
public abstract class MixinEntityPackets1_17 {
@Redirect(method = "registerPackets", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketRemapper;)V"))
private void handleClassicWorldHeight(Protocol1_17To1_16_4 instance, ClientboundPacketType packetType, PacketRemapper packetRemapper) {
if (packetType == ClientboundPackets1_16_2.JOIN_GAME) packetRemapper = ClassicWorldHeightInjection.handleJoinGame(instance, packetRemapper);
if (packetType == ClientboundPackets1_16_2.RESPAWN) packetRemapper = ClassicWorldHeightInjection.handleRespawn(instance, packetRemapper);
@Redirect(method = "registerPackets", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
private void handleClassicWorldHeight(Protocol1_17To1_16_4 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
if (packetType == ClientboundPackets1_16_2.JOIN_GAME) packetHandler = ClassicWorldHeightInjection.handleJoinGame(instance, packetHandler);
if (packetType == ClientboundPackets1_16_2.RESPAWN) packetHandler = ClassicWorldHeightInjection.handleRespawn(instance, packetHandler);
((Protocol) instance).registerClientbound(packetType, packetRemapper);
((Protocol) instance).registerClientbound(packetType, packetHandler);
}
}

View File

@ -23,11 +23,10 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(targets = "com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.InventoryPackets$3$1", remap = false)
public abstract class MixinInventoryPackets_3_1 {
@Mixin(targets = "com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.InventoryPackets$2", remap = false)
public abstract class MixinInventoryPackets_2 {
@SuppressWarnings({"UnresolvedMixinReference", "MixinAnnotationTarget"})
@Inject(method = "handle", at = @At(value = "FIELD", target = "Lcom/viaversion/viaversion/api/type/Type;BOOLEAN:Lcom/viaversion/viaversion/api/type/types/BooleanType;", ordinal = 2, shift = At.Shift.BEFORE))
@Inject(method = "lambda$register$0", at = @At(value = "FIELD", target = "Lcom/viaversion/viaversion/api/type/Type;BOOLEAN:Lcom/viaversion/viaversion/api/type/types/BooleanType;", ordinal = 2, shift = At.Shift.BEFORE))
private void removeExtraData(PacketWrapper wrapper, CallbackInfo ci) {
wrapper.clearInputBuffer();
}

View File

@ -19,7 +19,7 @@ package net.raphimc.viaproxy.injection.mixins;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
@ -43,9 +43,9 @@ public abstract class MixinProtocol1_19_1To1_19 extends AbstractProtocol<Clientb
@Inject(method = "registerPackets", at = @At("RETURN"))
private void allowSignatures(CallbackInfo ci) {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Name
read(Type.OPTIONAL_PROFILE_KEY); // Profile Key
handler(wrapper -> {
@ -55,20 +55,14 @@ public abstract class MixinProtocol1_19_1To1_19 extends AbstractProtocol<Clientb
read(Type.OPTIONAL_UUID); // Profile uuid
}
}, true);
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
@Override
public void registerMap() {
}
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), wrapper -> {
}, true);
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
@Override
public void registerMap() {
}
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), wrapper -> {
}, true);
this.registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, ServerboundPackets1_19.CHAT_MESSAGE, new PacketRemapper() {
this.registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, ServerboundPackets1_19.CHAT_MESSAGE, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Message
map(Type.LONG); // Timestamp
map(Type.LONG); // Salt

View File

@ -20,7 +20,7 @@ package net.raphimc.viaproxy.injection.mixins;
import com.google.common.primitives.Longs;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.BitSetType;
import com.viaversion.viaversion.api.type.types.ByteArrayType;
@ -63,9 +63,9 @@ public abstract class MixinProtocol1_19_3To1_19_1 extends AbstractProtocol<Clien
@Inject(method = "registerPackets", at = @At("RETURN"))
private void allowSignatures(CallbackInfo ci) {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Name
handler(wrapper -> {
final ChatSession1_19_1 chatSession = wrapper.user().get(ChatSession1_19_1.class);
@ -74,9 +74,9 @@ public abstract class MixinProtocol1_19_3To1_19_1 extends AbstractProtocol<Clien
map(Type.OPTIONAL_UUID); // Profile uuid
}
}, true);
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Server id
map(Type.BYTE_ARRAY_PRIMITIVE); // Public key
handler(wrapper -> {
@ -84,9 +84,9 @@ public abstract class MixinProtocol1_19_3To1_19_1 extends AbstractProtocol<Clien
});
}
});
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.BYTE_ARRAY_PRIMITIVE); // Public key
handler(wrapper -> {
final ChatSession1_19_1 chatSession = wrapper.user().get(ChatSession1_19_1.class);
@ -108,9 +108,9 @@ public abstract class MixinProtocol1_19_3To1_19_1 extends AbstractProtocol<Clien
}
}, true);
this.registerServerbound(ServerboundPackets1_19_3.CHAT_MESSAGE, ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketRemapper() {
this.registerServerbound(ServerboundPackets1_19_3.CHAT_MESSAGE, ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Message
map(Type.LONG); // Timestamp
map(Type.LONG); // Salt

View File

@ -17,15 +17,16 @@
*/
package net.raphimc.viaproxy.injection.mixins;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.WorldPackets;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(targets = "com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.WorldPackets$2", remap = false)
public abstract class MixinWorldPackets_2 {
@Mixin(value = WorldPackets.class, remap = false)
public abstract class MixinWorldPackets1_16_2 {
@ModifyConstant(method = "lambda$registerMap$0", constant = @Constant(intValue = 16))
private static int modifySectionCountToSupportClassicWorldHeight() {
@ModifyConstant(method = "lambda$register$1", constant = @Constant(intValue = 16))
private static int modifySectionCountToSupportClassicWorldHeight(int constant) {
return 64;
}

View File

@ -19,7 +19,7 @@ package net.raphimc.viaproxy.injection.mixins;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets.WorldPackets;
@ -31,12 +31,12 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = WorldPackets.class, remap = false)
public abstract class MixinWorldPackets1_17 {
@Redirect(method = "register", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketRemapper;)V"))
private static void handleClassicWorldHeight(Protocol1_17To1_16_4 instance, ClientboundPacketType packetType, PacketRemapper packetRemapper) {
if (packetType == ClientboundPackets1_16_2.CHUNK_DATA) packetRemapper = ClassicWorldHeightInjection.handleChunkData(instance, packetRemapper);
if (packetType == ClientboundPackets1_16_2.UPDATE_LIGHT) packetRemapper = ClassicWorldHeightInjection.handleUpdateLight(instance, packetRemapper);
@Redirect(method = "register", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4;registerClientbound(Lcom/viaversion/viaversion/api/protocol/packet/ClientboundPacketType;Lcom/viaversion/viaversion/api/protocol/remapper/PacketHandler;)V"))
private static void handleClassicWorldHeight(Protocol1_17To1_16_4 instance, ClientboundPacketType packetType, PacketHandler packetHandler) {
if (packetType == ClientboundPackets1_16_2.CHUNK_DATA) packetHandler = ClassicWorldHeightInjection.handleChunkData(instance, packetHandler);
if (packetType == ClientboundPackets1_16_2.UPDATE_LIGHT) packetHandler = ClassicWorldHeightInjection.handleUpdateLight(instance, packetHandler);
((Protocol) instance).registerClientbound(packetType, packetRemapper);
((Protocol) instance).registerClientbound(packetType, packetHandler);
}
}

View File

@ -19,7 +19,7 @@ package net.raphimc.viaproxy.injection.transformer;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18_2to1_18.Protocol1_18_2To1_18;
@ -34,18 +34,18 @@ public abstract class Protocol1_18_2To1_18Transformer extends AbstractProtocol<C
@CInject(method = "registerPackets", target = @CTarget("RETURN"))
private void fixDownloadingTerrainScreenNotClosing() {
this.registerClientbound(ClientboundPackets1_18.PLAYER_POSITION, new PacketRemapper() {
this.registerClientbound(ClientboundPackets1_18.PLAYER_POSITION, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
handler(wrapper -> {
final SpawnPositionTracker tracker = wrapper.user().get(SpawnPositionTracker.class);
tracker.sendSpawnPosition();
});
}
});
this.registerClientbound(ClientboundPackets1_18.SPAWN_POSITION, new PacketRemapper() {
this.registerClientbound(ClientboundPackets1_18.SPAWN_POSITION, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.POSITION1_14); // position
map(Type.FLOAT); // angle
handler(wrapper -> {

View File

@ -21,7 +21,7 @@ import com.google.common.primitives.Longs;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
@ -51,9 +51,9 @@ public abstract class Protocol1_18_2To1_19Transformer extends BackwardsProtocol<
@CInject(method = "registerPackets", target = @CTarget("RETURN"))
private void allowSignatures(InjectionCallback ic) {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Name
handler(wrapper -> {
final ChatSession1_19_0 chatSession = wrapper.user().get(ChatSession1_19_0.class);
@ -61,9 +61,9 @@ public abstract class Protocol1_18_2To1_19Transformer extends BackwardsProtocol<
});
}
}, true);
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Server id
map(Type.BYTE_ARRAY_PRIMITIVE); // Public key
handler(wrapper -> {
@ -71,9 +71,9 @@ public abstract class Protocol1_18_2To1_19Transformer extends BackwardsProtocol<
});
}
}, true);
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.BYTE_ARRAY_PRIMITIVE); // Public key
handler(wrapper -> {
final ChatSession1_19_0 chatSession = wrapper.user().get(ChatSession1_19_0.class);
@ -95,9 +95,9 @@ public abstract class Protocol1_18_2To1_19Transformer extends BackwardsProtocol<
}
}, true);
this.registerServerbound(ServerboundPackets1_17.CHAT_MESSAGE, ServerboundPackets1_19.CHAT_MESSAGE, new PacketRemapper() {
this.registerServerbound(ServerboundPackets1_17.CHAT_MESSAGE, ServerboundPackets1_19.CHAT_MESSAGE, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Message
handler(wrapper -> wrapper.write(Type.LONG, Instant.now().toEpochMilli())); // Timestamp
create(Type.LONG, 0L); // Salt

View File

@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.storage.ReceivedMessagesStorage;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
@ -48,9 +48,9 @@ public abstract class Protocol1_19To1_19_1Transformer extends BackwardsProtocol<
@CInject(method = "registerPackets", target = @CTarget("RETURN"))
private void allowSignatures(InjectionCallback ic) {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Name
read(Type.OPTIONAL_PROFILE_KEY); // Profile Key
handler(wrapper -> {
@ -60,20 +60,14 @@ public abstract class Protocol1_19To1_19_1Transformer extends BackwardsProtocol<
});
}
}, true);
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
@Override
public void registerMap() {
}
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), wrapper -> {
}, true);
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
@Override
public void registerMap() {
}
this.registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), wrapper -> {
}, true);
this.registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketRemapper() {
this.registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Message
map(Type.LONG); // Timestamp
map(Type.LONG); // Salt

View File

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.BitSetType;
import com.viaversion.viaversion.api.type.types.ByteArrayType;
@ -49,9 +49,9 @@ public abstract class Protocol1_19_1To1_19_3Transformer extends BackwardsProtoco
@CInject(method = "registerPackets", target = @CTarget("RETURN"))
private void allowSignatures(InjectionCallback ic) {
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketRemapper() {
this.registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
handler(wrapper -> {
final ChatSession1_19_3 chatSession = wrapper.user().get(ChatSession1_19_3.class);
@ -65,9 +65,9 @@ public abstract class Protocol1_19_1To1_19_3Transformer extends BackwardsProtoco
}
}, true);
this.registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, ServerboundPackets1_19_3.CHAT_MESSAGE, new PacketRemapper() {
this.registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, ServerboundPackets1_19_3.CHAT_MESSAGE, new PacketHandlers() {
@Override
public void registerMap() {
public void register() {
map(Type.STRING); // Message
map(Type.LONG); // Timestamp
map(Type.LONG); // Salt