SteamWar/SpigotCore
Archiviert
13
0

Fix Entity position tracking
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2023-01-15 18:50:23 +01:00
Ursprung d8825f0262
Commit cf9b3ddf22

Datei anzeigen

@ -70,7 +70,7 @@ public class REntityServer implements Listener {
}
void addEntity(REntity entity) {
entities.computeIfAbsent(entityToId(entity), i -> new HashSet<>()).add(entity);
addEntityToChunk(entity);
entity.spawn(packet -> updateEntity(entity, packet));
}
@ -81,6 +81,7 @@ public class REntityServer implements Listener {
return;
onMissing(players.get(fromId), players.get(toId), entity::despawn);
removeEntityFromChunk(entity);
}
void postEntityMove(REntity entity, double fromX, double fromZ) {
@ -89,6 +90,7 @@ public class REntityServer implements Listener {
if(fromId == toId)
return;
addEntityToChunk(entity);
onMissing(players.get(toId), players.get(fromId), entity::spawn);
}
@ -100,6 +102,14 @@ public class REntityServer implements Listener {
void removeEntity(REntity entity) {
entity.despawn(packet -> updateEntity(entity, packet));
removeEntityFromChunk(entity);
}
private void addEntityToChunk(REntity entity) {
entities.computeIfAbsent(entityToId(entity), i -> new HashSet<>()).add(entity);
}
private void removeEntityFromChunk(REntity entity) {
long id = entityToId(entity);
HashSet<REntity> entitiesInChunk = entities.get(id);
entitiesInChunk.remove(entity);