diff --git a/build.gradle.kts b/build.gradle.kts index 2d24fea7..2ad3dc99 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "com.viaversion" - version = "4.0.0-1.17-pre4-SNAPSHOT" + version = "4.0.0-1.17-pre5-SNAPSHOT" description = "Allow older clients to join newer server versions." } 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 4d7bacb3..4009511b 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,11 +19,11 @@ 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.rewriter.RewriterBase; 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; import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; -import com.viaversion.viaversion.rewriter.RewriterBase; import org.checkerframework.checker.nullness.qual.Nullable; public abstract class ItemRewriterBase extends RewriterBase { 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 067cdd24..5de366f4 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 @@ -21,7 +21,7 @@ package com.viaversion.viabackwards.api.rewriters; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; -import com.viaversion.viaversion.rewriter.RewriterBase; +import com.viaversion.viaversion.api.rewriter.RewriterBase; @Deprecated public abstract class LegacySoundRewriter extends RewriterBase { 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 f0c9b606..258c7f43 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 @@ -35,7 +35,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client public class Protocol1_10To1_11 extends BackwardsProtocol { public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.11", "1.10", null, true); - private EntityPackets1_11 entityPackets; // Required for the item rewriter + private final EntityPackets1_11 entityPackets = new EntityPackets1_11(this); // Required for the item rewriter private BlockItemPackets1_11 blockItemPackets; public Protocol1_10To1_11() { @@ -44,7 +44,7 @@ public class Protocol1_10To1_11 extends BackwardsProtocol { + protocol.getEntityRewriter().filter().handler((event, meta) -> { if (meta.metaType().type().equals(Type.ITEM)) // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); }); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java index d83bc0a2..3f422c03 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_11_1to1_12/Protocol1_11_1To1_12.java @@ -39,7 +39,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; public class Protocol1_11_1To1_12 extends BackwardsProtocol { - private EntityPackets1_12 entityPackets; + private final EntityPackets1_12 entityPackets = new EntityPackets1_12(this); private BlockItemPackets1_12 blockItemPackets; public Protocol1_11_1To1_12() { @@ -48,7 +48,7 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol { + protocol.getEntityRewriter().filter().handler((event, meta) -> { if (meta.metaType().type().equals(Type.ITEM)) // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); }); 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 5874011f..b3e2e210 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 @@ -26,7 +26,7 @@ import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; import com.viaversion.viaversion.rewriter.ComponentRewriter; -import com.viaversion.viaversion.rewriter.RewriterBase; +import com.viaversion.viaversion.api.rewriter.RewriterBase; public class ChatPackets1_12 extends RewriterBase { 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 af388ac9..69b845e5 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 @@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client public class Protocol1_11To1_11_1 extends BackwardsProtocol { - private EntityPackets1_11_1 entityPackets; + private final EntityPackets1_11_1 entityPackets = new EntityPackets1_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); @@ -38,7 +38,7 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol { + protocol.getEntityRewriter().filter().handler((event, meta) -> { if (meta.metaType().type().equals(Type.ITEM)) { // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/Protocol1_12_2To1_13.java index 5b5e7621..921c3638 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,6 +34,7 @@ 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; @@ -46,6 +47,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 BlockItemPackets1_13 blockItemPackets; public Protocol1_12_2To1_13() { @@ -79,7 +81,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol { private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"}; 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 dc89a844..e2bee54c 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 @@ -31,6 +31,7 @@ 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; @@ -44,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 BlockItemPackets1_14 blockItemPackets; - private EntityPackets1_14 entityPackets; public Protocol1_13_2To1_14() { super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class); @@ -68,12 +69,11 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol { 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 c9d74569..bfc2c44a 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 @@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; -import com.viaversion.viaversion.rewriter.RewriterBase; +import com.viaversion.viaversion.api.rewriter.RewriterBase; public class SoundPackets1_14 extends RewriterBase { 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 f42d10b1..854b4c70 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 @@ -31,6 +31,7 @@ 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.type.Type; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -47,6 +48,7 @@ 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); public Protocol1_13To1_13_1() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); @@ -56,7 +58,7 @@ public class Protocol1_13To1_13_1 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 BlockItemPackets1_15 blockItemPackets; public Protocol1_14_4To1_15() { @@ -63,7 +64,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol { + private final EntityRewriter entityRewriter = new EntityPackets1_14_1(this); + public Protocol1_14To1_14_1() { super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); } @Override protected void registerPackets() { - new EntityPackets1_14_1(this).register(); + entityRewriter.register(); } @Override public void init(UserConnection user) { user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_15Types.PLAYER)); } + + @Override + public EntityRewriter getEntityRewriter() { + return entityRewriter; + } } 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 51e16c74..8513747f 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 @@ -31,6 +31,7 @@ import com.viaversion.viaversion.api.connection.UserConnection; 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; @@ -45,12 +46,14 @@ import com.viaversion.viaversion.rewriter.RegistryType; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.GsonUtil; +import org.checkerframework.checker.nullness.qual.Nullable; 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 BlockItemPackets1_16 blockItemPackets; private TranslatableRewriter translatableRewriter; @@ -73,8 +76,7 @@ public class Protocol1_15_2To1_16 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 BlockItemPackets1_16_2 blockItemPackets; private TranslatableRewriter translatableRewriter; @@ -67,8 +69,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol { + protocol.getEntityRewriter().filter().handler((event, meta) -> { if (meta.metaType().type().equals(Type.ITEM)) // Is Item meta.setValue(handleItemToClient((Item) meta.getValue())); }); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 83d0c98e..302fb93c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.0" [versions] # ViaVersion -viaver = "4.0.0-1.17-pre4-SNAPSHOT" +viaver = "4.0.0-1.17-pre5-SNAPSHOT" # Common provided netty = "4.0.20.Final"