Skip to content

Commit 95a67b9

Browse files
authored
Fix potion effect display (#2194)
1 parent 4344117 commit 95a67b9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/cn/nukkit/entity/Entity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ public abstract class Entity extends Location implements Metadatable {
189189
public static final int DATA_PLAYER_LAST_DEATH_POS = 127;
190190
public static final int DATA_PLAYER_LAST_DEATH_DIMENSION = 128;
191191
public static final int DATA_PLAYER_HAS_DIED = 129;
192+
public static final int DATA_COLLISION_BOX = 130; //vector3f
193+
public static final int DATA_VISIBLE_MOB_EFFECTS = 131; //long
192194

193195
// Flags
194196
public static final int DATA_FLAG_ONFIRE = 0;
@@ -845,6 +847,8 @@ protected void recalculateEffectColor() {
845847
int[] color = new int[3];
846848
int count = 0;
847849
boolean ambient = true;
850+
long effectsData = 0;
851+
int packedEffectsCount = 0;
848852
for (Effect effect : this.effects.values()) {
849853
if (effect.isVisible()) {
850854
int[] c = effect.getColor();
@@ -855,6 +859,10 @@ protected void recalculateEffectColor() {
855859
if (!effect.isAmbient()) {
856860
ambient = false;
857861
}
862+
if (packedEffectsCount < 8) {
863+
effectsData = effectsData << 7 | ((effect.getId() & 0x3f) << 1) | (effect.isAmbient() ? 1 : 0);
864+
packedEffectsCount++;
865+
}
858866
}
859867
}
860868

@@ -869,6 +877,7 @@ protected void recalculateEffectColor() {
869877
this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, 0));
870878
this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, 0));
871879
}
880+
this.setDataProperty(new LongEntityData(Entity.DATA_VISIBLE_MOB_EFFECTS, effectsData));
872881
}
873882

874883
public static Entity createEntity(String name, Position pos, Object... args) {

0 commit comments

Comments
 (0)