diff --git a/build.gradle b/build.gradle index 4c3da9a..c2ce795 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/gradle.properties b/gradle.properties index 5aa4036..ef51c01 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java b/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java index 11543e7..aaca587 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java +++ b/src/main/java/net/raphimc/viaproxy/injection/ClassicWorldHeightInjection.java @@ -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,85 +41,70 @@ 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); - if (wrapper.isCancelled()) return; + 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)) { - for (Tag dimension : wrapper.get(Type.NBT, 0).get("minecraft:dimension_type").get("value")) { - changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element")); - } - changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NBT, 1)); - } - }); + if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { + for (Tag dimension : wrapper.get(Type.NBT, 0).get("minecraft:dimension_type").get("value")) { + changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element")); + } + 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); - if (wrapper.isCancelled()) return; + 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)); - } - }); + 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); - if (wrapper.isCancelled()) return; + 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)) { - wrapper.resetReader(); - final Chunk chunk = wrapper.read(new Chunk1_17Type(16)); - wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk); + if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { + wrapper.resetReader(); + final Chunk chunk = wrapper.read(new Chunk1_17Type(16)); + wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk); - final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class); - if (chunk.getSections().length < heightProvider.getMaxChunkSectionCount(wrapper.user())) { // Increase available sections to match new world height - final ChunkSection[] newArray = new ChunkSection[heightProvider.getMaxChunkSectionCount(wrapper.user())]; - System.arraycopy(chunk.getSections(), 0, newArray, 0, chunk.getSections().length); - chunk.setSections(newArray); - } + final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class); + if (chunk.getSections().length < heightProvider.getMaxChunkSectionCount(wrapper.user())) { // Increase available sections to match new world height + final ChunkSection[] newArray = new ChunkSection[heightProvider.getMaxChunkSectionCount(wrapper.user())]; + System.arraycopy(chunk.getSections(), 0, newArray, 0, chunk.getSections().length); + chunk.setSections(newArray); + } - final BitSet chunkMask = new BitSet(); - for (int i = 0; i < chunk.getSections().length; i++) { - if (chunk.getSections()[i] != null) chunkMask.set(i); - } - chunk.setChunkMask(chunkMask); + final BitSet chunkMask = new BitSet(); + for (int i = 0; i < chunk.getSections().length; i++) { + if (chunk.getSections()[i] != null) chunkMask.set(i); + } + chunk.setChunkMask(chunkMask); - final int[] newBiomeData = new int[chunk.getSections().length * 4 * 4 * 4]; - System.arraycopy(chunk.getBiomeData(), 0, newBiomeData, 0, chunk.getBiomeData().length); - for (int i = 64; i < chunk.getSections().length * 4; i++) { // copy top layer of old biome data all the way to max world height - System.arraycopy(chunk.getBiomeData(), chunk.getBiomeData().length - 16, newBiomeData, i * 16, 16); - } - chunk.setBiomeData(newBiomeData); + final int[] newBiomeData = new int[chunk.getSections().length * 4 * 4 * 4]; + System.arraycopy(chunk.getBiomeData(), 0, newBiomeData, 0, chunk.getBiomeData().length); + for (int i = 64; i < chunk.getSections().length * 4; i++) { // copy top layer of old biome data all the way to max world height + System.arraycopy(chunk.getBiomeData(), chunk.getBiomeData().length - 16, newBiomeData, i * 16, 16); + } + chunk.setBiomeData(newBiomeData); - chunk.setHeightMap(new CompoundTag()); // rip heightmap :( - } - }); + 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 -> { - if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { - classicLightHandler.remap(wrapper); - } else { - parentRemapper.remap(wrapper); - } - }); + return wrapper -> { + if (VersionEnum.fromUserConnection(wrapper.user()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) { + classicLightHandler.handle(wrapper); + } else { + parentHandler.handle(wrapper); } }; } diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinEntityPackets1_17.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinEntityPackets1_17.java index 2a796df..63b0759 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinEntityPackets1_17.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinEntityPackets1_17.java @@ -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); } } diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinInventoryPackets_3_1.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinInventoryPackets_2.java similarity index 76% rename from src/main/java/net/raphimc/viaproxy/injection/mixins/MixinInventoryPackets_3_1.java rename to src/main/java/net/raphimc/viaproxy/injection/mixins/MixinInventoryPackets_2.java index c1e2087..ccdc97d 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinInventoryPackets_3_1.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinInventoryPackets_2.java @@ -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(); } diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_1To1_19.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_1To1_19.java index f4580c2..9bc85a3 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_1To1_19.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_1To1_19.java @@ -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 { @@ -55,20 +55,14 @@ public abstract class MixinProtocol1_19_1To1_19 extends AbstractProtocol { }, 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 diff --git a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_3To1_19_1.java b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_3To1_19_1.java index 5c44b8f..b047ca3 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_3To1_19_1.java +++ b/src/main/java/net/raphimc/viaproxy/injection/mixins/MixinProtocol1_19_3To1_19_1.java @@ -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 { 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 { @@ -84,9 +84,9 @@ public abstract class MixinProtocol1_19_3To1_19_1 extends AbstractProtocol { 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 { 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 -> { diff --git a/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_18_2To1_19Transformer.java b/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_18_2To1_19Transformer.java index c9ea9b8..7586db8 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_18_2To1_19Transformer.java +++ b/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_18_2To1_19Transformer.java @@ -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 diff --git a/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19To1_19_1Transformer.java b/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19To1_19_1Transformer.java index 1bd262a..c7fdde8 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19To1_19_1Transformer.java +++ b/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19To1_19_1Transformer.java @@ -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 diff --git a/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19_1To1_19_3Transformer.java b/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19_1To1_19_3Transformer.java index b312c14..acea5ed 100644 --- a/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19_1To1_19_3Transformer.java +++ b/src/main/java/net/raphimc/viaproxy/injection/transformer/Protocol1_19_1To1_19_3Transformer.java @@ -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