From 641694d07c28aa940bd74ccffcd516287d20c062 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 23 Jun 2024 18:51:14 -0700 Subject: [PATCH] Fix NPE when retrieving an entity with a null UUID While the null UUID is almost certainly an error, the old implementation did not NPE as it used a plain HashMap for lookup by UUID, whereas we use a ConcurrentHashMap which will NPE on null keys. --- .../patches/chunk_system/level/entity/EntityLookup.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java index 3a8c192..f6a3eb3 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java @@ -88,7 +88,7 @@ public abstract class EntityLookup implements LevelEntityGetter { @Override public Entity get(final UUID id) { - return maskNonAccessible(this.entityByUUID.get(id)); + return maskNonAccessible(id == null ? null : this.entityByUUID.get(id)); } public boolean hasEntity(final UUID uuid) { @@ -96,7 +96,7 @@ public abstract class EntityLookup implements LevelEntityGetter { } public String getDebugInfo() { - return "count_id:" + this.entityById.size() + ",count_uuid:" + this.entityByUUID.size() + ",region_count:" + this.regions.size(); + return "count_id:" + this.entityById.size() + ",count_uuid:" + this.entityByUUID.size() + ",count_accessible:" + this.getEntityCount() + ",region_count:" + this.regions.size(); } protected static final class ArrayIterable implements Iterable {