From f30fdc1feb39b8ac47292b5f724a4b16d682f99c Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 4 Feb 2023 18:57:51 +0100 Subject: [PATCH] Ensure correct packet types in rewriters during compile time --- .../viabackwards/api/BackwardsProtocol.java | 2 +- .../storage/EntityPositionHandler.java | 4 +- .../api/rewriters/EnchantmentRewriter.java | 6 +-- .../api/rewriters/EntityRewriter.java | 6 +-- .../api/rewriters/EntityRewriterBase.java | 3 +- .../api/rewriters/ItemRewriter.java | 8 ++-- .../api/rewriters/ItemRewriterBase.java | 6 ++- .../rewriters/LegacyBlockItemRewriter.java | 5 ++- .../api/rewriters/LegacyEntityRewriter.java | 10 ++--- .../api/rewriters/LegacySoundRewriter.java | 2 +- .../api/rewriters/SoundRewriter.java | 10 ++--- .../api/rewriters/TranslatableRewriter.java | 16 +++---- .../Protocol1_10To1_11.java | 2 +- .../packets/BlockItemPackets1_11.java | 2 +- .../packets/EntityPackets1_11.java | 2 +- .../packets/BlockItemPackets1_12.java | 42 ++++++++----------- .../packets/ChatPackets1_12.java | 2 +- .../packets/EntityPackets1_12.java | 2 +- .../Protocol1_11To1_11_1.java | 5 +-- .../packets/EntityPackets1_11_1.java | 2 +- .../packets/ItemPackets1_11_1.java | 2 +- .../Protocol1_12_2To1_13.java | 7 ++-- .../packets/BlockItemPackets1_13.java | 2 +- .../packets/EntityPackets1_13.java | 2 +- .../packets/PlayerPacket1_13.java | 3 +- .../Protocol1_13_2To1_14.java | 11 +++-- .../data/CommandRewriter1_14.java | 7 ++-- .../packets/BlockItemPackets1_14.java | 6 +-- .../packets/EntityPackets1_14.java | 2 +- .../packets/SoundPackets1_14.java | 2 +- .../Protocol1_13To1_13_1.java | 16 ++++--- .../data/CommandRewriter1_13_1.java | 7 ++-- .../packets/EntityPackets1_13_1.java | 2 +- .../packets/InventoryPackets1_13_1.java | 2 +- .../packets/WorldPackets1_13_1.java | 5 ++- .../Protocol1_14_2To1_14_3.java | 2 +- .../Protocol1_14_4To1_15.java | 15 ++++--- .../packets/BlockItemPackets1_15.java | 6 +-- .../packets/EntityPackets1_15.java | 2 +- .../Protocol1_14To1_14_1.java | 5 +-- .../packets/EntityPackets1_14_1.java | 2 +- .../Protocol1_15_2To1_16.java | 16 ++++--- .../chat/TranslatableRewriter1_16.java | 7 ++-- .../data/CommandRewriter1_16.java | 7 ++-- .../packets/BlockItemPackets1_16.java | 8 ++-- .../packets/EntityPackets1_16.java | 2 +- .../Protocol1_16_1To1_16_2.java | 15 ++++--- .../data/CommandRewriter1_16_2.java | 7 ++-- .../packets/BlockItemPackets1_16_2.java | 6 +-- .../packets/EntityPackets1_16_2.java | 2 +- .../Protocol1_16_4To1_17.java | 19 ++++----- .../packets/BlockItemPackets1_17.java | 6 +-- .../packets/EntityPackets1_17.java | 2 +- .../Protocol1_17_1To1_18.java | 8 ++-- .../packets/BlockItemPackets1_18.java | 5 +-- .../packets/EntityPackets1_18.java | 2 +- .../Protocol1_18_2To1_19.java | 19 ++++----- .../data/CommandRewriter1_19.java | 7 ++-- .../packets/BlockItemPackets1_19.java | 6 +-- .../packets/EntityPackets1_19.java | 2 +- .../data/CommandRewriter1_18_2.java | 7 ++-- .../Protocol1_19_1To1_19_3.java | 19 ++++----- .../packets/BlockItemPackets1_19_3.java | 6 +-- .../packets/EntityPackets1_19_3.java | 2 +- .../Protocol1_19_3To1_19_4.java | 2 +- .../packets/EntityPackets1_19_4.java | 2 +- .../Protocol1_19To1_19_1.java | 10 ++--- .../packets/EntityPackets1_19_1.java | 2 +- .../Protocol1_9_4To1_10.java | 2 +- .../packets/BlockItemPackets1_10.java | 2 +- .../packets/EntityPackets1_10.java | 2 +- 71 files changed, 218 insertions(+), 229 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java b/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java index 029c0352..0cab9bd1 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/BackwardsProtocol.java @@ -55,7 +55,7 @@ public abstract class BackwardsProtocol getTranslatableRewriter() { return null; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java index 8d96367b..77db17b4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/EntityPositionHandler.java @@ -30,12 +30,12 @@ import java.util.function.Supplier; public class EntityPositionHandler { public static final double RELATIVE_MOVE_FACTOR = 32 * 128; - private final EntityRewriterBase entityRewriter; + private final EntityRewriterBase entityRewriter; private final Class storageClass; private final Supplier storageSupplier; private boolean warnedForMissingEntity; - public EntityPositionHandler(EntityRewriterBase entityRewriter, + public EntityPositionHandler(EntityRewriterBase entityRewriter, Class storageClass, Supplier storageSupplier) { this.entityRewriter = entityRewriter; this.storageClass = storageClass; diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java index b5fa0772..ec1345f2 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EnchantmentRewriter.java @@ -38,15 +38,15 @@ import java.util.Map; public class EnchantmentRewriter { private final Map enchantmentMappings = new HashMap<>(); - private final ItemRewriter itemRewriter; + private final ItemRewriter itemRewriter; private final boolean jsonFormat; - public EnchantmentRewriter(ItemRewriter itemRewriter, boolean jsonFormat) { + public EnchantmentRewriter(ItemRewriter itemRewriter, boolean jsonFormat) { this.itemRewriter = itemRewriter; this.jsonFormat = jsonFormat; } - public EnchantmentRewriter(ItemRewriter itemRewriter) { + public EnchantmentRewriter(ItemRewriter itemRewriter) { this(itemRewriter, true); } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java index c081f3aa..24f7e9e7 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriter.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_14; -public abstract class EntityRewriter extends EntityRewriterBase { +public abstract class EntityRewriter> extends EntityRewriterBase { protected EntityRewriter(T protocol) { this(protocol, Types1_14.META_TYPES.optionalComponentType, Types1_14.META_TYPES.booleanType); @@ -39,7 +39,7 @@ public abstract class EntityRewriter extends Entity } @Override - public void registerTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) { + public void registerTrackerWithData(C packetType, EntityType fallingBlockType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -79,7 +79,7 @@ public abstract class EntityRewriter extends Entity }; } - public void registerSpawnTracker(ClientboundPacketType packetType) { + public void registerSpawnTracker(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { 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 2d50c650..14a66cee 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 @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; @@ -46,7 +47,7 @@ import java.util.List; * @see com.viaversion.viabackwards.api.rewriters.EntityRewriter * @see LegacyEntityRewriter */ -public abstract class EntityRewriterBase extends EntityRewriter { +public abstract class EntityRewriterBase> extends EntityRewriter { private final Int2ObjectMap entityDataMappings = new Int2ObjectOpenHashMap<>(); private final MetaType displayNameMetaType; private final MetaType displayVisibilityMetaType; diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java index d6e9c933..f4c7ae6b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/ItemRewriter.java @@ -21,6 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.MappedItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -32,7 +33,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import org.checkerframework.checker.nullness.qual.Nullable; -public abstract class ItemRewriter extends ItemRewriterBase { +public abstract class ItemRewriter> extends ItemRewriterBase { protected ItemRewriter(T protocol) { super(protocol, true); @@ -119,7 +121,7 @@ public abstract class ItemRewriter extends ItemRewr } @Override - public void registerAdvancements(ClientboundPacketType packetType, Type type) { + public void registerAdvancements(C packetType, Type type) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -138,7 +140,7 @@ public abstract class ItemRewriter extends ItemRewr if (wrapper.passthrough(Type.BOOLEAN)) { final JsonElement title = wrapper.passthrough(Type.COMPONENT); final JsonElement description = wrapper.passthrough(Type.COMPONENT); - final TranslatableRewriter translatableRewriter = protocol.getTranslatableRewriter(); + final TranslatableRewriter translatableRewriter = protocol.getTranslatableRewriter(); if (translatableRewriter != null) { translatableRewriter.processText(title); translatableRewriter.processText(description); 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 29fe33d7..43d84013 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 @@ -19,6 +19,8 @@ package com.viaversion.viabackwards.api.rewriters; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; 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; @@ -26,7 +28,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.rewriter.ItemRewriter; import org.checkerframework.checker.nullness.qual.Nullable; -public abstract class ItemRewriterBase extends ItemRewriter { +public abstract class ItemRewriterBase> extends ItemRewriter { protected final String nbtTagName; protected final boolean jsonNameFormat; @@ -37,6 +40,7 @@ public abstract class ItemRewriterBase extends Item nbtTagName = "VB|" + protocol.getClass().getSimpleName(); } + @Override public @Nullable Item handleItemToServer(@Nullable Item item) { if (item == null) return null; super.handleItemToServer(item); diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java index ffdf0e67..e887a88c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java @@ -26,6 +26,8 @@ import com.viaversion.viabackwards.utils.Block; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -43,7 +45,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; import java.util.HashMap; import java.util.Map; -public abstract class LegacyBlockItemRewriter extends ItemRewriterBase { +public abstract class LegacyBlockItemRewriter> extends ItemRewriterBase { private static final Map> LEGACY_MAPPINGS = new HashMap<>(); protected final Int2ObjectMap replacementData; 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 e0f225ff..b450d5c9 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 @@ -40,7 +40,7 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -public abstract class LegacyEntityRewriter extends EntityRewriterBase { +public abstract class LegacyEntityRewriter> extends EntityRewriterBase { private final Map objectTypes = new HashMap<>(); protected LegacyEntityRewriter(T protocol) { @@ -61,7 +61,7 @@ public abstract class LegacyEntityRewriter extends return objectTypes.get(type); } - protected void registerRespawn(ClientboundPacketType packetType) { + protected void registerRespawn(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -74,7 +74,7 @@ public abstract class LegacyEntityRewriter extends }); } - protected void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) { + protected void registerJoinGame(C packetType, EntityType playerType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -91,7 +91,7 @@ public abstract class LegacyEntityRewriter extends } @Override - public void registerMetadataRewriter(ClientboundPacketType packetType, Type> oldMetaType, Type> newMetaType) { + public void registerMetadataRewriter(C packetType, Type> oldMetaType, Type> newMetaType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -110,7 +110,7 @@ public abstract class LegacyEntityRewriter extends } @Override - public void registerMetadataRewriter(ClientboundPacketType packetType, Type> metaType) { + public void registerMetadataRewriter(C packetType, Type> metaType) { registerMetadataRewriter(packetType, null, metaType); } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacySoundRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacySoundRewriter.java index cb5fb85e..057f7d56 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacySoundRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacySoundRewriter.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; @Deprecated -public abstract class LegacySoundRewriter extends RewriterBase { +public abstract class LegacySoundRewriter> extends RewriterBase { protected final Int2ObjectMap soundRewrites = new Int2ObjectOpenHashMap<>(64); protected LegacySoundRewriter(T protocol) { diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/SoundRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/SoundRewriter.java index 4163fc56..2fe62022 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/SoundRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/SoundRewriter.java @@ -23,16 +23,16 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; -public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewriter { +public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewriter { - private final BackwardsProtocol protocol; + private final BackwardsProtocol protocol; - public SoundRewriter(BackwardsProtocol protocol) { + public SoundRewriter(BackwardsProtocol protocol) { super(protocol); this.protocol = protocol; } - public void registerNamedSound(ClientboundPacketType packetType) { + public void registerNamedSound(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -42,7 +42,7 @@ public class SoundRewriter extends com.viaversion.viaversion.rewriter.SoundRewri }); } - public void registerStopSound(ClientboundPacketType packetType) { + public void registerStopSound(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java index 710925ba..300389f6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java @@ -31,7 +31,7 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter; import java.util.HashMap; import java.util.Map; -public class TranslatableRewriter extends ComponentRewriter { +public class TranslatableRewriter extends ComponentRewriter { private static final Map> TRANSLATABLES = new HashMap<>(); protected final Map newTranslatables; @@ -47,11 +47,11 @@ public class TranslatableRewriter extends ComponentRewriter { } } - public TranslatableRewriter(BackwardsProtocol protocol) { + public TranslatableRewriter(BackwardsProtocol protocol) { this(protocol, protocol.getClass().getSimpleName().split("To")[1].replace("_", ".")); } - public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) { + public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) { super(protocol); final Map newTranslatables = TRANSLATABLES.get(sectionIdentifier); if (newTranslatables == null) { @@ -71,7 +71,7 @@ public class TranslatableRewriter extends ComponentRewriter { }); } - public void registerDisconnect(ClientboundPacketType packetType) { + public void registerDisconnect(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -80,7 +80,7 @@ public class TranslatableRewriter extends ComponentRewriter { }); } - public void registerLegacyOpenWindow(ClientboundPacketType packetType) { + public void registerLegacyOpenWindow(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -91,7 +91,7 @@ public class TranslatableRewriter extends ComponentRewriter { }); } - public void registerOpenWindow(ClientboundPacketType packetType) { + public void registerOpenWindow(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -102,7 +102,7 @@ public class TranslatableRewriter extends ComponentRewriter { }); } - public void registerTabList(ClientboundPacketType packetType) { + public void registerTabList(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { @@ -114,7 +114,7 @@ public class TranslatableRewriter extends ComponentRewriter { }); } - public void registerCombatKill(ClientboundPacketType packetType) { + public void registerCombatKill(C packetType) { protocol.registerClientbound(packetType, new PacketRemapper() { @Override public void registerMap() { 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 7276250f..b14a3061 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 @@ -48,7 +48,7 @@ public class Protocol1_10To1_11 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerNamedSound(ClientboundPackets1_9_3.NAMED_SOUND); soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND); } 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 d3d42345..e5534274 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 @@ -49,7 +49,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client import java.util.Arrays; import java.util.Optional; -public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { +public class BlockItemPackets1_11 extends LegacyBlockItemRewriter { private LegacyEnchantmentRewriter enchantmentRewriter; 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 a6f94afd..a89e690c 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 @@ -41,7 +41,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac import java.util.List; import java.util.Optional; -public class EntityPackets1_11 extends LegacyEntityRewriter { +public class EntityPackets1_11 extends LegacyEntityRewriter { public EntityPackets1_11(Protocol1_10To1_11 protocol) { super(protocol); 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 7937472f..a09d5c39 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 @@ -42,7 +42,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Iterator; import java.util.Map; -public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { +public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { public BlockItemPackets1_12(Protocol1_11_1To1_12 protocol) { super(protocol); @@ -56,34 +56,28 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter { + int count = wrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < count * 3; i++) { + wrapper.passthrough(Type.BYTE); } }); - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - short columns = wrapper.passthrough(Type.UNSIGNED_BYTE); - if (columns <= 0) return; + handler(wrapper -> { + short columns = wrapper.passthrough(Type.UNSIGNED_BYTE); + if (columns <= 0) return; - short rows = wrapper.passthrough(Type.UNSIGNED_BYTE); - wrapper.passthrough(Type.UNSIGNED_BYTE); // X - wrapper.passthrough(Type.UNSIGNED_BYTE); // Z - byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); - for (int i = 0; i < data.length; i++) { - short color = (short) (data[i] & 0xFF); - if (color > 143) { - color = (short) MapColorMapping.getNearestOldColor(color); - data[i] = (byte) color; - } + wrapper.passthrough(Type.UNSIGNED_BYTE); // Rows + wrapper.passthrough(Type.UNSIGNED_BYTE); // X + wrapper.passthrough(Type.UNSIGNED_BYTE); // Z + byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE); + for (int i = 0; i < data.length; i++) { + short color = (short) (data[i] & 0xFF); + if (color > 143) { + color = (short) MapColorMapping.getNearestOldColor(color); + data[i] = (byte) color; } - wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, data); } + wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, data); }); } }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java index d76a1dee..e4c55718 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/ChatPackets1_12.java @@ -30,7 +30,7 @@ import com.viaversion.viaversion.rewriter.ComponentRewriter; public class ChatPackets1_12 extends RewriterBase { - private final ComponentRewriter componentRewriter = new ComponentRewriter() { + private final ComponentRewriter componentRewriter = new ComponentRewriter() { @Override protected void handleTranslate(JsonObject object, String translate) { String text = AdvancementTranslations.get(translate); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java index d1761c41..0a892e65 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/packets/EntityPackets1_12.java @@ -38,7 +38,7 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPacke import java.util.Optional; -public class EntityPackets1_12 extends LegacyEntityRewriter { +public class EntityPackets1_12 extends LegacyEntityRewriter { public EntityPackets1_12(Protocol1_11_1To1_12 protocol) { super(protocol); 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 97ef3357..d0e0e58e 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 @@ -23,7 +23,6 @@ import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityP 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.entities.Entity1_11Types; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; 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; @@ -32,7 +31,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client public class Protocol1_11To1_11_1 extends BackwardsProtocol { private final EntityPackets1_11_1 entityPackets = new EntityPackets1_11_1(this); - private final ItemRewriter itemRewriter = new ItemPackets1_11_1(this); + private final ItemPackets1_11_1 itemRewriter = new ItemPackets1_11_1(this); public Protocol1_11To1_11_1() { super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class); @@ -60,7 +59,7 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol { +public class EntityPackets1_11_1 extends LegacyEntityRewriter { public EntityPackets1_11_1(Protocol1_11To1_11_1 protocol) { super(protocol); 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 31bd3230..3041fc2b 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 @@ -31,7 +31,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; 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; -public class ItemPackets1_11_1 extends LegacyBlockItemRewriter { +public class ItemPackets1_11_1 extends LegacyBlockItemRewriter { private LegacyEnchantmentRewriter enchantmentRewriter; 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 ed2211ab..28dee107 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 @@ -34,7 +34,6 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabComp import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1; @@ -47,7 +46,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client public class Protocol1_12_2To1_13 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings(); - private final EntityRewriter entityRewriter = new EntityPackets1_13(this); + private final EntityPackets1_13 entityRewriter = new EntityPackets1_13(this); private final BlockItemPackets1_13 blockItemPackets = new BlockItemPackets1_13(this); public Protocol1_12_2To1_13() { @@ -62,7 +61,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter(this) { @Override protected void handleTranslate(JsonObject root, String translate) { String newTranslate = newTranslatables.get(translate); @@ -119,7 +118,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { +public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { private final Map enchantmentMappings = new HashMap<>(); private final String extraNbtTag; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index accf67de..90ad0118 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -45,7 +45,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke import java.util.Optional; -public class EntityPackets1_13 extends LegacyEntityRewriter { +public class EntityPackets1_13 extends LegacyEntityRewriter { public EntityPackets1_13(Protocol1_12_2To1_13 protocol) { super(protocol); 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 0723201a..e3a51afc 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 @@ -48,8 +48,7 @@ import java.util.concurrent.ThreadLocalRandom; public class PlayerPacket1_13 extends RewriterBase { - private final CommandRewriter commandRewriter = new CommandRewriter(protocol) { - }; + private final CommandRewriter commandRewriter = new CommandRewriter<>(protocol); public PlayerPacket1_13(Protocol1_12_2To1_13 protocol) { super(protocol); 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 069f8f68..b709ef2b 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 @@ -32,7 +32,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; @@ -46,8 +45,8 @@ import com.viaversion.viaversion.rewriter.StatisticsRewriter; public class Protocol1_13_2To1_14 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class, true); - private final EntityRewriter entityRewriter = new EntityPackets1_14(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter(this); + private final EntityPackets1_14 entityRewriter = new EntityPackets1_14(this); + private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this); private BlockItemPackets1_14 blockItemPackets; public Protocol1_13_2To1_14() { @@ -74,7 +73,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol(this).register(ClientboundPackets1_14.STATISTICS); cancelClientbound(ClientboundPackets1_14.UPDATE_VIEW_POSITION); cancelClientbound(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE); @@ -206,7 +205,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/data/CommandRewriter1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/data/CommandRewriter1_14.java index ca4f4b98..4d2fd6d8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/data/CommandRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/data/CommandRewriter1_14.java @@ -17,14 +17,15 @@ */ package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.data; -import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.rewriter.CommandRewriter; import org.checkerframework.checker.nullness.qual.Nullable; -public class CommandRewriter1_14 extends CommandRewriter { +public class CommandRewriter1_14 extends CommandRewriter { - public CommandRewriter1_14(Protocol protocol) { + public CommandRewriter1_14(Protocol1_13_2To1_14 protocol) { super(protocol); this.parserHandlers.put("minecraft:nbt_tag", wrapper -> { 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 83431c6c..54e00881 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 @@ -60,7 +60,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { +public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { private EnchantmentRewriter enchantmentRewriter; @@ -189,7 +189,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit } }); - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION); registerSetCooldown(ClientboundPackets1_14.COOLDOWN); registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); @@ -295,7 +295,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit } }); - RecipeRewriter recipeHandler = new RecipeRewriter1_13_2(protocol); + RecipeRewriter recipeHandler = new RecipeRewriter1_13_2<>(protocol); protocol.registerClientbound(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() { @Override public void registerMap() { 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 64ddd755..19726794 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 @@ -46,7 +46,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPacke 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 { +public class EntityPackets1_14 extends LegacyEntityRewriter { private EntityPositionHandler positionHandler; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java index 74b0c49b..33423865 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/SoundPackets1_14.java @@ -37,7 +37,7 @@ public class SoundPackets1_14 extends RewriterBase { @Override protected void registerPackets() { - SoundRewriter soundRewriter = new SoundRewriter(protocol); + SoundRewriter soundRewriter = new SoundRewriter<>(protocol); soundRewriter.registerSound(ClientboundPackets1_14.SOUND); soundRewriter.registerNamedSound(ClientboundPackets1_14.NAMED_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_14.STOP_SOUND); 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 03dee0d7..ed0f9662 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 @@ -33,8 +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.PacketRemapper; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -50,8 +48,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public class Protocol1_13To1_13_1 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.13.2", "1.13", Protocol1_13_1To1_13.class, true); - private final EntityRewriter entityRewriter = new EntityPackets1_13_1(this); - private final ItemRewriter itemRewriter = new InventoryPackets1_13_1(this); + private final EntityPackets1_13_1 entityRewriter = new EntityPackets1_13_1(this); + private final InventoryPackets1_13_1 itemRewriter = new InventoryPackets1_13_1(this); public Protocol1_13To1_13_1() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); @@ -65,7 +63,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE); translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT); translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT); @@ -222,8 +220,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM); + new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS); } @Override @@ -241,12 +239,12 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol { - public CommandRewriter1_13_1(Protocol protocol) { + public CommandRewriter1_13_1(Protocol1_13To1_13_1 protocol) { super(protocol); this.parserHandlers.put("minecraft:dimension", wrapper -> { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java index b146eabc..dc6c2a13 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java @@ -34,7 +34,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke import java.util.List; -public class EntityPackets1_13_1 extends LegacyEntityRewriter { +public class EntityPackets1_13_1 extends LegacyEntityRewriter { public EntityPackets1_13_1(Protocol1_13To1_13_1 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java index d9da7b11..f538bad7 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/InventoryPackets1_13_1.java @@ -27,7 +27,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; import com.viaversion.viaversion.rewriter.ItemRewriter; -public class InventoryPackets1_13_1 extends ItemRewriter { +public class InventoryPackets1_13_1 extends ItemRewriter { public InventoryPackets1_13_1(Protocol1_13To1_13_1 protocol) { super(protocol); 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 bd4faf5a..ddc677e4 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 @@ -17,6 +17,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.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; @@ -33,8 +34,8 @@ import com.viaversion.viaversion.rewriter.BlockRewriter; public class WorldPackets1_13_1 { - public static void register(Protocol protocol) { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION); + public static void register(Protocol1_13To1_13_1 protocol) { + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION); protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() { @Override 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 64165d69..810096d3 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 @@ -66,7 +66,7 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol recipeHandler = new RecipeRewriter1_14<>(this); registerClientbound(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java index 3142203b..3c5eca32 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java @@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; @@ -42,8 +41,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public class Protocol1_14_4To1_15 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.15", "1.14", Protocol1_15To1_14_4.class, true); - private final EntityRewriter entityRewriter = new EntityPackets1_15(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter(this); + private final EntityPackets1_15 entityRewriter = new EntityPackets1_15(this); + private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this); private BlockItemPackets1_15 blockItemPackets; public Protocol1_14_4To1_15() { @@ -66,7 +65,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_15.SOUND); soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND); soundRewriter.registerNamedSound(ClientboundPackets1_15.NAMED_SOUND); @@ -97,9 +96,9 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol(this).register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY); - new StatisticsRewriter(this).register(ClientboundPackets1_15.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS); } @Override @@ -114,7 +113,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java index 6e7c5cfa..04412290 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/BlockItemPackets1_15.java @@ -32,7 +32,7 @@ import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type; import com.viaversion.viaversion.rewriter.BlockRewriter; -public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { +public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { public BlockItemPackets1_15(Protocol1_14_4To1_15 protocol) { super(protocol); @@ -40,9 +40,9 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit @Override protected void registerPackets() { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); - new RecipeRewriter1_14(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES); + new RecipeRewriter1_14<>(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES); protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() { @Override diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java index a1fef090..c2256c05 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/packets/EntityPackets1_15.java @@ -33,7 +33,7 @@ import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPacke import java.util.ArrayList; -public class EntityPackets1_15 extends EntityRewriter { +public class EntityPackets1_15 extends EntityRewriter { public EntityPackets1_15(Protocol1_14_4To1_15 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java index 2935b425..2bf7ca62 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14to1_14_1/Protocol1_14To1_14_1.java @@ -21,14 +21,13 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets1_14_1; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; public class Protocol1_14To1_14_1 extends BackwardsProtocol { - private final EntityRewriter entityRewriter = new EntityPackets1_14_1(this); + private final EntityPackets1_14_1 entityRewriter = new EntityPackets1_14_1(this); public Protocol1_14To1_14_1() { super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); @@ -45,7 +44,7 @@ public class Protocol1_14To1_14_1 extends BackwardsProtocol { +public class EntityPackets1_14_1 extends LegacyEntityRewriter { public EntityPackets1_14_1(Protocol1_14To1_14_1 protocol) { super(protocol); 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 b2deb6bc..3e1c070a 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 @@ -19,7 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.chat.TranslatableRewriter1_16; import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings; import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data.CommandRewriter1_16; @@ -32,7 +31,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -52,8 +50,8 @@ import java.util.UUID; public class Protocol1_15_2To1_16 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings(); - private final EntityRewriter entityRewriter = new EntityPackets1_16(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter1_16(this); + private final EntityPackets1_16 entityRewriter = new EntityPackets1_16(this); + private final TranslatableRewriter1_16 translatableRewriter = new TranslatableRewriter1_16(this); private BlockItemPackets1_16 blockItemPackets; public Protocol1_15_2To1_16() { @@ -117,7 +115,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_16.SOUND); soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND); soundRewriter.registerNamedSound(ClientboundPackets1_16.NAMED_SOUND); @@ -135,9 +133,9 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol(this).register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY); - new StatisticsRewriter(this).register(ClientboundPackets1_16.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_16.STATISTICS); registerServerbound(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() { @Override @@ -206,7 +204,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol { private static final ChatColor[] COLORS = { new ChatColor("black", 0x000000), @@ -49,7 +50,7 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter { new ChatColor("white", 0xffffff) }; - public TranslatableRewriter1_16(BackwardsProtocol protocol) { + public TranslatableRewriter1_16(Protocol1_15_2To1_16 protocol) { super(protocol); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/CommandRewriter1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/CommandRewriter1_16.java index 38ee62b7..01e43fad 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/CommandRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/data/CommandRewriter1_16.java @@ -17,13 +17,14 @@ */ package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data; -import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16; +import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.rewriter.CommandRewriter; import org.checkerframework.checker.nullness.qual.Nullable; -public class CommandRewriter1_16 extends CommandRewriter { +public class CommandRewriter1_16 extends CommandRewriter { - public CommandRewriter1_16(Protocol protocol) { + public CommandRewriter1_16(Protocol1_15_2To1_16 protocol) { super(protocol); } 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 3868afbe..9e330c0e 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 @@ -52,7 +52,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; -public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { +public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { private EnchantmentRewriter enchantmentRewriter; @@ -62,9 +62,9 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit @Override protected void registerPackets() { - BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); + BlockRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); - RecipeRewriter1_14 recipeRewriter = new RecipeRewriter1_14(protocol); + RecipeRewriter1_14 recipeRewriter = new RecipeRewriter1_14<>(protocol); // Remove new smithing type, only in this handler protocol.registerClientbound(ClientboundPackets1_16.DECLARE_RECIPES, new PacketRemapper() { @Override @@ -86,7 +86,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit } wrapper.write(Type.STRING, originalType); - String id = wrapper.passthrough(Type.STRING); // Recipe Identifier + wrapper.passthrough(Type.STRING); // Recipe Identifier recipeRewriter.handle(wrapper, type); } 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 16cf4373..55cfe53c 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 @@ -42,7 +42,7 @@ import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -public class EntityPackets1_16 extends EntityRewriter { +public class EntityPackets1_16 extends EntityRewriter { private final ValueTransformer dimensionTransformer = new ValueTransformer(Type.STRING, Type.INT) { @Override diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java index 40ec2d85..d7333992 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/Protocol1_16_1To1_16_2.java @@ -31,7 +31,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -46,8 +45,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter; public class Protocol1_16_1To1_16_2 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.16.2", "1.16", Protocol1_16_2To1_16_1.class, true); - private final EntityRewriter entityRewriter = new EntityPackets1_16_2(this); - private final TranslatableRewriter translatableRewriter = new TranslatableRewriter(this); + private final EntityPackets1_16_2 entityRewriter = new EntityPackets1_16_2(this); + private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this); private BlockItemPackets1_16_2 blockItemPackets; public Protocol1_16_1To1_16_2() { @@ -71,7 +70,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND); soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND); soundRewriter.registerNamedSound(ClientboundPackets1_16_2.NAMED_SOUND); @@ -130,9 +129,9 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol(this).register(ClientboundPackets1_16_2.TAGS, RegistryType.ENTITY); - new StatisticsRewriter(this).register(ClientboundPackets1_16_2.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_16_2.STATISTICS); } @Override @@ -142,7 +141,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } @@ -152,7 +151,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol { - public CommandRewriter1_16_2(Protocol protocol) { + public CommandRewriter1_16_2(Protocol1_16_1To1_16_2 protocol) { super(protocol); this.parserHandlers.put("minecraft:angle", wrapper -> { 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 f001c577..0d84804b 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 @@ -36,7 +36,7 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewri import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type; import com.viaversion.viaversion.rewriter.BlockRewriter; -public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { +public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { public BlockItemPackets1_16_2(Protocol1_16_1To1_16_2 protocol) { super(protocol); @@ -44,9 +44,9 @@ 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 = new BlockRewriter<>(protocol, Type.POSITION1_14); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES); registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN); registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java index 5407dfb1..a71b163f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java @@ -39,7 +39,7 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPa import java.util.Set; -public class EntityPackets1_16_2 extends EntityRewriter { +public class EntityPackets1_16_2 extends EntityRewriter { private final Set oldDimensions = Sets.newHashSet("minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"); private boolean warned; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java index c14a9d64..5b741e2c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java @@ -32,8 +32,6 @@ import com.viaversion.viaversion.api.minecraft.TagData; import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.fastutil.ints.IntArrayList; @@ -46,7 +44,6 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPacke import com.viaversion.viaversion.rewriter.IdRewriteFunction; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -56,8 +53,8 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); private BlockItemPackets1_17 blockItemPackets; public Protocol1_16_4To1_17() { @@ -80,13 +77,13 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_17.SOUND); soundRewriter.registerSound(ClientboundPackets1_17.ENTITY_SOUND); soundRewriter.registerNamedSound(ClientboundPackets1_17.NAMED_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_17.STOP_SOUND); - TagRewriter tagRewriter = new TagRewriter(this); + TagRewriter tagRewriter = new TagRewriter<>(this); registerClientbound(ClientboundPackets1_17.TAGS, new PacketRemapper() { @Override public void registerMap() { @@ -144,7 +141,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol(this).register(ClientboundPackets1_17.STATISTICS); registerClientbound(ClientboundPackets1_17.RESOURCE_PACK, new PacketRemapper() { @Override @@ -259,7 +256,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } @@ -276,12 +273,12 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol { +public final class BlockItemPackets1_17 extends ItemRewriter { public BlockItemPackets1_17(Protocol1_16_4To1_17 protocol) { super(protocol); @@ -60,9 +60,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_17.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_17.DECLARE_RECIPES); registerSetCooldown(ClientboundPackets1_17.COOLDOWN); registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java index 72282acb..4d556edb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/packets/EntityPackets1_17.java @@ -37,7 +37,7 @@ 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_17to1_16_4.ClientboundPackets1_17; -public final class EntityPackets1_17 extends EntityRewriter { +public final class EntityPackets1_17 extends EntityRewriter { private boolean warned; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java index 795d4a19..1bdcaf47 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java @@ -40,7 +40,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); private BlockItemPackets1_18 itemRewriter; public Protocol1_17_1To1_18() { @@ -66,13 +66,13 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound(ClientboundPackets1_18.SOUND); soundRewriter.registerSound(ClientboundPackets1_18.ENTITY_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_18.STOP_SOUND); soundRewriter.registerNamedSound(ClientboundPackets1_18.NAMED_SOUND); - final TagRewriter tagRewriter = new TagRewriter(this); + final TagRewriter tagRewriter = new TagRewriter<>(this); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:lava_pool_stone_replaceables"); tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS); @@ -155,7 +155,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } } 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 56d09eef..1c729077 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 @@ -42,12 +42,11 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17T 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.util.MathUtil; - import java.util.ArrayList; import java.util.BitSet; import java.util.List; -public final class BlockItemPackets1_18 extends ItemRewriter { +public final class BlockItemPackets1_18 extends ItemRewriter { public BlockItemPackets1_18(final Protocol1_17_1To1_18 protocol) { super(protocol); @@ -55,7 +54,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES); registerSetCooldown(ClientboundPackets1_18.COOLDOWN); registerWindowItems1_17_1(ClientboundPackets1_18.WINDOW_ITEMS); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java index 7e402130..53b449ec 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java @@ -34,7 +34,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; -public final class EntityPackets1_18 extends EntityRewriter { +public final class EntityPackets1_18 extends EntityRewriter { public EntityPackets1_18(final Protocol1_17_1To1_18 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java index 2ba1b329..cd01d591 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/Protocol1_18_2To1_19.java @@ -32,8 +32,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -50,7 +48,6 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPacke import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; - import java.time.Instant; import java.util.UUID; @@ -61,7 +58,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); public Protocol1_18_2To1_19() { super(ClientboundPackets1_19.class, ClientboundPackets1_18.class, ServerboundPackets1_19.class, ServerboundPackets1_17.class); @@ -87,7 +84,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerStopSound(ClientboundPackets1_19.STOP_SOUND); registerClientbound(ClientboundPackets1_19.SOUND, new PacketRemapper() { @Override @@ -130,7 +127,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.removeTags("minecraft:banner_pattern"); tagRewriter.removeTags("minecraft:instrument"); tagRewriter.removeTags("minecraft:cat_variant"); @@ -141,9 +138,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol(this).register(ClientboundPackets1_19.STATISTICS); - final CommandRewriter commandRewriter = new CommandRewriter1_19(this); + final CommandRewriter commandRewriter = new CommandRewriter1_19(this); registerClientbound(ClientboundPackets1_19.DECLARE_COMMANDS, new PacketRemapper() { @Override public void registerMap() { @@ -299,17 +296,17 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } @Override - public EntityRewriter getEntityRewriter() { + public EntityPackets1_19 getEntityRewriter() { return entityRewriter; } @Override - public ItemRewriter getItemRewriter() { + public BlockItemPackets1_19 getItemRewriter() { return blockItemPackets; } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/CommandRewriter1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/CommandRewriter1_19.java index d54de119..65e8e05d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/CommandRewriter1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/data/CommandRewriter1_19.java @@ -17,13 +17,14 @@ */ package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.data; -import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.rewriter.CommandRewriter; -public final class CommandRewriter1_19 extends CommandRewriter { +public final class CommandRewriter1_19 extends CommandRewriter { - public CommandRewriter1_19(Protocol protocol) { + public CommandRewriter1_19(Protocol1_18_2To1_19 protocol) { super(protocol); this.parserHandlers.put("minecraft:template_mirror", wrapper -> wrapper.write(Type.VAR_INT, 0)); this.parserHandlers.put("minecraft:template_rotation", wrapper -> wrapper.write(Type.VAR_INT, 0)); 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 917baa15..719d1166 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 @@ -36,7 +36,7 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPacke import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.util.MathUtil; -public final class BlockItemPackets1_19 extends ItemRewriter { +public final class BlockItemPackets1_19 extends ItemRewriter { public BlockItemPackets1_19(final Protocol1_18_2To1_19 protocol) { super(protocol); @@ -44,9 +44,9 @@ public final class BlockItemPackets1_19 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); - new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_19.DECLARE_RECIPES); + new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_19.DECLARE_RECIPES); registerSetCooldown(ClientboundPackets1_19.COOLDOWN); registerWindowItems1_17_1(ClientboundPackets1_19.WINDOW_ITEMS); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java index 96f63fe4..412958c4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18_2to1_19/packets/EntityPackets1_19.java @@ -41,7 +41,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; -public final class EntityPackets1_19 extends EntityRewriter { +public final class EntityPackets1_19 extends EntityRewriter { public EntityPackets1_19(final Protocol1_18_2To1_19 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java index 6f92352a..cebf7f16 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_18to1_18_2/data/CommandRewriter1_18_2.java @@ -17,14 +17,15 @@ */ package com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.data; -import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.Protocol1_18To1_18_2; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.rewriter.CommandRewriter; import org.checkerframework.checker.nullness.qual.Nullable; -public final class CommandRewriter1_18_2 extends CommandRewriter { +public final class CommandRewriter1_18_2 extends CommandRewriter { - public CommandRewriter1_18_2(Protocol protocol) { + public CommandRewriter1_18_2(Protocol1_18To1_18_2 protocol) { super(protocol); // Uncompletable without the full list diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java index d788b1da..88bd16d8 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/Protocol1_19_1To1_19_3.java @@ -34,8 +34,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; -import com.viaversion.viaversion.api.rewriter.ItemRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.BitSetType; import com.viaversion.viaversion.api.type.types.ByteArrayType; @@ -54,7 +52,6 @@ import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.CipherUtil; - import java.util.BitSet; public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol { @@ -64,7 +61,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); public Protocol1_19_1To1_19_3() { super(ClientboundPackets1_19_3.class, ClientboundPackets1_19_1.class, ServerboundPackets1_19_3.class, ServerboundPackets1_19_1.class); @@ -91,7 +88,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND); registerClientbound(ClientboundPackets1_19_3.SOUND, new PacketRemapper() { @Override @@ -165,14 +162,14 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol tagRewriter = new TagRewriter<>(this); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:non_flammable_wood"); tagRewriter.addEmptyTag(RegistryType.ITEM, "minecraft:overworld_natural_logs"); tagRewriter.registerGeneric(ClientboundPackets1_19_3.TAGS); - new StatisticsRewriter(this).register(ClientboundPackets1_19_3.STATISTICS); + new StatisticsRewriter<>(this).register(ClientboundPackets1_19_3.STATISTICS); - final CommandRewriter commandRewriter = new CommandRewriter(this); + final CommandRewriter commandRewriter = new CommandRewriter<>(this); registerClientbound(ClientboundPackets1_19_3.DECLARE_COMMANDS, new PacketRemapper() { @Override public void registerMap() { @@ -388,17 +385,17 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } @Override - public ItemRewriter getItemRewriter() { + public BlockItemPackets1_19_3 getItemRewriter() { return itemRewriter; } @Override - public EntityRewriter getEntityRewriter() { + public EntityPackets1_19_3 getEntityRewriter() { return entityRewriter; } } 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 cb33b8a9..293646d8 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 @@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPacke import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3; import com.viaversion.viaversion.rewriter.BlockRewriter; -public final class BlockItemPackets1_19_3 extends ItemRewriter { +public final class BlockItemPackets1_19_3 extends ItemRewriter { public BlockItemPackets1_19_3(final Protocol1_19_1To1_19_3 protocol) { super(protocol); @@ -36,7 +36,7 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_19_3.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_19_3.BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_3.MULTI_BLOCK_CHANGE); @@ -64,7 +64,7 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter recipeRewriter = new RecipeRewriter1_16<>(protocol); protocol.registerClientbound(ClientboundPackets1_19_3.DECLARE_RECIPES, new PacketRemapper() { @Override public void registerMap() { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java index 2957e955..cdda19b3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_1to1_19_3/packets/EntityPackets1_19_3.java @@ -42,7 +42,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import java.util.BitSet; import java.util.UUID; -public final class EntityPackets1_19_3 extends EntityRewriter { +public final class EntityPackets1_19_3 extends EntityRewriter { private static final BitSetType PROFILE_ACTIONS_ENUM_TYPE = new BitSetType(6); private static final int[] PROFILE_ACTIONS = {2, 4, 5}; // Ignore initialize chat and listed status; add player already handled before diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java index 9806f2ca..3cb74505 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/Protocol1_19_3To1_19_4.java @@ -47,7 +47,7 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol commandRewriter = new CommandRewriter(this) { @Override public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception { if (argumentType.equals("minecraft:time")) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java index 17aed7f4..494554dd 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19_3to1_19_4/packets/EntityPackets1_19_4.java @@ -31,7 +31,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPac import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4; import com.viaversion.viaversion.rewriter.EntityRewriter; -public final class EntityPackets1_19_4 extends EntityRewriter { +public final class EntityPackets1_19_4 extends EntityRewriter { public EntityPackets1_19_4(final Protocol1_19_3To1_19_4 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java index d25d4d70..3865910d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/Protocol1_19To1_19_1.java @@ -33,7 +33,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; -import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -57,11 +56,10 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPacke import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets.EntityPackets; import com.viaversion.viaversion.util.CipherUtil; -import org.checkerframework.checker.nullness.qual.Nullable; - import java.util.ArrayList; import java.util.List; import java.util.UUID; +import org.checkerframework.checker.nullness.qual.Nullable; public final class Protocol1_19To1_19_1 extends BackwardsProtocol { @@ -70,7 +68,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); public Protocol1_19To1_19_1() { super(ClientboundPackets1_19_1.class, ClientboundPackets1_19.class, ServerboundPackets1_19_1.class, ServerboundPackets1_19.class); @@ -355,12 +353,12 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol getTranslatableRewriter() { return translatableRewriter; } @Override - public EntityRewriter getEntityRewriter() { + public EntityPackets1_19_1 getEntityRewriter() { return entityRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/packets/EntityPackets1_19_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/packets/EntityPackets1_19_1.java index fbc288ce..2e69f6f5 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/packets/EntityPackets1_19_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_19to1_19_1/packets/EntityPackets1_19_1.java @@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.type.types.version.Types1_19; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1; -public final class EntityPackets1_19_1 extends EntityRewriter { +public final class EntityPackets1_19_1 extends EntityRewriter { public EntityPackets1_19_1(final Protocol1_19To1_19_1 protocol) { super(protocol); 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 8c752b8b..41176838 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 @@ -53,7 +53,7 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); registerClientbound(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() { @Override public void registerMap() { 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 9c9f85e0..e4b237b5 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 @@ -32,7 +32,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac 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 BlockItemPackets1_10 extends LegacyBlockItemRewriter { +public class BlockItemPackets1_10 extends LegacyBlockItemRewriter { public BlockItemPackets1_10(Protocol1_9_4To1_10 protocol) { super(protocol); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java index eef5ebe8..e2c9bb7e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java @@ -39,7 +39,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac import java.util.List; import java.util.Optional; -public class EntityPackets1_10 extends LegacyEntityRewriter { +public class EntityPackets1_10 extends LegacyEntityRewriter { public EntityPackets1_10(Protocol1_9_4To1_10 protocol) { super(protocol);