diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java index da6cbc09f..7e5ab8e4e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/Protocol.java @@ -36,6 +36,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.rewriter.ComponentRewriter; import com.viaversion.viaversion.api.rewriter.EntityRewriter; import com.viaversion.viaversion.api.rewriter.ItemRewriter; +import com.viaversion.viaversion.api.rewriter.ParticleRewriter; import com.viaversion.viaversion.api.rewriter.TagRewriter; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.exception.CancelException; @@ -374,6 +375,15 @@ public interface Protocol> extends Rewriter. + */ +package com.viaversion.viaversion.api.rewriter; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.Particle; + +public interface ParticleRewriter { + + void rewriteParticle(UserConnection connection, Particle particle); + +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/template/BlockItemPacketRewriter1_99.java b/common/src/main/java/com/viaversion/viaversion/protocols/template/BlockItemPacketRewriter1_99.java index fe33bd3df..1921cadb8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/template/BlockItemPacketRewriter1_99.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/template/BlockItemPacketRewriter1_99.java @@ -23,8 +23,8 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPac import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5; 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.RecipeDisplayRewriter; import com.viaversion.viaversion.rewriter.BlockRewriter; +import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter; import com.viaversion.viaversion.rewriter.StructuredItemRewriter; // To replace if needed: @@ -37,8 +37,7 @@ final class BlockItemPacketRewriter1_99 extends StructuredItemRewriter recipeRewriter = new RecipeDisplayRewriter<>(protocol); recipeRewriter.registerUpdateRecipes(ClientboundPackets1_21.UPDATE_RECIPES); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/template/Protocol1_99To_98.java b/common/src/main/java/com/viaversion/viaversion/protocols/template/Protocol1_99To_98.java index 3befaa2f0..9609dcc3a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/template/Protocol1_99To_98.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/template/Protocol1_99To_98.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; import com.viaversion.viaversion.api.rewriter.ComponentRewriter; +import com.viaversion.viaversion.api.type.types.version.Types1_21_2; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5; import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5; @@ -33,6 +34,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfi 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.AttributeRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -44,12 +46,14 @@ import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap; // ClientboundPacket1_21 // ServerboundPacket1_20_5 // EntityTypes1_20_5 (MAPPED type) +// Types1_21_2.PARTICLE // 1.99, 1.98 final class Protocol1_99To_98 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingDataBase("1.98", "1.99"); private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this); private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this); + private final ParticleRewriter particleRewriter = new ParticleRewriter<>(this, /*Types1_OLD.PARTICLE,*/ Types1_21_2.PARTICLE); private final TagRewriter tagRewriter = new TagRewriter<>(this); private final ComponentRewriter1_99 componentRewriter = new ComponentRewriter1_99(this); @@ -79,6 +83,10 @@ final class Protocol1_99To_98 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND); soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND_ENTITY); @@ -146,6 +154,11 @@ final class Protocol1_99To_98 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java index f663cfaab..99d7ce593 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/Protocol1_13_2To1_14.java @@ -23,15 +23,16 @@ import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; +import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13; -import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.ComponentRewriter1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.data.MappingData1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ServerboundPackets1_14; +import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.ComponentRewriter1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.EntityPacketRewriter1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.ItemPacketRewriter1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.PlayerPacketRewriter1_14; @@ -39,6 +40,7 @@ import com.viaversion.viaversion.protocols.v1_13_2to1_14.rewriter.WorldPacketRew import com.viaversion.viaversion.protocols.v1_13_2to1_14.storage.EntityTracker1_14; import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -49,6 +51,7 @@ public class Protocol1_13_2To1_14 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_13_2To1_14() { @@ -65,6 +68,8 @@ public class Protocol1_13_2To1_14 extends AbstractProtocol(this).registerSound(ClientboundPackets1_13.SOUND); new StatisticsRewriter<>(this).register(ClientboundPackets1_13.AWARD_STATS); + particleRewriter.registerLevelParticles1_13(ClientboundPackets1_13.LEVEL_PARTICLES, Types.FLOAT); + ComponentRewriter componentRewriter = new ComponentRewriter1_14<>(this); componentRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT); @@ -139,6 +144,11 @@ public class Protocol1_13_2To1_14 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java index 2cd1c6166..4e544a910 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/ItemPacketRewriter1_14.java @@ -206,8 +206,6 @@ public class ItemPacketRewriter1_14 extends ItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_13To1_13_1() { @@ -128,6 +130,8 @@ public class Protocol1_13To1_13_1 extends AbstractProtocol(this).register(ClientboundPackets1_13.AWARD_STATS); } @@ -152,6 +156,11 @@ public class Protocol1_13To1_13_1 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java index 748a43d44..095a21f60 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13to1_13_1/rewriter/ItemPacketRewriter1_13_1.java @@ -97,7 +97,5 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_14_4To1_15() { @@ -95,8 +97,13 @@ public class Protocol1_14_4To1_15 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java index e520ed575..e15eb368b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java @@ -47,6 +47,7 @@ import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.EntityPacketRe import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.ItemPacketRewriter1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.rewriter.WorldPacketRewriter1_16; import com.viaversion.viaversion.protocols.v1_15_2to1_16.storage.InventoryTracker1_16; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -63,6 +64,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final ComponentRewriter1_16 componentRewriter = new ComponentRewriter1_16(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -77,6 +79,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol(this).register(ClientboundPackets1_15.AWARD_STATS); @@ -255,6 +258,11 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + public ComponentRewriter1_16 getComponentRewriter() { return componentRewriter; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java index 885761f4f..ff0c96fed 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/rewriter/ItemPacketRewriter1_16.java @@ -136,8 +136,6 @@ public class ItemPacketRewriter1_16 extends ItemRewriter handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); - - registerLevelParticles(ClientboundPackets1_15.LEVEL_PARTICLES, Types.DOUBLE); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java index 0e62e1cc6..18e71e9fa 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/Protocol1_16_1To1_16_2.java @@ -31,6 +31,7 @@ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPac import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.rewriter.EntityPacketRewriter1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.rewriter.ItemPacketRewriter1_16_2; import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.rewriter.WorldPacketRewriter1_16_2; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -40,6 +41,7 @@ public class Protocol1_16_1To1_16_2 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_16_1To1_16_2() { @@ -53,6 +55,7 @@ public class Protocol1_16_1To1_16_2 extends AbstractProtocol(this).register(ClientboundPackets1_16.AWARD_STATS); @@ -111,8 +114,13 @@ public class Protocol1_16_1To1_16_2 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java index 88c872d0d..8c2fe8d31 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_1to1_16_2/rewriter/ItemPacketRewriter1_16_2.java @@ -57,7 +57,5 @@ public class ItemPacketRewriter1_16_2 extends ItemRewriter handleItemToServer(wrapper.user(), wrapper.passthrough(Types.ITEM1_13_2))); - - registerLevelParticles(ClientboundPackets1_16.LEVEL_PARTICLES, Types.DOUBLE); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java index 41004b37d..39279ba20 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/Protocol1_16_4To1_17.java @@ -37,6 +37,7 @@ import com.viaversion.viaversion.protocols.v1_16_4to1_17.packet.ServerboundPacke import com.viaversion.viaversion.protocols.v1_16_4to1_17.rewriter.EntityPacketRewriter1_17; import com.viaversion.viaversion.protocols.v1_16_4to1_17.rewriter.ItemPacketRewriter1_17; import com.viaversion.viaversion.protocols.v1_16_4to1_17.rewriter.WorldPacketRewriter1_17; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -46,6 +47,7 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_16_4To1_17() { @@ -86,6 +88,8 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol { wrapper.passthrough(Types.STRING); wrapper.passthrough(Types.STRING); @@ -208,6 +212,11 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/ItemPacketRewriter1_17.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/ItemPacketRewriter1_17.java index 24e46a119..f76592244 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/ItemPacketRewriter1_17.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_16_4to1_17/rewriter/ItemPacketRewriter1_17.java @@ -46,7 +46,6 @@ public final class ItemPacketRewriter1_17 extends ItemRewriter(protocol).register(ClientboundPackets1_16_2.UPDATE_RECIPES); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java index 9fa698ee4..b268e462e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/Protocol1_17_1To1_18.java @@ -35,6 +35,7 @@ import com.viaversion.viaversion.protocols.v1_17_1to1_18.rewriter.ItemPacketRewr import com.viaversion.viaversion.protocols.v1_17_1to1_18.rewriter.WorldPacketRewriter1_18; import com.viaversion.viaversion.protocols.v1_17_1to1_18.storage.ChunkLightStorage; import com.viaversion.viaversion.protocols.v1_17to1_17_1.packet.ClientboundPackets1_17_1; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -46,6 +47,7 @@ public final class Protocol1_17_1To1_18 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_17_1To1_18() { @@ -123,8 +125,13 @@ public final class Protocol1_17_1To1_18 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/EntityPacketRewriter1_18.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/EntityPacketRewriter1_18.java index 7d7e90a10..ac4364521 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/EntityPacketRewriter1_18.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_17_1to1_18/rewriter/EntityPacketRewriter1_18.java @@ -90,7 +90,7 @@ public final class EntityPacketRewriter1_18 extends EntityRewriter particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_18_2To1_19() { @@ -347,6 +349,11 @@ public final class Protocol1_18_2To1_19 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java index dc336c801..0d5dd4d39 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_18_2to1_19/rewriter/EntityPacketRewriter1_19.java @@ -331,7 +331,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_1To1_19_3() { @@ -78,6 +80,8 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java index 8e8ae1a07..6d70853e3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_1to1_19_3/rewriter/ItemPacketRewriter1_19_3.java @@ -56,7 +56,6 @@ public final class ItemPacketRewriter1_19_3 extends ItemRewriter recipeRewriter = new RecipeRewriter<>(protocol); protocol.registerClientbound(ClientboundPackets1_19_1.UPDATE_RECIPES, wrapper -> { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java index 9db2a7aba..ba05f3960 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/Protocol1_19_3To1_19_4.java @@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; import com.viaversion.viaversion.api.type.types.version.Types1_19_4; @@ -36,6 +35,7 @@ import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.EntityPacket import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.ItemPacketRewriter1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.storage.PlayerVehicleTracker; import com.viaversion.viaversion.rewriter.CommandRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -48,6 +48,7 @@ public final class Protocol1_19_3To1_19_4 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_3To1_19_4() { @@ -59,6 +60,8 @@ public final class Protocol1_19_3To1_19_4 extends AbstractProtocol(this).register(ClientboundPackets1_19_3.AWARD_STATS); final SoundRewriter soundRewriter = new SoundRewriter<>(this); @@ -133,6 +136,11 @@ public final class Protocol1_19_3To1_19_4 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java index 56286be44..f1f50a425 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_3to1_19_4/rewriter/ItemPacketRewriter1_19_4.java @@ -19,7 +19,6 @@ package com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter; 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_18; import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3; @@ -91,7 +90,6 @@ public final class ItemPacketRewriter1_19_4 extends ItemRewriter particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_19_4To1_20() { @@ -51,6 +53,7 @@ public final class Protocol1_19_4To1_20 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound1_19_3(ClientboundPackets1_19_4.SOUND); @@ -108,8 +111,13 @@ public final class Protocol1_19_4To1_20 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/ItemPacketRewriter1_20.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/ItemPacketRewriter1_20.java index d3e0b1861..8f510bf03 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/ItemPacketRewriter1_20.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_19_4to1_20/rewriter/ItemPacketRewriter1_20.java @@ -59,7 +59,6 @@ public final class ItemPacketRewriter1_20 extends ItemRewriter { wrapper.passthrough(Types.BOOLEAN); // Reset/clear @@ -193,4 +192,4 @@ public final class ItemPacketRewriter1_20 extends ItemRewriter particleRewriter = new ParticleRewriter<>(this); private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); @@ -381,6 +383,11 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public EntityPacketRewriter1_20_3 getEntityRewriter() { return entityRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java index 65a2f9dad..eaaa07348 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java @@ -91,7 +91,7 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter tagRewriter = new TagRewriter<>(this); private final ComponentRewriter1_20_5 componentRewriter = new ComponentRewriter1_20_5<>(this, Types1_20_5.STRUCTURED_DATA); @@ -318,6 +320,11 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java index 6828a016f..64d4965ae 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java @@ -306,8 +306,8 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter extends ComponentRewriter { +public final class ComponentRewriter1_20_5 extends ComponentRewriter { private final Map, ConverterPair> converters = new Reference2ObjectOpenHashMap<>(); private final StructuredDataType structuredDataType; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java index 5c552b269..8a03b6a08 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java @@ -547,14 +547,6 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter. + */ +package com.viaversion.viaversion.protocols.v1_20_3to1_20_5.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.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3; +import com.viaversion.viaversion.rewriter.ParticleRewriter; + +public final class ParticleRewriter1_20_5 extends ParticleRewriter { + + public ParticleRewriter1_20_5(final Protocol protocol) { + super(protocol); + } + + @Override + public void rewriteParticle(final UserConnection connection, final Particle particle) { + super.rewriteParticle(connection, particle); + + if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) { + particle.add(Types.INT, 0); // Default color, changed in the area effect handler + } + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java index c731bb4ab..b49ba0422 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/Protocol1_20_5To1_21.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvide import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.misc.ParticleType; +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; @@ -47,6 +48,7 @@ import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.EntityPacketRe import com.viaversion.viaversion.protocols.v1_20_5to1_21.storage.EfficiencyAttributeStorage; import com.viaversion.viaversion.protocols.v1_20_5to1_21.storage.OnGroundTracker; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; @@ -62,6 +64,7 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this, Types1_20_5.PARTICLE, Types1_21.PARTICLE); private final TagRewriter tagRewriter = new TagRewriter<>(this); private final ComponentRewriter componentRewriter = new ComponentRewriter1_21(this); @@ -92,6 +95,9 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol { componentRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.TAG)); // Message @@ -246,6 +252,11 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java index ffec67e75..d95204ab3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java @@ -52,8 +52,7 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter { wrapper.passthrough(Types.UNSIGNED_BYTE); // Container id diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java index db94d6b12..81996eb9c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java @@ -53,6 +53,7 @@ import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.ConfigurationSt import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.ConfigurationState.BridgePhase; import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.LastResourcePack; import com.viaversion.viaversion.protocols.v1_20to1_20_2.storage.LastTags; +import com.viaversion.viaversion.rewriter.ParticleRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.util.Key; @@ -64,6 +65,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol particleRewriter = new ParticleRewriter<>(this); private final TagRewriter tagRewriter = new TagRewriter<>(this); public Protocol1_20To1_20_2() { @@ -79,6 +81,8 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol getParticleRewriter() { + return particleRewriter; + } + @Override public TagRewriter getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java index 5e843c7c6..2bbf619bd 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/rewriter/BlockItemPacketRewriter1_20_2.java @@ -24,13 +24,13 @@ import com.viaversion.nbt.tag.StringTag; import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.entity.EntityTracker; +import com.viaversion.viaversion.api.minecraft.ChunkPosition; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.minecraft.item.Item; -import com.viaversion.viaversion.api.minecraft.ChunkPosition; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Types; @@ -39,8 +39,8 @@ import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.packet.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.RecipeRewriter1_19_4; import com.viaversion.viaversion.protocols.v1_20to1_20_2.Protocol1_20To1_20_2; -import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.v1_20to1_20_2.data.PotionEffects1_20_2; +import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.ItemRewriter; import com.viaversion.viaversion.util.MathUtil; @@ -65,7 +65,6 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter { // Effects start at 1 before 1.20.2 diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java index 28307acd2..768e29cb7 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java @@ -46,6 +46,7 @@ import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPacke import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.ComponentRewriter1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.EntityPacketRewriter1_21_2; +import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.ParticleRewriter1_21_2; import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.BundleStateTracker; import com.viaversion.viaversion.protocols.v1_21to1_21_2.storage.PlayerPositionStorage; import com.viaversion.viaversion.rewriter.AttributeRewriter; @@ -61,6 +62,7 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol tagRewriter = new TagRewriter<>(this); private final ComponentRewriter1_21_2 componentRewriter = new ComponentRewriter1_21_2(this); @@ -87,6 +89,8 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol soundRewriter = new SoundRewriter<>(this); soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND); soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND_ENTITY); @@ -244,6 +248,11 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol getTagRewriter() { return tagRewriter; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java index 70f974fc1..509eb52e8 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/BlockItemPacketRewriter1_21_2.java @@ -70,8 +70,7 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< public BlockItemPacketRewriter1_21_2(final Protocol1_21To1_21_2 protocol) { super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_21_2.ITEM, Types1_21_2.ITEM_ARRAY, - Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_21_2.ITEM_COST, Types1_21_2.OPTIONAL_ITEM_COST, - Types1_21.PARTICLE, Types1_21_2.PARTICLE + Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_21_2.ITEM_COST, Types1_21_2.OPTIONAL_ITEM_COST ); } @@ -89,7 +88,6 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT); registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS); registerSetCreativeModeSlot(ServerboundPackets1_21_2.SET_CREATIVE_MODE_SLOT); - registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES); protocol.registerClientbound(ClientboundPackets1_21.COOLDOWN, wrapper -> { final MappingData mappingData = protocol.getMappingData(); @@ -217,10 +215,10 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< final Particle smallExplosionParticle = wrapper.read(Types1_21.PARTICLE); final Particle largeExplosionParticle = wrapper.read(Types1_21.PARTICLE); if (power >= 2.0F && blockInteractionMode != 0) { - rewriteParticle(wrapper.user(), largeExplosionParticle); + protocol.getParticleRewriter().rewriteParticle(wrapper.user(), largeExplosionParticle); wrapper.write(Types1_21_2.PARTICLE, largeExplosionParticle); } else { - rewriteParticle(wrapper.user(), smallExplosionParticle); + protocol.getParticleRewriter().rewriteParticle(wrapper.user(), smallExplosionParticle); wrapper.write(Types1_21_2.PARTICLE, smallExplosionParticle); } @@ -357,27 +355,6 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter< wrapper.write(Types.STRING, recipe.identifier()); } - @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")) { - floatsToARGB(particle, 0); - floatsToARGB(particle, 1); - } else if (identifier.equals("minecraft:dust")) { - floatsToARGB(particle, 0); - } - } - - private void floatsToARGB(final Particle particle, final int fromIndex) { - final Particle.ParticleData r = particle.removeArgument(fromIndex); - final Particle.ParticleData g = particle.removeArgument(fromIndex); - final Particle.ParticleData b = particle.removeArgument(fromIndex); - final int rgb = 255 << 24 | (int) (r.getValue() * 255) << 16 | (int) (g.getValue() * 255) << 8 | (int) (b.getValue() * 255); - particle.add(fromIndex, Types.INT, rgb); - } - @Override public Item handleItemToClient(final UserConnection connection, final Item item) { super.handleItemToClient(connection, item); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/ParticleRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/ParticleRewriter1_21_2.java new file mode 100644 index 000000000..be256e3cf --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/ParticleRewriter1_21_2.java @@ -0,0 +1,55 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * 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.viaversion.protocols.v1_21to1_21_2.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_20_5to1_21.packet.ClientboundPacket1_21; +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.PARTICLE, Types1_21_2.PARTICLE); + } + + private void floatsToARGB(final Particle particle, final int fromIndex) { + final Particle.ParticleData r = particle.removeArgument(fromIndex); + final Particle.ParticleData g = particle.removeArgument(fromIndex); + final Particle.ParticleData b = particle.removeArgument(fromIndex); + final int rgb = 255 << 24 | (int) (r.getValue() * 255) << 16 | (int) (g.getValue() * 255) << 8 | (int) (b.getValue() * 255); + particle.add(fromIndex, Types.INT, rgb); + } + + @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")) { + floatsToARGB(particle, 0); + floatsToARGB(particle, 1); + } else if (identifier.equals("minecraft:dust")) { + floatsToARGB(particle, 0); + } + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java index f8cbb0805..cf37dee5b 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/EntityRewriter.java @@ -27,7 +27,6 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.FullMappings; import com.viaversion.viaversion.api.data.Int2IntMapMappings; import com.viaversion.viaversion.api.data.Mappings; -import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.data.entity.DimensionData; import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.data.entity.TrackedEntity; @@ -238,11 +237,11 @@ public abstract class EntityRewriter data = particle.getArgument(0); - data.setValue(protocol.getMappingData().getNewBlockStateId(data.getValue())); - } - - particle.setId(protocol.getMappingData().getNewParticleId(id)); - } - private void logException(Exception e, @Nullable EntityType type, List entityDataList, EntityData entityData) { if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { protocol.getLogger().severe("An error occurred in entity data handler " + this.getClass().getSimpleName() diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java index 256e1c679..99d26f35f 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -22,14 +22,11 @@ import com.viaversion.nbt.tag.Tag; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.FullMappings; import com.viaversion.viaversion.api.data.Mappings; -import com.viaversion.viaversion.api.data.ParticleMappings; -import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; -import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.rewriter.ComponentRewriter; import com.viaversion.viaversion.api.rewriter.RewriterBase; @@ -47,14 +44,11 @@ public class ItemRewriter mappedItemCostType; private final Type optionalItemCostType; private final Type mappedOptionalItemCostType; - private final Type particleType; - private final Type mappedParticleType; public ItemRewriter( T protocol, Type 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); this.itemType = itemType; @@ -65,12 +59,10 @@ public class ItemRewriter itemType, Type itemArrayType, Type mappedItemType, Type mappedItemArrayType) { - this(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, null, null, null, null, null, null); + this(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, null, null, null, null); } public ItemRewriter(T protocol, Type itemType, Type itemArrayType) { @@ -459,137 +451,6 @@ public class ItemRewriter coordType) { - protocol.registerClientbound(packetType, new PacketHandlers() { - @Override - public void register() { - map(Types.INT); // 0 - Particle ID - map(Types.BOOLEAN); // 1 - Long Distance - map(coordType); // 2 - X - map(coordType); // 3 - Y - map(coordType); // 4 - Z - map(Types.FLOAT); // 5 - Offset X - map(Types.FLOAT); // 6 - Offset Y - map(Types.FLOAT); // 7 - Offset Z - map(Types.FLOAT); // 8 - Particle Data - map(Types.INT); // 9 - Particle Count - handler(levelParticlesHandler()); - } - }); - } - - public void registerLevelParticles1_19(C packetType) { - protocol.registerClientbound(packetType, new PacketHandlers() { - @Override - public void register() { - map(Types.VAR_INT); // 0 - Particle ID - map(Types.BOOLEAN); // 1 - Long Distance - map(Types.DOUBLE); // 2 - X - map(Types.DOUBLE); // 3 - Y - map(Types.DOUBLE); // 4 - Z - map(Types.FLOAT); // 5 - Offset X - map(Types.FLOAT); // 6 - Offset Y - map(Types.FLOAT); // 7 - Offset Z - map(Types.FLOAT); // 8 - Particle Data - map(Types.INT); // 9 - Particle Count - handler(levelParticlesHandler(Types.VAR_INT)); - } - }); - } - - public void registerLevelParticles1_20_5(C packetType) { - protocol.registerClientbound(packetType, new PacketHandlers() { - @Override - public void register() { - map(Types.BOOLEAN); // Long Distance - map(Types.DOUBLE); // X - map(Types.DOUBLE); // Y - map(Types.DOUBLE); // Z - map(Types.FLOAT); // Offset X - map(Types.FLOAT); // Offset Y - map(Types.FLOAT); // Offset Z - map(Types.FLOAT); // Particle Data - map(Types.INT); // Particle Count - handler(wrapper -> { - final Particle particle = wrapper.passthroughAndMap(particleType, mappedParticleType); - rewriteParticle(wrapper.user(), particle); - }); - } - }); - } - - public void registerExplosion(C packetType) { - final SoundRewriter soundRewriter = new SoundRewriter<>(protocol); - protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Types.DOUBLE); // X - wrapper.passthrough(Types.DOUBLE); // Y - wrapper.passthrough(Types.DOUBLE); // Z - wrapper.passthrough(Types.FLOAT); // Power - final int blocks = wrapper.passthrough(Types.VAR_INT); - for (int i = 0; i < blocks; i++) { - wrapper.passthrough(Types.BYTE); // Relative X - wrapper.passthrough(Types.BYTE); // Relative Y - wrapper.passthrough(Types.BYTE); // Relative Z - } - wrapper.passthrough(Types.FLOAT); // Knockback X - wrapper.passthrough(Types.FLOAT); // Knockback Y - wrapper.passthrough(Types.FLOAT); // Knockback Z - wrapper.passthrough(Types.VAR_INT); // Block interaction type - - final Particle smallExplosionParticle = wrapper.passthroughAndMap(particleType, mappedParticleType); - final Particle largeExplosionParticle = wrapper.passthroughAndMap(particleType, mappedParticleType); - rewriteParticle(wrapper.user(), smallExplosionParticle); - rewriteParticle(wrapper.user(), largeExplosionParticle); - - soundRewriter.soundHolderHandler().handle(wrapper); - }); - } - - public void registerExplosion1_21_2(C packetType) { - final SoundRewriter soundRewriter = new SoundRewriter<>(protocol); - protocol.registerClientbound(packetType, wrapper -> { - wrapper.passthrough(Types.DOUBLE); // X - wrapper.passthrough(Types.DOUBLE); // Y - wrapper.passthrough(Types.DOUBLE); // Z - wrapper.passthrough(Types.DOUBLE); // Knockback X - wrapper.passthrough(Types.DOUBLE); // Knockback Y - wrapper.passthrough(Types.DOUBLE); // Knockback Z - - final Particle explosionParticle = wrapper.read(particleType); - wrapper.write(mappedParticleType, explosionParticle); - rewriteParticle(wrapper.user(), explosionParticle); - - soundRewriter.soundHolderHandler().handle(wrapper); - }); - } - - public PacketHandler levelParticlesHandler() { - return levelParticlesHandler(Types.INT); - } - - public PacketHandler levelParticlesHandler(Type idType) { - return wrapper -> { - int id = wrapper.get(idType, 0); - if (id == -1) { - return; - } - - ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); - if (mappings.isBlockParticle(id)) { - int data = wrapper.read(Types.VAR_INT); - wrapper.write(Types.VAR_INT, protocol.getMappingData().getNewBlockStateId(data)); - } else if (mappings.isItemParticle(id)) { - passthroughClientboundItem(wrapper); - } - - int mappedId = protocol.getMappingData().getNewParticleId(id); - if (mappedId != id) { - wrapper.set(idType, 0, mappedId); - } - }; - } - protected void passthroughClientboundItem(final PacketWrapper wrapper) { final Item item = handleItemToClient(wrapper.user(), wrapper.read(itemType)); wrapper.write(mappedItemType, item); @@ -600,27 +461,6 @@ public class ItemRewriter data = particle.getArgument(0); - data.setValue(protocol.getMappingData().getNewBlockStateId(data.getValue())); - } else if (mappings.isItemParticle(id)) { - Particle.ParticleData data = particle.getArgument(0); - Item item = handleItemToClient(connection, data.getValue()); - if (mappedItemType() != null && itemType() != mappedItemType()) { - // Replace the type - particle.set(0, mappedItemType(), item); - } else { - data.setValue(item); - } - } - - particle.setId(protocol.getMappingData().getNewParticleId(id)); - } - protected @Nullable String mappedIdentifier(final FullMappings mappings, final String identifier) { // Check if the original exists before mapping if (mappings.id(identifier) == -1) { diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/ParticleRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/ParticleRewriter.java new file mode 100644 index 000000000..ac1b1859a --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ParticleRewriter.java @@ -0,0 +1,199 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * 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.viaversion.rewriter; + +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.data.ParticleMappings; +import com.viaversion.viaversion.api.minecraft.Particle; +import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.protocol.Protocol; +import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; +import com.viaversion.viaversion.api.rewriter.ItemRewriter; +import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.Types; + +public class ParticleRewriter implements com.viaversion.viaversion.api.rewriter.ParticleRewriter { + + protected final Protocol protocol; + private final Type particleType; + private final Type mappedParticleType; + + public ParticleRewriter(final Protocol protocol) { + this(protocol, null); + } + + public ParticleRewriter(final Protocol protocol, final Type particleType) { + this.protocol = protocol; + this.particleType = particleType; + this.mappedParticleType = particleType; + } + + public ParticleRewriter(final Protocol protocol, final Type particleType, final Type mappedParticleType) { + this.protocol = protocol; + this.particleType = particleType; + this.mappedParticleType = mappedParticleType; + } + + public void registerLevelParticles1_13(C packetType, Type coordType) { + protocol.registerClientbound(packetType, new PacketHandlers() { + @Override + public void register() { + map(Types.INT); // 0 - Particle ID + map(Types.BOOLEAN); // 1 - Long Distance + map(coordType); // 2 - X + map(coordType); // 3 - Y + map(coordType); // 4 - Z + map(Types.FLOAT); // 5 - Offset X + map(Types.FLOAT); // 6 - Offset Y + map(Types.FLOAT); // 7 - Offset Z + map(Types.FLOAT); // 8 - Particle Data + map(Types.INT); // 9 - Particle Count + handler(levelParticlesHandler1_13(Types.INT)); + } + }); + } + + public void registerLevelParticles1_19(C packetType) { + protocol.registerClientbound(packetType, new PacketHandlers() { + @Override + public void register() { + map(Types.VAR_INT); // 0 - Particle ID + map(Types.BOOLEAN); // 1 - Long Distance + map(Types.DOUBLE); // 2 - X + map(Types.DOUBLE); // 3 - Y + map(Types.DOUBLE); // 4 - Z + map(Types.FLOAT); // 5 - Offset X + map(Types.FLOAT); // 6 - Offset Y + map(Types.FLOAT); // 7 - Offset Z + map(Types.FLOAT); // 8 - Particle Data + map(Types.INT); // 9 - Particle Count + handler(levelParticlesHandler1_13(Types.VAR_INT)); + } + }); + } + + public PacketHandler levelParticlesHandler1_13(Type idType) { + return wrapper -> { + int id = wrapper.get(idType, 0); + if (id == -1) { + return; + } + + ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); + if (mappings.isBlockParticle(id)) { + int data = wrapper.read(Types.VAR_INT); + wrapper.write(Types.VAR_INT, protocol.getMappingData().getNewBlockStateId(data)); + } else if (mappings.isItemParticle(id)) { + ItemRewriter itemRewriter = protocol.getItemRewriter(); + final Item item = wrapper.read(itemRewriter.itemType()); + wrapper.write(itemRewriter.mappedItemType(), itemRewriter.handleItemToClient(wrapper.user(), item)); + } + + int mappedId = protocol.getMappingData().getNewParticleId(id); + if (mappedId != id) { + wrapper.set(idType, 0, mappedId); + } + }; + } + + public void registerLevelParticles1_20_5(final C packetType) { + protocol.registerClientbound(packetType, wrapper -> { + wrapper.passthrough(Types.BOOLEAN); // Long Distance + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.FLOAT); // Offset X + wrapper.passthrough(Types.FLOAT); // Offset Y + wrapper.passthrough(Types.FLOAT); // Offset Z + wrapper.passthrough(Types.FLOAT); // Particle Data + wrapper.passthrough(Types.INT); // Particle Count + + final Particle particle = wrapper.passthroughAndMap(particleType, mappedParticleType); + rewriteParticle(wrapper.user(), particle); + }); + } + + public void registerExplode1_20_5(final C packetType) { + final SoundRewriter soundRewriter = new SoundRewriter<>(protocol); + protocol.registerClientbound(packetType, wrapper -> { + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.FLOAT); // Power + final int blocks = wrapper.passthrough(Types.VAR_INT); + for (int i = 0; i < blocks; i++) { + wrapper.passthrough(Types.BYTE); // Relative X + wrapper.passthrough(Types.BYTE); // Relative Y + wrapper.passthrough(Types.BYTE); // Relative Z + } + wrapper.passthrough(Types.FLOAT); // Knockback X + wrapper.passthrough(Types.FLOAT); // Knockback Y + wrapper.passthrough(Types.FLOAT); // Knockback Z + wrapper.passthrough(Types.VAR_INT); // Block interaction type + + final Particle smallExplosionParticle = wrapper.passthroughAndMap(particleType, mappedParticleType); + final Particle largeExplosionParticle = wrapper.passthroughAndMap(particleType, mappedParticleType); + rewriteParticle(wrapper.user(), smallExplosionParticle); + rewriteParticle(wrapper.user(), largeExplosionParticle); + + soundRewriter.soundHolderHandler().handle(wrapper); + }); + } + + public void registerExplode1_21_2(final C packetType) { + final SoundRewriter soundRewriter = new SoundRewriter<>(protocol); + protocol.registerClientbound(packetType, wrapper -> { + wrapper.passthrough(Types.DOUBLE); // X + wrapper.passthrough(Types.DOUBLE); // Y + wrapper.passthrough(Types.DOUBLE); // Z + wrapper.passthrough(Types.DOUBLE); // Knockback X + wrapper.passthrough(Types.DOUBLE); // Knockback Y + wrapper.passthrough(Types.DOUBLE); // Knockback Z + + final Particle explosionParticle = wrapper.read(particleType); + wrapper.write(mappedParticleType, explosionParticle); + rewriteParticle(wrapper.user(), explosionParticle); + + soundRewriter.soundHolderHandler().handle(wrapper); + }); + } + + @Override + public void rewriteParticle(final UserConnection connection, final Particle particle) { + final ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); + final ItemRewriter itemRewriter = protocol.getItemRewriter(); + final int id = particle.id(); + if (mappings.isBlockParticle(id)) { + final Particle.ParticleData data = particle.getArgument(0); + data.setValue(protocol.getMappingData().getNewBlockStateId(data.getValue())); + } else if (mappings.isItemParticle(id) && itemRewriter != null) { + final Particle.ParticleData data = particle.getArgument(0); + final Item item = itemRewriter.handleItemToClient(connection, data.getValue()); + if (itemRewriter.mappedItemType() != null && itemRewriter.itemType() != itemRewriter.mappedItemType()) { + // Replace the type + particle.set(0, itemRewriter.mappedItemType(), item); + } else { + data.setValue(item); + } + } + + particle.setId(protocol.getMappingData().getNewParticleId(id)); + } +} diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/StructuredItemRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/StructuredItemRewriter.java index 4e4e9e278..27da771d2 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/StructuredItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/StructuredItemRewriter.java @@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.FullMappings; import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.minecraft.Holder; -import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.data.StructuredData; import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; @@ -45,10 +44,9 @@ public class StructuredItemRewriter 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 StructuredItemRewriter(T protocol, Type itemType, Type itemArrayType, Type mappedItemType, Type mappedItemArrayType) {