From 7f85d074afe6c96e8dd53ae5a296b8babaf164f6 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 19 Oct 2023 21:31:00 +1000 Subject: [PATCH] Update VV usage --- .../api/rewriters/EntityRewriterBase.java | 2 +- .../api/rewriters/ItemRewriterBase.java | 2 +- .../api/rewriters/LegacyEntityRewriter.java | 2 +- .../Protocol1_10To1_11.java | 2 +- .../packets/BlockItemPackets1_11.java | 33 +++++----- .../packets/EntityPackets1_11.java | 2 +- .../packets/PlayerPackets1_11.java | 2 +- .../Protocol1_11_1To1_12.java | 2 +- .../packets/BlockItemPackets1_12.java | 31 +++++---- .../Protocol1_11To1_11_1.java | 2 +- .../packets/ItemPackets1_11_1.java | 16 ++--- .../Protocol1_12_2To1_13.java | 2 +- .../packets/BlockItemPackets1_13.java | 40 +++++------ .../packets/PlayerPacket1_13.java | 14 ++-- .../Protocol1_13_1To1_13_2.java | 4 +- .../packets/InventoryPackets1_13_2.java | 28 ++++---- .../packets/WorldPackets1_13_2.java | 2 +- .../Protocol1_13_2To1_14.java | 2 +- .../packets/BlockItemPackets1_14.java | 66 +++++++++---------- .../packets/EntityPackets1_14.java | 12 ++-- .../packets/PlayerPackets1_14.java | 14 ++-- .../Protocol1_13To1_13_1.java | 2 +- .../packets/WorldPackets1_13_1.java | 14 ++-- .../Protocol1_14_2To1_14_3.java | 6 +- .../Protocol1_14_3To1_14_4.java | 6 +- .../packets/BlockItemPackets1_15.java | 28 ++++---- .../Protocol1_15_2To1_16.java | 3 +- .../packets/BlockItemPackets1_16.java | 36 +++++----- .../packets/EntityPackets1_16.java | 4 +- .../packets/BlockItemPackets1_16_2.java | 24 +++---- .../Protocol1_16_3To1_16_4.java | 2 +- .../packets/BlockItemPackets1_17.java | 28 ++++---- .../packets/BlockItemPackets1_18.java | 14 ++-- .../Protocol1_17To1_17_1.java | 6 +- .../packets/BlockItemPackets1_19.java | 18 ++--- .../packets/BlockItemPackets1_19_3.java | 22 +++---- .../packets/BlockItemPackets1_19_4.java | 20 +++--- .../packets/BlockItemPackets1_20.java | 10 +-- .../BlockItemPacketRewriter1_20_3.java | 2 +- .../BlockItemPacketRewriter1_20_2.java | 46 ++++++------- .../Protocol1_9_1_2To1_9_3_4.java | 16 ++--- .../chunks/BlockEntity.java | 2 +- .../Protocol1_9_4To1_10.java | 2 +- .../packets/BlockItemPackets1_10.java | 24 +++---- .../rewriter/BlockItemPacketRewriter1_99.java | 2 +- 45 files changed, 307 insertions(+), 310 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java index cdb632ff..7053941e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java @@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.Int2IntMapMappings; import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.TrackedEntity; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -35,7 +36,6 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import com.viaversion.viaversion.libs.gson.JsonElement; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent; import java.util.List; diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java index 987603f3..ba1b83bd 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriterBase.java @@ -36,7 +36,7 @@ public abstract class ItemRewriterBase itemType, Type itemArrayType, boolean jsonNameFormat) { diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java index 7aea75bc..8edde4ff 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEntityRewriter.java @@ -22,6 +22,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.entities.storage.EntityData; import com.viaversion.viabackwards.api.entities.storage.EntityObjectData; import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.ObjectType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; @@ -32,7 +33,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 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.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java index b2b154a3..23cb073d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java @@ -26,11 +26,11 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPac import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11; import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class Protocol1_10To1_11 extends BackwardsProtocol { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java index f0b9016a..79d8bf90 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/BlockItemPackets1_11.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11; import com.viaversion.viaversion.api.minecraft.item.DataItem; @@ -36,6 +37,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 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.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; @@ -43,9 +45,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type; - import java.util.Arrays; import java.util.Optional; @@ -64,9 +63,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter Trading protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() { @@ -128,12 +127,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { @@ -173,12 +172,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed. + ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); // Use the 1.10 Chunk type since nothing changed. Chunk chunk = wrapper.passthrough(type); handleChunk(chunk); @@ -198,7 +197,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { @@ -226,7 +225,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { - if (meta.metaType().type().equals(Type.ITEM)) // Is Item + if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java index 48b16e33..0eb74c80 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java @@ -50,7 +50,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter { int type = wrapper.get(Type.INT, 0); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java index 831a3a9d..751f8039 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/PlayerPackets1_11.java @@ -81,7 +81,7 @@ public class PlayerPackets1_11 { protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() { @Override public void register() { - map(Type.POSITION); // 0 - Location + map(Type.POSITION1_8); // 0 - Location map(Type.VAR_INT); // 1 - Face map(Type.VAR_INT); // 2 - Hand diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java index c01aa6c3..7decd736 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java @@ -26,6 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPac import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -34,7 +35,6 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; public class Protocol1_11_1To1_12 extends BackwardsProtocol { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java index 4430f086..6bfb89eb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/BlockItemPackets1_12.java @@ -22,11 +22,13 @@ import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag; @@ -34,11 +36,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import java.util.Iterator; import java.util.Map; - -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type; import org.checkerframework.checker.nullness.qual.Nullable; public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { @@ -81,9 +80,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter Trading protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketHandlers() { @@ -97,12 +96,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click @@ -129,7 +128,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed. + ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); // Use the 1.9.4 Chunk type since nothing changed. Chunk chunk = wrapper.passthrough(type); handleChunk(chunk); @@ -163,7 +162,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { @@ -191,7 +190,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { - if (meta.metaType().type().equals(Type.ITEM)) // Is Item + if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/Protocol1_11To1_11_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/Protocol1_11To1_11_1.java index b2db518d..91838e9a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/Protocol1_11To1_11_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/Protocol1_11To1_11_1.java @@ -22,11 +22,11 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1; import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class Protocol1_11To1_11_1 extends BackwardsProtocol { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java index 2ca61ed9..5345d692 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11to1_11_1/packets/ItemPackets1_11_1.java @@ -39,9 +39,9 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter Trading protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() { @@ -55,12 +55,12 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter { - if (meta.metaType().type().equals(Type.ITEM)) { // Is Item + if (meta.metaType().type().equals(Type.ITEM1_8)) { // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); } }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java index edcb46be..09d0f26d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java @@ -33,6 +33,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerP import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -46,7 +47,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.ComponentRewriter; import org.checkerframework.checker.nullness.qual.Nullable; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index 22a75624..be58f72d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -28,6 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.Backwar import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; @@ -37,6 +38,8 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry; import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; @@ -53,9 +56,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter; -import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type; import com.viaversion.viaversion.util.Key; import java.util.ArrayList; import java.util.HashMap; @@ -109,7 +109,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() { @Override public void register() { - map(Type.POSITION); // Location + map(Type.POSITION1_8); // Location map(Type.UNSIGNED_BYTE); // Action Id map(Type.UNSIGNED_BYTE); // Action param map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID @@ -145,7 +145,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.POSITION); // 0 - Position + map(Type.POSITION1_8); // 0 - Position map(Type.UNSIGNED_BYTE); // 1 - Action map(Type.NAMED_COMPOUND_TAG); // 2 - NBT Data @@ -160,7 +160,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit wrapper.set(Type.NAMED_COMPOUND_TAG, 0, provider.transform( wrapper.user(), - wrapper.get(Type.POSITION, 0), + wrapper.get(Type.POSITION1_8, 0), wrapper.get(Type.NAMED_COMPOUND_TAG, 0) )); }); @@ -184,11 +184,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketHandlers() { @Override public void register() { - map(Type.POSITION); // 0 - Position + map(Type.POSITION1_8); // 0 - Position handler(wrapper -> { int blockState = wrapper.read(Type.VAR_INT); - Position position = wrapper.get(Type.POSITION, 0); + Position position = wrapper.get(Type.POSITION1_8, 0); // Store blocks BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class); @@ -249,17 +249,17 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit public void register() { map(Type.UNSIGNED_BYTE); map(Type.SHORT); - map(Type.ITEM1_13, Type.ITEM); + map(Type.ITEM1_13, Type.ITEM1_8); - handler(itemToClientHandler(Type.ITEM)); + handler(itemToClientHandler(Type.ITEM1_8)); } }); protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld); - Chunk1_13Type type = new Chunk1_13Type(clientWorld); + ChunkType1_9_3 type_old = new ChunkType1_9_3(clientWorld); + ChunkType1_13 type = new ChunkType1_13(clientWorld); Chunk chunk = wrapper.read(type); // Handle Block Entities before block rewrite @@ -371,7 +371,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit @Override public void register() { map(Type.INT); // Effect Id - map(Type.POSITION); // Location + map(Type.POSITION1_8); // Location map(Type.INT); // Data handler(wrapper -> { int id = wrapper.get(Type.INT, 0); @@ -421,9 +421,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit public void register() { map(Type.VAR_INT); map(Type.VAR_INT); - map(Type.ITEM1_13, Type.ITEM); + map(Type.ITEM1_13, Type.ITEM1_8); - handler(itemToClientHandler(Type.ITEM)); + handler(itemToClientHandler(Type.ITEM1_8)); } }); @@ -449,7 +449,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit @Override public void register() { map(Type.SHORT); - map(Type.ITEM, Type.ITEM1_13); + map(Type.ITEM1_8, Type.ITEM1_13); handler(itemToServerHandler(Type.ITEM1_13)); } @@ -463,7 +463,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit map(Type.BYTE); map(Type.SHORT); map(Type.VAR_INT); - map(Type.ITEM, Type.ITEM1_13); + map(Type.ITEM1_8, Type.ITEM1_13); handler(itemToServerHandler(Type.ITEM1_13)); } @@ -966,19 +966,19 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit // Remove the flowerpot PacketWrapper blockUpdateRemove = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_CHANGE, user); - blockUpdateRemove.write(Type.POSITION, position); + blockUpdateRemove.write(Type.POSITION1_8, position); blockUpdateRemove.write(Type.VAR_INT, 0); blockUpdateRemove.scheduleSend(Protocol1_12_2To1_13.class); // Create the flowerpot PacketWrapper blockCreate = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_CHANGE, user); - blockCreate.write(Type.POSITION, position); + blockCreate.write(Type.POSITION1_8, position); blockCreate.write(Type.VAR_INT, Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState)); blockCreate.scheduleSend(Protocol1_12_2To1_13.class); // Send a block entity update PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, user); - wrapper.write(Type.POSITION, position); + wrapper.write(Type.POSITION1_8, position); wrapper.write(Type.UNSIGNED_BYTE, (short) 5); wrapper.write(Type.NAMED_COMPOUND_TAG, nbt); wrapper.scheduleSend(Protocol1_12_2To1_13.class); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index 788bbd1a..997a97e3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -82,16 +82,16 @@ public class PlayerPacket1_13 extends RewriterBase { for (int i = 0; i < size; i++) { //Input Item Item input = wrapper.read(Type.ITEM1_13); - wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input)); + wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(input)); //Output Item Item output = wrapper.read(Type.ITEM1_13); - wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output)); + wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(output)); boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item if (secondItem) { //Second Item Item second = wrapper.read(Type.ITEM1_13); - wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second)); + wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(second)); } wrapper.passthrough(Type.BOOLEAN); //Trade disabled @@ -332,7 +332,7 @@ public class PlayerPacket1_13 extends RewriterBase { String command = wrapper.read(Type.STRING); boolean assumeCommand = wrapper.read(Type.BOOLEAN); - wrapper.read(Type.OPTIONAL_POSITION); + wrapper.read(Type.OPTIONAL_POSITION1_8); if (!assumeCommand && !command.startsWith("/")) { // Complete usernames for non-commands @@ -382,7 +382,7 @@ public class PlayerPacket1_13 extends RewriterBase { case "MC|BSign": case "MC|BEdit": wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK); - Item book = wrapper.read(Type.ITEM); + Item book = wrapper.read(Type.ITEM1_8); wrapper.write(Type.ITEM1_13, protocol.getItemRewriter().handleItemToServer(book)); boolean signing = channel.equals("MC|BSign"); wrapper.write(Type.BOOLEAN, signing); @@ -416,7 +416,7 @@ public class PlayerPacket1_13 extends RewriterBase { int y = wrapper.read(Type.INT); int z = wrapper.read(Type.INT); - wrapper.write(Type.POSITION, new Position(x, (short) y, z)); + wrapper.write(Type.POSITION1_8, new Position(x, (short) y, z)); wrapper.passthrough(Type.STRING); //Command @@ -439,7 +439,7 @@ public class PlayerPacket1_13 extends RewriterBase { int x = wrapper.read(Type.INT); int y = wrapper.read(Type.INT); int z = wrapper.read(Type.INT); - wrapper.write(Type.POSITION, new Position(x, (short) y, z)); + wrapper.write(Type.POSITION1_8, new Position(x, (short) y, z)); wrapper.write(Type.VAR_INT, wrapper.read(Type.BYTE) - 1); String mode = wrapper.read(Type.STRING); int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java index 9d596126..6fce03b4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_1to1_13_2/Protocol1_13_1To1_13_2.java @@ -42,7 +42,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol { int id = wrapper.get(Type.INT, 0); if (id == 27) { - wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM)); + wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2)); } }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java index d2a97c51..2ed47e04 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/Protocol1_13_2To1_14.java @@ -28,6 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPa import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; @@ -36,7 +37,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPacke import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index 39c72ccd..e585b68c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage; import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; @@ -30,12 +31,14 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLight; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLightImpl; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.minecraft.entities.EntityType; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14; import com.viaversion.viaversion.api.type.types.version.Types1_13; import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -47,11 +50,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; -import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; -import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; import java.util.ArrayList; @@ -68,7 +68,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit @Override protected void registerPackets() { - protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); + protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2))); protocol.registerClientbound(ClientboundPackets1_14.OPEN_WINDOW, wrapper -> { int windowId = wrapper.read(Type.VAR_INT); @@ -166,12 +166,12 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit wrapper.passthrough(Type.INT); // Entity id }); - BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION); + BlockRewriter blockRewriter = BlockRewriter.legacy(protocol); registerSetCooldown(ClientboundPackets1_14.COOLDOWN); - registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); - registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM); - registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); + registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY); + registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.ITEM1_13_2); + registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.ITEM1_13_2); // Trade List -> Plugin Message protocol.registerClientbound(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> { @@ -183,22 +183,22 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit int size = wrapper.passthrough(Type.UNSIGNED_BYTE); for (int i = 0; i < size; i++) { // Input Item - Item input = wrapper.read(Type.FLAT_VAR_INT_ITEM); + Item input = wrapper.read(Type.ITEM1_13_2); input = handleItemToClient(input); - wrapper.write(Type.FLAT_VAR_INT_ITEM, input); + wrapper.write(Type.ITEM1_13_2, input); // Output Item - Item output = wrapper.read(Type.FLAT_VAR_INT_ITEM); + Item output = wrapper.read(Type.ITEM1_13_2); output = handleItemToClient(output); - wrapper.write(Type.FLAT_VAR_INT_ITEM, output); + wrapper.write(Type.ITEM1_13_2, output); boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item if (secondItem) { // Second Item - Item second = wrapper.read(Type.FLAT_VAR_INT_ITEM); + Item second = wrapper.read(Type.ITEM1_13_2); second = handleItemToClient(second); - wrapper.write(Type.FLAT_VAR_INT_ITEM, second); + wrapper.write(Type.ITEM1_13_2, second); } wrapper.passthrough(Type.BOOLEAN); // Trade disabled @@ -225,9 +225,9 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit public void register() { map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 1 - Slot ID - map(Type.FLAT_VAR_INT_ITEM); // 2 - Item + map(Type.ITEM1_13_2); // 2 - Item - handler(itemToClientHandler(Type.FLAT_VAR_INT_ITEM)); + handler(itemToClientHandler(Type.ITEM1_13_2)); handler(wrapper -> { int entityId = wrapper.get(Type.VAR_INT, 0); @@ -239,7 +239,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit wrapper.resetReader(); wrapper.passthrough(Type.VAR_INT); wrapper.read(Type.VAR_INT); - Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM); + Item item = wrapper.read(Type.ITEM1_13_2); int armorType = item == null || item.identifier() == 0 ? 0 : item.identifier() - 726; if (armorType < 0 || armorType > 3) { wrapper.cancel(); @@ -268,15 +268,15 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit case "smoking": case "campfire_cooking": wrapper.read(Type.STRING); // Group - wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - wrapper.read(Type.FLAT_VAR_INT_ITEM); + wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients + wrapper.read(Type.ITEM1_13_2); wrapper.read(Type.FLOAT); // EXP wrapper.read(Type.VAR_INT); // Cooking time break; case "stonecutting": wrapper.read(Type.STRING); // Group? - wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients - wrapper.read(Type.FLAT_VAR_INT_ITEM); // Result + wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients + wrapper.read(Type.ITEM1_13_2); // Result break; } deleted++; @@ -292,14 +292,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit }); - registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); - registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); + registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.ITEM1_13_2); + registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2); protocol.registerClientbound(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketHandlers() { @Override public void register() { map(Type.VAR_INT); - map(Type.POSITION1_14, Type.POSITION); + map(Type.POSITION1_14, Type.POSITION1_8); map(Type.BYTE); } }); @@ -307,14 +307,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION); + map(Type.POSITION1_14, Type.POSITION1_8); } }); protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ACTION, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION); // Location + map(Type.POSITION1_14, Type.POSITION1_8); // Location map(Type.UNSIGNED_BYTE); // Action id map(Type.UNSIGNED_BYTE); // Action param map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE @@ -332,7 +332,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_14.BLOCK_CHANGE, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION); + map(Type.POSITION1_14, Type.POSITION1_8); map(Type.VAR_INT); handler(wrapper -> { int id = wrapper.get(Type.VAR_INT, 0); @@ -366,8 +366,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk chunk = wrapper.read(new Chunk1_14Type()); - wrapper.write(new Chunk1_13Type(clientWorld), chunk); + Chunk chunk = wrapper.read(new ChunkType1_14()); + wrapper.write(new ChunkType1_13(clientWorld), chunk); ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ()); for (int i = 0; i < chunk.getSections().length; i++) { @@ -421,7 +421,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit @Override public void register() { map(Type.INT); // Effect Id - map(Type.POSITION1_14, Type.POSITION); // Location + map(Type.POSITION1_14, Type.POSITION1_8); // Location map(Type.INT); // Data handler(wrapper -> { int id = wrapper.get(Type.INT, 0); @@ -435,7 +435,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit } }); - registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.FLOAT); + registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.FLOAT); protocol.registerClientbound(ClientboundPackets1_14.MAP_DATA, new PacketHandlers() { @Override @@ -450,7 +450,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit protocol.registerClientbound(ClientboundPackets1_14.SPAWN_POSITION, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION); + map(Type.POSITION1_14, Type.POSITION1_8); } }); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java index d1d55d12..f4c73edd 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java @@ -26,11 +26,12 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLi import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14; import com.viaversion.viaversion.api.data.entity.EntityTracker; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.VillagerData; +import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; -import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -40,7 +41,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.meta.MetaHandler; public class EntityPackets1_14 extends LegacyEntityRewriter { @@ -58,7 +58,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { protocol.registerClientbound(ClientboundPackets1_14.OPEN_SIGN_EDITOR, new PacketHandlers() { @Override public void register() { - map(Type.POSITION1_14, Type.POSITION); + map(Type.POSITION1_14, Type.POSITION1_8); } }); protocol.registerServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT, new PacketHandlers() { @Override public void register() { map(Type.VAR_INT); - map(Type.POSITION, Type.POSITION1_14); + map(Type.POSITION1_8, Type.POSITION1_14); } }); protocol.registerServerbound(ServerboundPackets1_13.PLAYER_DIGGING, new PacketHandlers() { @Override public void register() { map(Type.VAR_INT); // Action - map(Type.POSITION, Type.POSITION1_14); // Position + map(Type.POSITION1_8, Type.POSITION1_14); // Position } }); @@ -94,24 +94,24 @@ public class PlayerPackets1_14 extends RewriterBase { protocol.registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, new PacketHandlers() { @Override public void register() { - map(Type.POSITION, Type.POSITION1_14); + map(Type.POSITION1_8, Type.POSITION1_14); } }); protocol.registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, new PacketHandlers() { @Override public void register() { - map(Type.POSITION, Type.POSITION1_14); + map(Type.POSITION1_8, Type.POSITION1_14); } }); protocol.registerServerbound(ServerboundPackets1_13.UPDATE_SIGN, new PacketHandlers() { @Override public void register() { - map(Type.POSITION, Type.POSITION1_14); + map(Type.POSITION1_8, Type.POSITION1_14); } }); protocol.registerServerbound(ServerboundPackets1_13.PLAYER_BLOCK_PLACEMENT, wrapper -> { - Position position = wrapper.read(Type.POSITION); + Position position = wrapper.read(Type.POSITION1_8); int face = wrapper.read(Type.VAR_INT); int hand = wrapper.read(Type.VAR_INT); float x = wrapper.read(Type.FLOAT); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index e66ce219..1c511c6d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -26,6 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityP import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1; import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -40,7 +41,6 @@ import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java index 9de4a9aa..5291af68 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/WorldPackets1_13_1.java @@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets; import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1; import com.viaversion.viaversion.api.minecraft.BlockFace; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; @@ -26,19 +27,18 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; -import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.rewriter.BlockRewriter; public class WorldPackets1_13_1 { public static void register(Protocol1_13To1_13_1 protocol) { - BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION); + BlockRewriter blockRewriter = BlockRewriter.legacy(protocol); protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld)); + Chunk chunk = wrapper.passthrough(new ChunkType1_13(clientWorld)); for (ChunkSection section : chunk.getSections()) { if (section == null) { @@ -60,7 +60,7 @@ public class WorldPackets1_13_1 { @Override public void register() { map(Type.INT); // Effect Id - map(Type.POSITION); // Location + map(Type.POSITION1_8); // Location map(Type.INT); // Data handler(wrapper -> { int id = wrapper.get(Type.INT, 0); @@ -73,9 +73,9 @@ public class WorldPackets1_13_1 { switch (data) { case 0: // Down case 1: // Up - Position pos = wrapper.get(Type.POSITION, 0); + Position pos = wrapper.get(Type.POSITION1_8, 0); BlockFace relative = data == 0 ? BlockFace.BOTTOM : BlockFace.TOP; - wrapper.set(Type.POSITION, 0, pos.getRelative(relative)); // Y Offset + wrapper.set(Type.POSITION1_8, 0, pos.getRelative(relative)); // Y Offset wrapper.set(Type.INT, 1, 4); // Self break; case 2: // North diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java index 7c4e8ac8..a842912c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_2to1_14_3/Protocol1_14_2To1_14_3.java @@ -35,10 +35,10 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); new RecipeRewriter<>(protocol).register(ClientboundPackets1_15.DECLARE_RECIPES); - protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); + protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2))); registerSetCooldown(ClientboundPackets1_15.COOLDOWN); - registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); - registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM); + registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY); + registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.ITEM1_13_2); registerTradeList(ClientboundPackets1_15.TRADE_LIST); - registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); - registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); - registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); - registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); + registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.ITEM1_13_2); + registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.ITEM1_13_2); + registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.ITEM1_13_2); + registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING); blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION); @@ -61,8 +61,8 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE); protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, wrapper -> { - Chunk chunk = wrapper.read(new Chunk1_15Type()); - wrapper.write(new Chunk1_14Type(), chunk); + Chunk chunk = wrapper.read(new ChunkType1_15()); + wrapper.write(new ChunkType1_14(), chunk); if (chunk.isFullChunk()) { int[] biomeData = chunk.getBiomeData(); @@ -122,8 +122,8 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit int data = wrapper.passthrough(Type.VAR_INT); wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data)); } else if (id == 32) { - Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM)); - wrapper.write(Type.FLAT_VAR_INT_ITEM, item); + Item item = handleItemToClient(wrapper.read(Type.ITEM1_13_2)); + wrapper.write(Type.ITEM1_13_2, item); } int mappedId = protocol.getMappingData().getNewParticleId(id); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java index 58b863c1..ee46043c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/Protocol1_15_2To1_16.java @@ -27,6 +27,7 @@ import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.packets.BlockIt import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets1_16; import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16; import com.viaversion.viaversion.api.protocol.packet.State; @@ -39,8 +40,6 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPacke import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.GsonUtil; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java index 5fbfc7ef..6e3b9393 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java @@ -33,6 +33,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.UUIDIntArrayType; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag; @@ -42,10 +44,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; -import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.InventoryPackets; -import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; import com.viaversion.viaversion.util.CompactArrayUtil; @@ -65,7 +65,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit @Override protected void registerPackets() { - BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); RecipeRewriter recipeRewriter = new RecipeRewriter<>(protocol); // Remove new smithing type, only in this handler @@ -79,9 +79,9 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit newSize--; wrapper.read(Type.STRING); - wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); - wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); - wrapper.read(Type.FLAT_VAR_INT_ITEM); + wrapper.read(Type.ITEM1_13_2_ARRAY); + wrapper.read(Type.ITEM1_13_2_ARRAY); + wrapper.read(Type.ITEM1_13_2); continue; } @@ -94,10 +94,10 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit }); registerSetCooldown(ClientboundPackets1_16.COOLDOWN); - registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); - registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM); + registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY); + registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.ITEM1_13_2); registerTradeList(ClientboundPackets1_16.TRADE_LIST); - registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); + registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.ITEM1_13_2); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING); blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION); @@ -111,7 +111,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit byte slot; do { slot = wrapper.read(Type.BYTE); - Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM)); + Item item = handleItemToClient(wrapper.read(Type.ITEM1_13_2)); int rawSlot = slot & 0x7F; equipmentData.add(new EquipmentData(rawSlot, item)); } while ((slot & 0xFFFFFF80) != 0); @@ -119,7 +119,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit // Send first data in the current packet EquipmentData firstData = equipmentData.get(0); wrapper.write(Type.VAR_INT, firstData.slot); - wrapper.write(Type.FLAT_VAR_INT_ITEM, firstData.item); + wrapper.write(Type.ITEM1_13_2, firstData.item); // If there are more items, send new packets for them for (int i = 1; i < equipmentData.size(); i++) { @@ -127,7 +127,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit EquipmentData data = equipmentData.get(i); equipmentPacket.write(Type.VAR_INT, entityId); equipmentPacket.write(Type.VAR_INT, data.slot); - equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, data.item); + equipmentPacket.write(Type.ITEM1_13_2, data.item); equipmentPacket.send(Protocol1_15_2To1_16.class); } }); @@ -142,8 +142,8 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit }); protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, wrapper -> { - Chunk chunk = wrapper.read(new Chunk1_16Type()); - wrapper.write(new Chunk1_15Type(), chunk); + Chunk chunk = wrapper.read(new ChunkType1_16()); + wrapper.write(new ChunkType1_15(), chunk); for (int i = 0; i < chunk.getSections().length; i++) { ChunkSection section = chunk.getSections()[i]; @@ -201,7 +201,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001); - registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE); + registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.DOUBLE); protocol.registerClientbound(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketHandlers() { @Override @@ -241,10 +241,10 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit handleBlockEntity(tag); }); - registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); - registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); + registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.ITEM1_13_2); + registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2); - protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); + protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2))); } private void handleBlockEntity(CompoundTag tag) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java index 3d932897..fe79727c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java @@ -23,9 +23,10 @@ import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameT import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.WolfDataMaskStorage; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.data.entity.StoredEntityData; +import com.viaversion.viaversion.api.minecraft.ClientWorld; +import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16; -import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -40,7 +41,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_16; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.util.Key; public class EntityPackets1_16 extends EntityRewriter { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java index 75df2a4d..f940c54c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java @@ -26,15 +26,15 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; -import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; -import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; @@ -46,16 +46,16 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr @Override protected void registerPackets() { - BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); new RecipeRewriter<>(protocol).register(ClientboundPackets1_16_2.DECLARE_RECIPES); registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN); - registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); - registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM); + registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY); + registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.ITEM1_13_2); registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT); registerTradeList(ClientboundPackets1_16_2.TRADE_LIST); - registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); + registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.ITEM1_13_2); protocol.registerClientbound(ClientboundPackets1_16_2.UNLOCK_RECIPES, wrapper -> { wrapper.passthrough(Type.VAR_INT); @@ -75,8 +75,8 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE); protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, wrapper -> { - Chunk chunk = wrapper.read(new Chunk1_16_2Type()); - wrapper.write(new Chunk1_16Type(), chunk); + Chunk chunk = wrapper.read(new ChunkType1_16_2()); + wrapper.write(new ChunkType1_16(), chunk); chunk.setIgnoreOldLightData(true); for (int i = 0; i < chunk.getSections().length; i++) { @@ -132,11 +132,11 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001); - registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE); + registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.DOUBLE); - registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); - registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); - protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); + registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.ITEM1_13_2); + registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2); + protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2))); } private void handleBlockEntity(CompoundTag tag) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_3to1_16_4/Protocol1_16_3To1_16_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_3to1_16_4/Protocol1_16_3To1_16_4.java index bc99a603..4a90ce95 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_3to1_16_4/Protocol1_16_3To1_16_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_3to1_16_4/Protocol1_16_3To1_16_4.java @@ -36,7 +36,7 @@ public class Protocol1_16_3To1_16_4 extends BackwardsProtocol { int slot = wrapper.read(Type.VAR_INT); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/BlockItemPackets1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/BlockItemPackets1_17.java index b02e1345..42f4ca29 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/BlockItemPackets1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/BlockItemPackets1_17.java @@ -34,16 +34,16 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; -import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; -import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; import com.viaversion.viaversion.util.CompactArrayUtil; @@ -61,23 +61,23 @@ public final class BlockItemPackets1_17 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); new RecipeRewriter<>(protocol).register(ClientboundPackets1_17.DECLARE_RECIPES); registerSetCooldown(ClientboundPackets1_17.COOLDOWN); - registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); + registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY); registerEntityEquipmentArray(ClientboundPackets1_17.ENTITY_EQUIPMENT); registerTradeList(ClientboundPackets1_17.TRADE_LIST); - registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); + registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS, Type.ITEM1_13_2); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_17.ACKNOWLEDGE_PLAYER_DIGGING); blockRewriter.registerBlockAction(ClientboundPackets1_17.BLOCK_ACTION); blockRewriter.registerEffect(ClientboundPackets1_17.EFFECT, 1010, 2001); - registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); - protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); + registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2); + protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2))); // TODO Since the carried and modified items are typically set incorrectly, the server sends unnecessary // set slot packets after practically every window click, since it thinks the client and server @@ -95,7 +95,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter after a click and send the changed slots here wrapper.write(Type.VAR_INT, 0); // Empty array of slot+item @@ -128,9 +128,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter { @@ -324,8 +324,8 @@ public final class BlockItemPackets1_17 extends ItemRewriter> 4)); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/BlockItemPackets1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/BlockItemPackets1_18.java index 0f87d2f7..46675c74 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/BlockItemPackets1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/BlockItemPackets1_18.java @@ -32,14 +32,14 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; -import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; -import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; import com.viaversion.viaversion.rewriter.RecipeRewriter; import com.viaversion.viaversion.util.Key; import com.viaversion.viaversion.util.MathUtil; @@ -62,7 +62,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); - final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(), + final ChunkType1_18 chunkType = new ChunkType1_18(tracker.currentWorldSectionHeight(), MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()), MathUtil.ceilLog2(tracker.biomesSent())); final Chunk oldChunk = wrapper.read(chunkType); @@ -218,7 +218,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter { - Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM); + Item item = wrapper.read(Type.ITEM1_13_2); boolean signing = wrapper.read(Type.BOOLEAN); wrapper.passthrough(Type.VAR_INT); // Slot comes first diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/BlockItemPackets1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/BlockItemPackets1_19.java index 69557b33..82db0bdb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/BlockItemPackets1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/BlockItemPackets1_19.java @@ -29,8 +29,8 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; -import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.RecipeRewriter; @@ -44,7 +44,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); new RecipeRewriter<>(protocol).register(ClientboundPackets1_19.DECLARE_RECIPES); @@ -52,7 +52,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); - final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(), + final ChunkType1_18 chunkType = new ChunkType1_18(tracker.currentWorldSectionHeight(), MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()), MathUtil.ceilLog2(tracker.biomesSent())); final Chunk chunk = wrapper.passthrough(chunkType); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/BlockItemPackets1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/BlockItemPackets1_19_3.java index ebf6ebdc..af6fdda1 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/BlockItemPackets1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/BlockItemPackets1_19_3.java @@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3; import com.viaversion.viaversion.rewriter.BlockRewriter; @@ -37,22 +37,22 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); blockRewriter.registerBlockAction(ClientboundPackets1_19_3.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_19_3.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_3.MULTI_BLOCK_CHANGE); blockRewriter.registerEffect(ClientboundPackets1_19_3.EFFECT, 1010, 2001); - blockRewriter.registerChunkData1_19(ClientboundPackets1_19_3.CHUNK_DATA, Chunk1_18Type::new); + blockRewriter.registerChunkData1_19(ClientboundPackets1_19_3.CHUNK_DATA, ChunkType1_18::new); blockRewriter.registerBlockEntityData(ClientboundPackets1_19_3.BLOCK_ENTITY_DATA); registerSetCooldown(ClientboundPackets1_19_3.COOLDOWN); registerWindowItems1_17_1(ClientboundPackets1_19_3.WINDOW_ITEMS); registerSetSlot1_17_1(ClientboundPackets1_19_3.SET_SLOT); registerEntityEquipmentArray(ClientboundPackets1_19_3.ENTITY_EQUIPMENT); - registerAdvancements(ClientboundPackets1_19_3.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); + registerAdvancements(ClientboundPackets1_19_3.ADVANCEMENTS, Type.ITEM1_13_2); registerClickWindow1_17_1(ServerboundPackets1_19_1.CLICK_WINDOW); registerTradeList1_19(ClientboundPackets1_19_3.TRADE_LIST); - registerCreativeInvAction(ServerboundPackets1_19_1.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); + registerCreativeInvAction(ServerboundPackets1_19_1.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2); registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_3.WINDOW_PROPERTY); registerSpawnParticle1_19(ClientboundPackets1_19_3.SPAWN_PARTICLE); @@ -77,12 +77,12 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); blockRewriter.registerBlockAction(ClientboundPackets1_19_4.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_19_4.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_4.MULTI_BLOCK_CHANGE); blockRewriter.registerEffect(ClientboundPackets1_19_4.EFFECT, 1010, 2001); - blockRewriter.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, Chunk1_18Type::new); + blockRewriter.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, ChunkType1_18::new); blockRewriter.registerBlockEntityData(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA); protocol.registerClientbound(ClientboundPackets1_19_4.OPEN_WINDOW, new PacketHandlers() { @@ -67,11 +67,11 @@ public final class BlockItemPackets1_19_4 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); blockRewriter.registerBlockAction(ClientboundPackets1_19_4.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_19_4.BLOCK_CHANGE); blockRewriter.registerEffect(ClientboundPackets1_19_4.EFFECT, 1010, 2001); @@ -60,7 +60,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java index 05f3285a..3734693f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java @@ -31,15 +31,15 @@ import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; -import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2; -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.util.Key; @@ -54,7 +54,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); + final BlockRewriter blockRewriter = BlockRewriter.for1_14(protocol); blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE); @@ -93,7 +93,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter newChunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(), + final Type newChunkType = new ChunkType1_18(tracker.currentWorldSectionHeight(), MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()), MathUtil.ceilLog2(tracker.biomesSent())); wrapper.write(newChunkType, chunk); @@ -133,8 +133,8 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2)))); + handler(wrapper -> wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2)))); } }); protocol.registerClientbound(ClientboundPackets1_20_2.ADVANCEMENTS, wrapper -> { @@ -162,7 +162,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.FLAT_VAR_INT_ITEM)))); // 1 - Clicked Item + handler(wrapper -> wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.ITEM1_13_2)))); // 1 - Clicked Item } }); protocol.registerClientbound(ClientboundPackets1_20_2.SPAWN_PARTICLE, new PacketHandlers() { @@ -261,7 +261,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 9) { - Position position = wrapper.get(Type.POSITION, 0); + Position position = wrapper.get(Type.POSITION1_8, 0); CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); wrapper.clearPacket(); //Clear the packet wrapper.setPacketType(ClientboundPackets1_9.UPDATE_SIGN); - wrapper.write(Type.POSITION, position); // Position + wrapper.write(Type.POSITION1_8, position); // Position for (int i = 1; i < 5; i++) { // Should technically be written as COMPONENT, but left as String for simplification/to remove redundant wrapping for VR Tag textTag = tag.get("Text" + i); @@ -72,8 +72,8 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk1_9_3_4Type newType = new Chunk1_9_3_4Type(clientWorld); - Chunk1_9_1_2Type oldType = new Chunk1_9_1_2Type(clientWorld); // Get the old type to not write Block Entities + ChunkType1_9_3 newType = new ChunkType1_9_3(clientWorld); + ChunkType1_9_1 oldType = new ChunkType1_9_1(clientWorld); // Get the old type to not write Block Entities Chunk chunk = wrapper.read(newType); wrapper.write(oldType, chunk); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java index 4b0fd9f0..3e5f9b53 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_1_2to1_9_3_4/chunks/BlockEntity.java @@ -77,7 +77,7 @@ public class BlockEntity { private static void updateBlockEntity(Position pos, short id, CompoundTag tag, UserConnection connection) throws Exception { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, null, connection); - wrapper.write(Type.POSITION, pos); + wrapper.write(Type.POSITION1_8, pos); wrapper.write(Type.UNSIGNED_BYTE, id); wrapper.write(Type.NAMED_COMPOUND_TAG, tag); wrapper.scheduleSend(Protocol1_9_1_2To1_9_3_4.class, false); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/Protocol1_9_4To1_10.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/Protocol1_9_4To1_10.java index 4d6d7db2..c8001e73 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/Protocol1_9_4To1_10.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/Protocol1_9_4To1_10.java @@ -24,6 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -32,7 +33,6 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class Protocol1_9_4To1_10 extends BackwardsProtocol { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java index 7a9377e2..fc606de9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/BlockItemPackets1_10.java @@ -21,14 +21,14 @@ package com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets; import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type; public class BlockItemPackets1_10 extends LegacyBlockItemRewriter { @@ -38,11 +38,11 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter { ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); + ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); Chunk chunk = wrapper.passthrough(type); handleChunk(chunk); @@ -88,7 +88,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter { @@ -116,7 +116,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter { - if (meta.metaType().type().equals(Type.ITEM)) // Is Item + if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); }); diff --git a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java index 3eb0c1ac..77957c37 100644 --- a/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java +++ b/template/src/main/java/com/viaversion/viabackwards/template/protocol/rewriter/BlockItemPacketRewriter1_99.java @@ -20,10 +20,10 @@ package com.viaversion.viabackwards.template.protocol.rewriter; import com.viaversion.viabackwards.api.rewriters.ItemRewriter; import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2; -import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2; import com.viaversion.viaversion.rewriter.BlockRewriter; // To replace if needed: