From 95a67b90fcd6cbc1b9b32609d2a9c66a77fe9944 Mon Sep 17 00:00:00 2001 From: LT_Name <45508179+lt-name@users.noreply.github.com> Date: Mon, 26 Aug 2024 23:52:03 +0800 Subject: [PATCH] Fix potion effect display (#2194) --- src/main/java/cn/nukkit/entity/Entity.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/cn/nukkit/entity/Entity.java b/src/main/java/cn/nukkit/entity/Entity.java index 475376b72..52ebe204c 100644 --- a/src/main/java/cn/nukkit/entity/Entity.java +++ b/src/main/java/cn/nukkit/entity/Entity.java @@ -189,6 +189,8 @@ public abstract class Entity extends Location implements Metadatable { public static final int DATA_PLAYER_LAST_DEATH_POS = 127; public static final int DATA_PLAYER_LAST_DEATH_DIMENSION = 128; public static final int DATA_PLAYER_HAS_DIED = 129; + public static final int DATA_COLLISION_BOX = 130; //vector3f + public static final int DATA_VISIBLE_MOB_EFFECTS = 131; //long // Flags public static final int DATA_FLAG_ONFIRE = 0; @@ -845,6 +847,8 @@ protected void recalculateEffectColor() { int[] color = new int[3]; int count = 0; boolean ambient = true; + long effectsData = 0; + int packedEffectsCount = 0; for (Effect effect : this.effects.values()) { if (effect.isVisible()) { int[] c = effect.getColor(); @@ -855,6 +859,10 @@ protected void recalculateEffectColor() { if (!effect.isAmbient()) { ambient = false; } + if (packedEffectsCount < 8) { + effectsData = effectsData << 7 | ((effect.getId() & 0x3f) << 1) | (effect.isAmbient() ? 1 : 0); + packedEffectsCount++; + } } } @@ -869,6 +877,7 @@ protected void recalculateEffectColor() { this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, 0)); this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, 0)); } + this.setDataProperty(new LongEntityData(Entity.DATA_VISIBLE_MOB_EFFECTS, effectsData)); } public static Entity createEntity(String name, Position pos, Object... args) {