From b1f4a88050ba7c3dae327567181aa7441152a96d Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 23 Oct 2024 21:26:12 +0200 Subject: [PATCH] Fix 1.20.5->1.20.3 darkness effect transition --- .../rewriter/EntityPacketRewriter1_20_5.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 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 ac9c8b7e..9775c982 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 @@ -243,14 +243,26 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter { wrapper.passthrough(Types.VAR_INT); // Entity ID - wrapper.passthrough(Types.VAR_INT); // Effect ID + final int effectId = wrapper.passthrough(Types.VAR_INT); final int amplifier = wrapper.read(Types.VAR_INT); wrapper.write(Types.BYTE, (byte) MathUtil.clamp(amplifier, Byte.MIN_VALUE, Byte.MAX_VALUE)); wrapper.passthrough(Types.VAR_INT); // Duration wrapper.passthrough(Types.BYTE); // Flags - wrapper.write(Types.OPTIONAL_COMPOUND_TAG, null); // Add empty factor data + + if (effectId == 32) { // Darkness, keep a stable effect + final CompoundTag factorData = new CompoundTag(); + factorData.putInt("padding_duration", 22); + factorData.putBoolean("had_effect_last_tick", true); + factorData.putFloat("factor_previous_frame", 0); + factorData.putFloat("factor_start", 1); + factorData.putFloat("factor_target", 1); + factorData.putFloat("factor_current", 1); + wrapper.write(Types.OPTIONAL_COMPOUND_TAG, factorData); + } else { + wrapper.write(Types.OPTIONAL_COMPOUND_TAG, null); + } }); protocol.registerClientbound(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES, wrapper -> {