forked from GeyserMC/Geyser
Only add entity to entity cache if ID doesn't exist (#428)
This commit is contained in:
parent
35506f8bef
commit
0caecf68db
1 changed files with 11 additions and 5 deletions
|
@ -58,13 +58,19 @@ public class EntityCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEntity(Entity entity) {
|
public void spawnEntity(Entity entity) {
|
||||||
cacheEntity(entity);
|
if (cacheEntity(entity)) {
|
||||||
entity.spawnEntity(session);
|
entity.spawnEntity(session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cacheEntity(Entity entity) {
|
public boolean cacheEntity(Entity entity) {
|
||||||
entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId());
|
// Check to see if the entity exists, otherwise we can end up with duplicated mobs
|
||||||
entities.put(entity.getGeyserId(), entity);
|
if (!entityIdTranslations.containsKey(entity.getEntityId())) {
|
||||||
|
entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId());
|
||||||
|
entities.put(entity.getGeyserId(), entity);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeEntity(Entity entity, boolean force) {
|
public boolean removeEntity(Entity entity, boolean force) {
|
||||||
|
|
Loading…
Reference in a new issue