[1.9.2] Generating Reports throws NPE with unmapped entities
Fayti1703 opened this issue ยท 3 comments
Attempting to generate a Concise or Full Report from the mod settings "Debugging" section results in this error message if a mod that adds entities is installed:
Failed to generate report: java.lang.NullPointerException: Cannot invoke "eu.ha3.presencefootsteps.sound.generator.Locomotion.name()" because the return value of "java.util.Map.get(Object)" is null
This is caused by the values.get(id).name() call here:
If a mod that adds entities (e.g. Spectrum) is installed without a resource pack that adds entries to the locomotionmap.json for these entities, the values.get(id) call will return null, causing the above exception.
Quick-fix patch
(n.b. this results in such unmapped entities being assigned null in the report)
diff --git a/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java b/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java
index 3e7f724c..e1f010cc 100644
--- a/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java
+++ b/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java
@@ -56,7 +56,8 @@ public class LocomotionLookup implements Index<Entity, Locomotion> {
Identifier id = EntityType.getId(type);
if (full || !contains(id)) {
if (type.create(MinecraftClient.getInstance().world) instanceof LivingEntity) {
- writer.field(id.toString(), values.get(id).name());
+ Locomotion locomotion = values.get(id);
+ writer.field(id.toString(), locomotion == null ? null : locomotion.name());
}
}
});Of course now github's auto-closing works. Re-opening, will close when the update has been released.