mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-31 20:41:29 +01:00
Fixed not auto viewable entity keeping viewers after being removed
This commit is contained in:
parent
1345968aac
commit
d699343366
@ -657,11 +657,10 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
|||||||
|
|
||||||
RemoveEntityFromInstanceEvent event = new RemoveEntityFromInstanceEvent(this, entity);
|
RemoveEntityFromInstanceEvent event = new RemoveEntityFromInstanceEvent(this, entity);
|
||||||
callCancellableEvent(RemoveEntityFromInstanceEvent.class, event, () -> {
|
callCancellableEvent(RemoveEntityFromInstanceEvent.class, event, () -> {
|
||||||
if (entity.isAutoViewable()) {
|
// Remove this entity from players viewable list and send delete entities packet
|
||||||
// Remove this entity from players viewable list and send delete entities packet
|
entity.getViewers().forEach(p -> entity.removeViewer(p));
|
||||||
entity.getViewers().forEach(p -> entity.removeViewer(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Remove the entity from cache
|
||||||
final Chunk chunk = getChunkAt(entity.getPosition());
|
final Chunk chunk = getChunkAt(entity.getPosition());
|
||||||
removeEntityFromChunk(entity, chunk);
|
removeEntityFromChunk(entity, chunk);
|
||||||
});
|
});
|
||||||
@ -731,7 +730,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<Entity> getEntitiesInChunk(long index) {
|
private Set<Entity> getEntitiesInChunk(long index) {
|
||||||
Set<Entity> entities = chunkEntities.getOrDefault(index, new CopyOnWriteArraySet<>());
|
final Set<Entity> entities = chunkEntities.getOrDefault(index, new CopyOnWriteArraySet<>());
|
||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,7 +802,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
|||||||
final ExplosionSupplier explosionSupplier = getExplosionSupplier();
|
final ExplosionSupplier explosionSupplier = getExplosionSupplier();
|
||||||
if (explosionSupplier == null)
|
if (explosionSupplier == null)
|
||||||
throw new IllegalStateException("Tried to create an explosion with no explosion supplier");
|
throw new IllegalStateException("Tried to create an explosion with no explosion supplier");
|
||||||
Explosion explosion = explosionSupplier.createExplosion(centerX, centerY, centerZ, strength, additionalData);
|
final Explosion explosion = explosionSupplier.createExplosion(centerX, centerY, centerZ, strength, additionalData);
|
||||||
explosion.apply(this);
|
explosion.apply(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user