Fix 1.20.5->1.20.3 darkness effect transition

This commit is contained in:
Nassim Jahnke 2024-10-23 21:26:12 +02:00
parent 4f119d26d7
commit b1f4a88050
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F

View File

@ -243,14 +243,26 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
protocol.registerClientbound(ClientboundPackets1_20_5.UPDATE_MOB_EFFECT, wrapper -> { protocol.registerClientbound(ClientboundPackets1_20_5.UPDATE_MOB_EFFECT, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Entity ID 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); final int amplifier = wrapper.read(Types.VAR_INT);
wrapper.write(Types.BYTE, (byte) MathUtil.clamp(amplifier, Byte.MIN_VALUE, Byte.MAX_VALUE)); wrapper.write(Types.BYTE, (byte) MathUtil.clamp(amplifier, Byte.MIN_VALUE, Byte.MAX_VALUE));
wrapper.passthrough(Types.VAR_INT); // Duration wrapper.passthrough(Types.VAR_INT); // Duration
wrapper.passthrough(Types.BYTE); // Flags 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 -> { protocol.registerClientbound(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES, wrapper -> {