From 1be0605f51b54cc4b1abd3345b3bc84f3c9103b8 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 19 Apr 2024 17:02:08 +0200 Subject: [PATCH] Eat remaining particle data in spawn particle --- .../viaversion/api/data/ParticleMappings.java | 1 + .../BlockItemPacketRewriter1_20_5.java | 37 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java b/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java index 90a8a2631..b15881411 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java @@ -35,6 +35,7 @@ public class ParticleMappings extends FullMappingsBase { addBlockParticle("block"); addBlockParticle("falling_dust"); addBlockParticle("block_marker"); + addBlockParticle("dust_pillar"); addItemParticle("item"); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 4fac307a2..2d235a3ee 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -210,28 +210,45 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter fromColor, toColor, scale - particle.add(Type.FLOAT, particle. removeArgument(3).getValue()); - } - - if (mappings.isBlockParticle(particleId)) { + particle.add(Type.FLOAT, particle.removeArgument(3).getValue()); + } else if (mappings.isBlockParticle(particleId)) { final int blockStateId = wrapper.read(Type.VAR_INT); particle.add(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(blockStateId)); } else if (mappings.isItemParticle(particleId)) { final Item item = handleNonNullItemToClient(wrapper.read(Type.ITEM1_20_2)); particle.add(Types1_20_5.ITEM, item); + } else if (particleId == mappings.id("dust")) { + // R, g, b, scale + for (int i = 0; i < 4; i++) { + particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); + } + } else if (particleId == mappings.id("vibration")) { + final int sourceTypeId = wrapper.read(Type.VAR_INT); + particle.add(Type.VAR_INT, sourceTypeId); + if (sourceTypeId == 0) { // Block + particle.add(Type.POSITION1_14, wrapper.read(Type.POSITION1_14)); // Target block pos + } else if (sourceTypeId == 1) { // Entity + particle.add(Type.VAR_INT, wrapper.read(Type.VAR_INT)); // Target entity + particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); // Y offset + } else { + Via.getPlatform().getLogger().warning("Unknown vibration path position source type: " + sourceTypeId); + } + particle.add(Type.VAR_INT, wrapper.read(Type.VAR_INT)); // Arrival in ticks + } else if (particleId == mappings.id("sculk_charge")) { + particle.add(Type.FLOAT, wrapper.read(Type.FLOAT)); // Roll + } else if (particleId == mappings.id("shriek")) { + particle.add(Type.VAR_INT, wrapper.read(Type.VAR_INT)); // Delay } - // TODO: We should read the particle data of every particle. - // Otherwise reading the particle type in future versions will be broken. wrapper.write(Types1_20_5.PARTICLE, particle); });