fix: avoid tripping async catcher when getting entity from chunk (#2464)

This commit is contained in:
Jordan 2023-10-18 14:30:22 +01:00 committed by GitHub
parent 470c75d843
commit c6a9673b4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -295,7 +295,15 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
@Override
public CompoundTag getEntity(UUID uuid) {
Entity entity = serverLevel.getEntity(uuid);
ensureLoaded(serverLevel, chunkX, chunkZ);
List<Entity> entities = PaperweightPlatformAdapter.getEntities(getChunk());
Entity entity = null;
for (Entity e : entities) {
if (e.getUUID().equals(uuid)) {
entity = e;
break;
}
}
if (entity != null) {
org.bukkit.entity.Entity bukkitEnt = entity.getBukkitEntity();
return BukkitAdapter.adapt(bukkitEnt).getState().getNbtData();