From da5837d7944ab358d397f785dba4538151c0239a Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 18 Jun 2024 10:00:20 +0200 Subject: [PATCH] Move particles type handling into generic handler This allows for handling of data for untracked entities --- .../rewriter/EntityPacketRewriter1_20_5.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java index b2ac9311..8c8bbb7e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/EntityPacketRewriter1_20_5.java @@ -380,23 +380,32 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { + filter().handler((event, data) -> { + final int typeId = data.dataType().typeId(); if (typeId == Types1_20_5.ENTITY_DATA_TYPES.particlesType.typeId()) { - // Handled with living entity - return Types1_20_5.ENTITY_DATA_TYPES.particlesType; + final Particle[] particles = data.value(); + int color = 0; + for (final Particle particle : particles) { + if (particle.id() == protocol.getMappingData().getParticleMappings().id("entity_effect")) { + // Remove color argument, use one of them for the ambient particle color + color = particle.removeArgument(0).getValue(); + } + } + data.setTypeAndValue(Types1_20_3.ENTITY_DATA_TYPES.varIntType, removeAlpha(color)); + return; } int id = typeId; - if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType.typeId()) { + if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.armadilloState.typeId()) { id--; } - if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.armadilloState.typeId()) { + if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType.typeId()) { id--; } if (typeId >= Types1_20_5.ENTITY_DATA_TYPES.particlesType.typeId()) { id--; } - return Types1_20_3.ENTITY_DATA_TYPES.byId(id); + data.setDataType(Types1_20_3.ENTITY_DATA_TYPES.byId(id)); }); registerMetaTypeHandler1_20_3(