From a94d06716cce6fac1c43437e5710a7b8c912435d Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Mon, 28 Oct 2024 11:28:12 +0100 Subject: [PATCH] Use new ParticleRewriter (#901) --- .../BackwardsStructuredItemRewriter.java | 7 +-- .../api/rewriters/EntityRewriterBase.java | 6 +- .../template/BlockItemPacketRewriter1_99.java | 2 - .../protocol/template/Protocol1_98To1_99.java | 13 +++++ .../v1_13_1to1_13/Protocol1_13_1To1_13.java | 9 +++ .../rewriter/EntityPacketRewriter1_13_1.java | 4 +- .../rewriter/ItemPacketRewriter1_13_1.java | 3 - .../v1_14to1_13_2/Protocol1_14To1_13_2.java | 11 +++- .../rewriter/BlockItemPacketRewriter1_14.java | 10 ++-- .../rewriter/EntityPacketRewriter1_14.java | 6 +- .../v1_15to1_14_4/Protocol1_15To1_14_4.java | 9 ++- .../Protocol1_16_2To1_16_1.java | 11 +++- .../BlockItemPacketRewriter1_16_2.java | 2 - .../v1_16to1_15_2/Protocol1_16To1_15_2.java | 17 ++++-- .../rewriter/BlockItemPacketRewriter1_16.java | 16 +++--- .../rewriter/EntityPacketRewriter1_16.java | 6 +- .../v1_17to1_16_4/Protocol1_17To1_16_4.java | 7 +++ .../rewriter/BlockItemPacketRewriter1_17.java | 2 +- .../rewriter/EntityPacketRewriter1_17.java | 7 ++- .../v1_18to1_17_1/Protocol1_18To1_17_1.java | 8 ++- .../rewriter/EntityPacketRewriter1_18.java | 8 +-- .../Protocol1_19_3To1_19_1.java | 12 +++- .../BlockItemPacketRewriter1_19_3.java | 1 - .../Protocol1_19_4To1_19_3.java | 11 +++- .../BlockItemPacketRewriter1_19_4.java | 3 +- .../v1_19to1_18_2/Protocol1_19To1_18_2.java | 14 +++-- .../rewriter/BlockItemPacketRewriter1_19.java | 2 +- .../rewriter/EntityPacketRewriter1_19.java | 10 ++-- .../v1_20_2to1_20/Protocol1_20_2To1_20.java | 11 +++- .../BlockItemPacketRewriter1_20_2.java | 1 - .../Protocol1_20_3To1_20_2.java | 21 ++++--- .../BlockItemPacketRewriter1_20_3.java | 10 ++-- .../Protocol1_20_5To1_20_3.java | 7 +++ .../BlockItemPacketRewriter1_20_5.java | 7 +-- .../v1_20to1_19_4/Protocol1_20To1_19_4.java | 12 +++- .../rewriter/BlockItemPacketRewriter1_20.java | 11 ++-- .../v1_21_2to1_21/Protocol1_21_2To1_21.java | 9 +++ .../BlockItemPacketRewriter1_21_2.java | 29 +--------- .../rewriter/ParticleRewriter1_21_2.java | 57 +++++++++++++++++++ .../v1_21to1_20_5/Protocol1_21To1_20_5.java | 12 ++++ .../rewriter/BlockItemPacketRewriter1_21.java | 5 +- 41 files changed, 282 insertions(+), 127 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ParticleRewriter1_21_2.java diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java index e5a81d90..9869c7b9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java @@ -25,7 +25,6 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.data.MappedItem; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -35,7 +34,6 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.rewriter.StructuredItemRewriter; import java.util.ArrayList; import java.util.List; -import java.util.function.Function; import org.checkerframework.checker.nullness.qual.Nullable; public class BackwardsStructuredItemRewriter itemType, Type itemArrayType, Type mappedItemType, Type mappedItemArrayType, - Type itemCostType, Type optionalItemCostType, Type mappedItemCostType, Type mappedOptionalItemCostType, - Type particleType, Type mappedParticleType + Type itemCostType, Type optionalItemCostType, Type mappedItemCostType, Type mappedOptionalItemCostType ) { - super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, itemCostType, optionalItemCostType, mappedItemCostType, mappedOptionalItemCostType, particleType, mappedParticleType); + super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, itemCostType, optionalItemCostType, mappedItemCostType, mappedOptionalItemCostType); } public BackwardsStructuredItemRewriter(final T protocol, final Type itemType, final Type itemArrayType, final Type mappedItemType, final Type mappedItemArrayType) { 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 a720700f..a0c6be46 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 @@ -185,7 +185,7 @@ public abstract class EntityRewriterBase { @@ -54,6 +57,7 @@ final class Protocol1_98To1_99 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this, Types1_21_2.PARTICLE/*, Types1_OLD.PARTICLE*/); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -89,6 +93,10 @@ final class Protocol1_98To1_99 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TranslatableRewriter getComponentRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java index 2ed9918f..1ad6880d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/Protocol1_13_1To1_13.java @@ -41,6 +41,7 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPacke import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.ComponentUtil; @@ -50,6 +51,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -72,6 +74,8 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + public TranslatableRewriter translatableRewriter() { return translatableRewriter; } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java index b63a5bad..88e0a038 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_13_1to1_13/rewriter/EntityPacketRewriter1_13_1.java @@ -22,8 +22,8 @@ import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13; import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; -import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; +import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_13; @@ -138,7 +138,7 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter { @@ -45,6 +46,7 @@ public class Protocol1_14To1_13_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); public Protocol1_14To1_13_2() { @@ -63,6 +65,8 @@ public class Protocol1_14To1_13_2 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TranslatableRewriter getComponentRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java index 8fe48094..6629d7f0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_14to1_13_2/rewriter/BlockItemPacketRewriter1_14.java @@ -18,6 +18,9 @@ package com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter; import com.google.common.collect.ImmutableSet; +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.ListTag; +import com.viaversion.nbt.tag.StringTag; import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter; import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; @@ -35,8 +38,8 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; -import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; +import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; @@ -45,9 +48,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13; import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.ListTag; -import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.libs.gson.JsonParseException; import com.viaversion.viaversion.libs.mcstructs.text.utils.TextUtils; import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13; @@ -430,8 +430,6 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter { - rewriteParticle(event.user(), (Particle) data.getValue()); + protocol.getParticleRewriter().rewriteParticle(event.user(), (Particle) data.getValue()); }); filter().type(EntityTypes1_14.FIREWORK_ROCKET).index(8).handler((event, data) -> { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java index b0ad6fe8..d0cce1a7 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_15to1_14_4/Protocol1_15To1_14_4.java @@ -21,9 +21,9 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; -import com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage.ImmediateRespawnStorage; import com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter.BlockItemPacketRewriter1_15; import com.viaversion.viabackwards.protocol.v1_15to1_14_4.rewriter.EntityPacketRewriter1_15; +import com.viaversion.viabackwards.protocol.v1_15to1_14_4.storage.ImmediateRespawnStorage; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.RegistryType; @@ -37,6 +37,7 @@ import com.viaversion.viaversion.protocols.v1_14_3to1_14_4.packet.ClientboundPac import com.viaversion.viaversion.protocols.v1_14_4to1_15.Protocol1_14_4To1_15; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -45,6 +46,7 @@ public class Protocol1_15To1_14_4 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -124,6 +126,11 @@ public class Protocol1_15To1_14_4 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java index a78d15c5..e9313f29 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/Protocol1_16_2To1_16_1.java @@ -21,8 +21,8 @@ import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; -import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.CommandRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.BlockItemPacketRewriter1_16_2; +import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.CommandRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.EntityPacketRewriter1_16_2; import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage; import com.viaversion.viaversion.api.connection.UserConnection; @@ -38,6 +38,7 @@ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.Protocol1_16_1To1_16_ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ClientboundPackets1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPackets1_16_2; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.ProtocolLogger; @@ -48,6 +49,7 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -67,6 +69,8 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); @@ -151,6 +155,11 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/BlockItemPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/BlockItemPacketRewriter1_16_2.java index bd371d0f..2f437f56 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/BlockItemPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16_2to1_16_1/rewriter/BlockItemPacketRewriter1_16_2.java @@ -114,8 +114,6 @@ public class BlockItemPacketRewriter1_16_2 extends BackwardsItemRewriter handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/Protocol1_16To1_15_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/Protocol1_16To1_15_2.java index 136bf0fe..8cd66bf9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/Protocol1_16To1_15_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/Protocol1_16To1_15_2.java @@ -19,14 +19,14 @@ package com.viaversion.viabackwards.protocol.v1_16to1_15_2; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; -import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.TranslatableRewriter1_16; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.BackwardsMappingData1_16; -import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.CommandRewriter1_16; -import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.PlayerAttributesStorage; -import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WorldNameTracker; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.BlockItemPacketRewriter1_16; +import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.CommandRewriter1_16; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.EntityPacketRewriter1_16; +import com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter.TranslatableRewriter1_16; +import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.PlayerAttributesStorage; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.PlayerSneakStorage; +import com.viaversion.viabackwards.protocol.v1_16to1_15_2.storage.WorldNameTracker; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.RegistryType; @@ -43,6 +43,7 @@ import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPacke import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ServerboundPackets1_16; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.GsonUtil; @@ -53,6 +54,7 @@ public class Protocol1_16To1_15_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter1_16 translatableRewriter = new TranslatableRewriter1_16(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -71,6 +73,8 @@ public class Protocol1_16To1_15_2 extends BackwardsProtocol { @@ -196,6 +200,11 @@ public class Protocol1_16To1_15_2 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/BlockItemPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/BlockItemPacketRewriter1_16.java index a5976495..69970dc4 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/BlockItemPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_16to1_15_2/rewriter/BlockItemPacketRewriter1_16.java @@ -17,12 +17,18 @@ */ package com.viaversion.viabackwards.protocol.v1_16to1_15_2.rewriter; +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.IntArrayTag; +import com.viaversion.nbt.tag.ListTag; +import com.viaversion.nbt.tag.LongArrayTag; +import com.viaversion.nbt.tag.StringTag; +import com.viaversion.nbt.tag.Tag; import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter; import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter; import com.viaversion.viabackwards.api.rewriters.MapColorRewriter; +import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.Protocol1_16To1_15_2; import com.viaversion.viabackwards.protocol.v1_16to1_15_2.data.MapColorMappings1_15_2; -import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @@ -33,12 +39,6 @@ import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.IntArrayTag; -import com.viaversion.nbt.tag.ListTag; -import com.viaversion.nbt.tag.LongArrayTag; -import com.viaversion.nbt.tag.StringTag; -import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.protocols.v1_14_4to1_15.packet.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.v1_15_2to1_16.packet.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.ItemPacketRewriter1_16; @@ -179,8 +179,6 @@ public class BlockItemPacketRewriter1_16 extends BackwardsItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -254,6 +256,11 @@ public final class Protocol1_17To1_16_4 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java index ad4c87a2..10fbb3ef 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_17to1_16_4/rewriter/BlockItemPacketRewriter1_17.java @@ -204,7 +204,7 @@ public final class BlockItemPacketRewriter1_17 extends BackwardsItemRewriter { @@ -42,6 +42,7 @@ public final class Protocol1_18To1_17_1 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -151,6 +152,11 @@ public final class Protocol1_18To1_17_1 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TranslatableRewriter getComponentRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/rewriter/EntityPacketRewriter1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/rewriter/EntityPacketRewriter1_18.java index 685ec209..7e060fdc 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/rewriter/EntityPacketRewriter1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_18to1_17_1/rewriter/EntityPacketRewriter1_18.java @@ -17,6 +17,9 @@ */ package com.viaversion.viabackwards.protocol.v1_18to1_17_1.rewriter; +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.ListTag; +import com.viaversion.nbt.tag.StringTag; import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.protocol.v1_18to1_17_1.Protocol1_18To1_17_1; import com.viaversion.viaversion.api.minecraft.Particle; @@ -28,9 +31,6 @@ import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.version.Types1_17; import com.viaversion.viaversion.api.type.types.version.Types1_18; import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.ListTag; -import com.viaversion.nbt.tag.StringTag; import com.viaversion.viaversion.util.TagUtil; public final class EntityPacketRewriter1_18 extends EntityRewriter { @@ -110,7 +110,7 @@ public final class EntityPacketRewriter1_18 extends EntityRewriter particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -95,6 +96,8 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND); registerClientbound(ClientboundPackets1_19_3.SOUND, wrapper -> { @@ -412,6 +415,11 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public EntityPacketRewriter1_19_3 getEntityRewriter() { return entityRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/rewriter/BlockItemPacketRewriter1_19_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/rewriter/BlockItemPacketRewriter1_19_3.java index c42800b7..ea0147bf 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/rewriter/BlockItemPacketRewriter1_19_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_3to1_19_1/rewriter/BlockItemPacketRewriter1_19_3.java @@ -54,7 +54,6 @@ public final class BlockItemPacketRewriter1_19_3 extends BackwardsItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -74,6 +76,8 @@ public final class Protocol1_19_4To1_19_3 extends BackwardsProtocol(this) { @Override public void handleArgument(final PacketWrapper wrapper, final String argumentType) { @@ -123,6 +127,11 @@ public final class Protocol1_19_4To1_19_3 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public EntityPacketRewriter1_19_4 getEntityRewriter() { return entityRewriter; @@ -137,4 +146,4 @@ public final class Protocol1_19_4To1_19_3 extends BackwardsProtocol getTagRewriter() { return tagRewriter; } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/rewriter/BlockItemPacketRewriter1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/rewriter/BlockItemPacketRewriter1_19_4.java index ea85e512..ed281470 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/rewriter/BlockItemPacketRewriter1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19_4to1_19_3/rewriter/BlockItemPacketRewriter1_19_4.java @@ -73,7 +73,6 @@ public final class BlockItemPacketRewriter1_19_4 extends BackwardsItemRewriter recipeRewriter = new RecipeRewriter1_19_3<>(protocol) { @Override @@ -121,4 +120,4 @@ public final class BlockItemPacketRewriter1_19_4 extends BackwardsItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -386,6 +387,11 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/rewriter/BlockItemPacketRewriter1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/rewriter/BlockItemPacketRewriter1_19.java index a9254766..4f6b491e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/rewriter/BlockItemPacketRewriter1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/rewriter/BlockItemPacketRewriter1_19.java @@ -141,7 +141,7 @@ public final class BlockItemPacketRewriter1_19 extends BackwardsItemRewriter= 8) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/Protocol1_20_2To1_20.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/Protocol1_20_2To1_20.java index e240ba0d..422fdd2b 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/Protocol1_20_2To1_20.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/Protocol1_20_2To1_20.java @@ -17,6 +17,7 @@ */ package com.viaversion.viabackwards.protocol.v1_20_2to1_20; +import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; @@ -36,7 +37,6 @@ import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.exception.InformativeException; -import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets; import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; @@ -46,6 +46,7 @@ import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfi import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPackets1_20_2; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import java.util.UUID; @@ -54,6 +55,7 @@ public final class Protocol1_20_2To1_20 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20_2To1_20() { @@ -71,6 +73,8 @@ public final class Protocol1_20_2To1_20 extends BackwardsProtocol { final int slot = wrapper.read(Types.VAR_INT); wrapper.write(Types.BYTE, (byte) slot); @@ -225,6 +229,11 @@ public final class Protocol1_20_2To1_20 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java index 392cb6cb..15bede89 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_2to1_20/rewriter/BlockItemPacketRewriter1_20_2.java @@ -69,7 +69,6 @@ public final class BlockItemPacketRewriter1_20_2 extends BackwardsItemRewriter { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java index 9fdc0ae0..699c2b89 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/Protocol1_20_3To1_20_2.java @@ -17,6 +17,7 @@ */ package com.viaversion.viabackwards.protocol.v1_20_3to1_20_2; +import com.viaversion.nbt.tag.Tag; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.rewriters.SoundRewriter; @@ -36,21 +37,21 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.libs.fastutil.Pair; -import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.CommandRewriter1_19_4; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPacket1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPackets1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.Protocol1_20_2To1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundConfigurationPackets1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ServerboundPacket1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ServerboundPackets1_20_3; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPacket1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPackets1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.ComponentUtil; @@ -64,6 +65,7 @@ public final class Protocol1_20_3To1_20_2 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -392,6 +394,11 @@ public final class Protocol1_20_3To1_20_2 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public EntityPacketRewriter1_20_3 getEntityRewriter() { return entityRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/rewriter/BlockItemPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/rewriter/BlockItemPacketRewriter1_20_3.java index b8023f40..3defb021 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/rewriter/BlockItemPacketRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_3to1_20_2/rewriter/BlockItemPacketRewriter1_20_3.java @@ -17,21 +17,19 @@ */ package com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.rewriter; -import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter; import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.Protocol1_20_3To1_20_2; import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; -import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.rewriter.BlockRewriter; public final class BlockItemPacketRewriter1_20_3 extends BackwardsItemRewriter { @@ -87,7 +85,7 @@ public final class BlockItemPacketRewriter1_20_3 extends BackwardsItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TranslatableRewriter translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -247,6 +249,11 @@ public final class Protocol1_20_5To1_20_3 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TranslatableRewriter getComponentRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 16f764e7..d3072043 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -50,7 +50,6 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPac import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.StructuredDataConverter; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.util.Key; -import java.util.function.Function; import org.checkerframework.checker.nullness.qual.Nullable; public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItemRewriter { @@ -108,7 +107,7 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem // Move it to the beginning, move out arguments here final Particle particle = wrapper.read(Types1_20_5.PARTICLE); - rewriteParticle(wrapper.user(), particle); + protocol.getParticleRewriter().rewriteParticle(wrapper.user(), particle); if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) { // Remove color argument final int color = particle.removeArgument(0).getValue(); @@ -144,8 +143,8 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem final Particle smallExplosionParticle = wrapper.passthroughAndMap(Types1_20_5.PARTICLE, Types1_20_3.PARTICLE); final Particle largeExplosionParticle = wrapper.passthroughAndMap(Types1_20_5.PARTICLE, Types1_20_3.PARTICLE); - rewriteParticle(wrapper.user(), smallExplosionParticle); - rewriteParticle(wrapper.user(), largeExplosionParticle); + protocol.getParticleRewriter().rewriteParticle(wrapper.user(), smallExplosionParticle); + protocol.getParticleRewriter().rewriteParticle(wrapper.user(), largeExplosionParticle); final Holder soundEventHolder = wrapper.read(Types.SOUND_EVENT); if (soundEventHolder.isDirect()) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java index e8a941ae..cadae68d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/Protocol1_20To1_19_4.java @@ -26,12 +26,12 @@ import com.viaversion.viabackwards.protocol.v1_20to1_19_4.rewriter.EntityPacketR import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; -import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPackets1_19_4; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.ArrayUtil; @@ -42,6 +42,7 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON); private final EntityPacketRewriter1_20 entityRewriter = new EntityPacketRewriter1_20(this); private final BlockItemPacketRewriter1_20 itemRewriter = new BlockItemPacketRewriter1_20(this); + private final ParticleRewriter particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20To1_19_4() { @@ -60,6 +61,8 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol(this).register(ClientboundPackets1_19_4.AWARD_STATS); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.SET_ACTION_BAR_TEXT); @@ -108,6 +111,11 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TranslatableRewriter getComponentRewriter() { return translatableRewriter; @@ -117,4 +125,4 @@ public final class Protocol1_20To1_19_4 extends BackwardsProtocol getTagRewriter() { return tagRewriter; } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/rewriter/BlockItemPacketRewriter1_20.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/rewriter/BlockItemPacketRewriter1_20.java index a25f34da..7d9e4d6d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/rewriter/BlockItemPacketRewriter1_20.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20to1_19_4/rewriter/BlockItemPacketRewriter1_20.java @@ -17,6 +17,10 @@ */ package com.viaversion.viabackwards.protocol.v1_20to1_19_4.rewriter; +import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.ListTag; +import com.viaversion.nbt.tag.StringTag; +import com.viaversion.nbt.tag.Tag; import com.viaversion.viabackwards.api.rewriters.BackwardsItemRewriter; import com.viaversion.viabackwards.protocol.v1_20to1_19_4.Protocol1_20To1_19_4; import com.viaversion.viabackwards.protocol.v1_20to1_19_4.storage.BackSignEditStorage; @@ -28,10 +32,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18; -import com.viaversion.nbt.tag.CompoundTag; -import com.viaversion.nbt.tag.ListTag; -import com.viaversion.nbt.tag.StringTag; -import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ServerboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.RecipeRewriter1_19_4; @@ -100,7 +100,6 @@ public final class BlockItemPacketRewriter1_20 extends BackwardsItemRewriter { wrapper.passthrough(Types.BOOLEAN); // Reset/clear @@ -232,4 +231,4 @@ public final class BlockItemPacketRewriter1_20 extends BackwardsItemRewriter translatableRewriter = new ComponentRewriter1_21_2(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -79,6 +81,8 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol(this).register(ClientboundPackets1_21_2.AWARD_STATS); new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES); @@ -176,6 +180,11 @@ public final class Protocol1_21_2To1_21 extends BackwardsProtocol getComponentRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java index 0bba1db1..9e8dac22 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/BlockItemPacketRewriter1_21_2.java @@ -47,8 +47,7 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem public BlockItemPacketRewriter1_21_2(final Protocol1_21_2To1_21 protocol) { super(protocol, Types1_21_2.ITEM, Types1_21_2.ITEM_ARRAY, Types1_21.ITEM, Types1_21.ITEM_ARRAY, - Types1_21_2.ITEM_COST, Types1_21_2.OPTIONAL_ITEM_COST, Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, - Types1_21_2.PARTICLE, Types1_21.PARTICLE + Types1_21_2.ITEM_COST, Types1_21_2.OPTIONAL_ITEM_COST, Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST ); } @@ -66,7 +65,6 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem registerSetEquipment(ClientboundPackets1_21_2.SET_EQUIPMENT); registerMerchantOffers1_20_5(ClientboundPackets1_21_2.MERCHANT_OFFERS); registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT); - registerLevelParticles1_20_5(ClientboundPackets1_21_2.LEVEL_PARTICLES); protocol.registerClientbound(ClientboundPackets1_21_2.COOLDOWN, wrapper -> { final MappingData mappingData = protocol.getMappingData(); @@ -171,7 +169,7 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem wrapper.write(Types.VAR_INT, 0); // Block interaction type final Particle explosionParticle = wrapper.read(Types1_21.PARTICLE); - rewriteParticle(wrapper.user(), explosionParticle); + protocol.getParticleRewriter().rewriteParticle(wrapper.user(), explosionParticle); // As small and large explosion particle wrapper.write(Types1_21_2.PARTICLE, explosionParticle); wrapper.write(Types1_21_2.PARTICLE, explosionParticle); @@ -250,29 +248,6 @@ public final class BlockItemPacketRewriter1_21_2 extends BackwardsStructuredItem wrapper.write(Types.VAR_INT, intId); } - @Override - public void rewriteParticle(final UserConnection connection, final Particle particle) { - super.rewriteParticle(connection, particle); - - final String identifier = protocol.getMappingData().getParticleMappings().mappedIdentifier(particle.id()); - if (identifier.equals("minecraft:dust_color_transition")) { - argbToVector(particle, 0); - argbToVector(particle, 3); - } else if (identifier.equals("minecraft:dust")) { - argbToVector(particle, 0); - } - } - - private void argbToVector(final Particle particle, final int index) { - final int argb = particle.removeArgument(index).getValue(); - final float r = ((argb >> 16) & 0xFF) / 255F; - final float g = ((argb >> 8) & 0xFF) / 255F; - final float b = (argb & 0xFF) / 255F; - particle.add(index, Types.FLOAT, r); - particle.add(index + 1, Types.FLOAT, g); - particle.add(index + 2, Types.FLOAT, b); - } - @Override public Item handleItemToClient(final UserConnection connection, final Item item) { super.handleItemToClient(connection, item); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ParticleRewriter1_21_2.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ParticleRewriter1_21_2.java new file mode 100644 index 00000000..a5ac14e1 --- /dev/null +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21_2to1_21/rewriter/ParticleRewriter1_21_2.java @@ -0,0 +1,57 @@ +/* + * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards + * Copyright (C) 2016-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.viaversion.viabackwards.protocol.v1_21_2to1_21.rewriter; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.Particle; +import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.api.type.Types; +import com.viaversion.viaversion.api.type.types.version.Types1_21; +import com.viaversion.viaversion.api.type.types.version.Types1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2; +import com.viaversion.viaversion.rewriter.ParticleRewriter; + +public final class ParticleRewriter1_21_2 extends ParticleRewriter { + + public ParticleRewriter1_21_2(final Protocol protocol) { + super(protocol, Types1_21_2.PARTICLE, Types1_21.PARTICLE); + } + + @Override + public void rewriteParticle(final UserConnection connection, final Particle particle) { + super.rewriteParticle(connection, particle); + + final String identifier = protocol.getMappingData().getParticleMappings().mappedIdentifier(particle.id()); + if (identifier.equals("minecraft:dust_color_transition")) { + argbToVector(particle, 0); + argbToVector(particle, 3); + } else if (identifier.equals("minecraft:dust")) { + argbToVector(particle, 0); + } + } + + private void argbToVector(final Particle particle, final int index) { + final int argb = particle.removeArgument(index).getValue(); + final float r = ((argb >> 16) & 0xFF) / 255F; + final float g = ((argb >> 8) & 0xFF) / 255F; + final float b = (argb & 0xFF) / 255F; + particle.add(index, Types.FLOAT, r); + particle.add(index + 1, Types.FLOAT, g); + particle.add(index + 2, Types.FLOAT, b); + } +} diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java index e18759c8..2dfafe16 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/Protocol1_21To1_20_5.java @@ -34,6 +34,8 @@ import com.viaversion.viaversion.api.minecraft.item.data.ChatType; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; import com.viaversion.viaversion.api.type.Types; +import com.viaversion.viaversion.api.type.types.version.Types1_20_5; +import com.viaversion.viaversion.api.type.types.version.Types1_21; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5; @@ -45,6 +47,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21; import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.ArrayUtil; @@ -56,6 +59,7 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol particleRewriter = new ParticleRewriter<>(this, Types1_21.PARTICLE, Types1_20_5.PARTICLE); private final TranslatableRewriter translatableRewriter = new ComponentRewriter1_21(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -75,6 +79,9 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol(this).register(ClientboundPackets1_21.AWARD_STATS); translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_ACTION_BAR_TEXT); @@ -206,6 +213,11 @@ public final class Protocol1_21To1_20_5 extends BackwardsProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TranslatableRewriter getComponentRewriter() { return translatableRewriter; diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java index 02091d06..4be17c25 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_21to1_20_5/rewriter/BlockItemPacketRewriter1_21.java @@ -63,8 +63,7 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe public BlockItemPacketRewriter1_21(final Protocol1_21To1_20_5 protocol) { super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY, - Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST, - Types1_21.PARTICLE, Types1_20_5.PARTICLE + Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST ); } @@ -85,8 +84,6 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK); registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS); registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT); - registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES); - registerExplosion(ClientboundPackets1_21.EXPLODE); protocol.registerClientbound(ClientboundPackets1_21.OPEN_SCREEN, wrapper -> { wrapper.passthrough(Types.VAR_INT); // Id