Class EntityCache
java.lang.Object
org.geysermc.geyser.session.cache.EntityCache
Each session has its own EntityCache in the occasion that an entity packet is sent specifically
for that player (e.g. seeing vanished players from /vanish)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBossBar(UUID uuid, BossBar bossBar) voidaddPlayerEntity(PlayerEntity entity) booleancacheEntity(Entity entity) voidforEachPlayerEntity(Consumer<PlayerEntity> player) Run a specific bit of code for each cached player entity.getBossBar(UUID uuid) it.unimi.dsi.fastutil.longs.Long2ObjectMap<Entity> Returns the raw, mutable backing entity map.getEntityByGeyserId(long geyserId) Safe to call from any thread.getEntityByJavaId(int javaId) Safe to call from any thread.getEntityByUuid(UUID uuid) Safe to call from any thread.getPlayerEntity(UUID uuid) getPlayersByName(String name) A list of all entities that must be ticked.voidlonglongreassignGeyserId(Entity entity) Moves a cached entity to a fresh Geyser id and returns the new id.voidvoidvoidvoidremoveBossBar(UUID uuid) voidremoveEntity(Entity entity) removePlayerEntity(UUID uuid) voidspawnEntity(Entity entity) void
-
Constructor Details
-
EntityCache
-
-
Method Details
-
nextEntityId
public long nextEntityId() -
getEntitiesUnsafe
Returns the raw, mutable backing entity map. This bypasses the read/write lock that guards the map, so it must only be accessed on the session's event loop thread, where it is sequential with all mutations. You should never mutate it directly, usespawnEntity(Entity)orremoveEntity(Entity)and related methods instead. Off-thread callers - mainly API users - must instead usegetEntityByGeyserId(long),getEntityByJavaId(int)orgetEntityByUuid(UUID). -
spawnEntity
-
cacheEntity
-
reassignGeyserId
Moves a cached entity to a fresh Geyser id and returns the new id. For an entity the Bedrock client removed on its own while Java still has it: the client ignores a spawn for an id it already removed, so the entity has to be spawned again under a new one. The caller stores the id and sends the spawn. -
removeEntity
-
markDirty
-
removeAllEntities
public void removeAllEntities() -
getEntityByGeyserId
Safe to call from any thread. When called off the session's event loop thread, the lookup is guarded by the read lock; on the event loop it reads directly since it is sequential with all writes there. -
getEntityByJavaId
Safe to call from any thread. When called off the session's event loop thread, the lookup is guarded by the read lock; on the event loop it reads directly since it is sequential with all writes there. -
getEntityByUuid
Safe to call from any thread. When called off the session's event loop thread, the lookup is guarded by the read lock; on the event loop it reads directly since it is sequential with all writes there. -
addPlayerEntity
-
getPlayerEntity
-
getPlayersByName
-
removePlayerEntity
-
forEachPlayerEntity
Run a specific bit of code for each cached player entity. As usual with synchronized, try to minimize the amount of work you because you block the PlayerList collection. -
removeAllPlayerEntities
public void removeAllPlayerEntities() -
addBossBar
-
getBossBar
-
removeBossBar
-
updateBossBars
public void updateBossBars() -
removeAllBossBars
public void removeAllBossBars() -
getTickableEntities
A list of all entities that must be ticked. -
getDirtyEntities
-
getNextEntityId
-