From c4b148b84b813db12a0f92334ffd49a03c648236 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 5 Jan 2021 11:47:00 -0800 Subject: [PATCH] Prevent NPE and deprecated MissingMappings.getMappings function. Closes #6252 --- .../net/minecraftforge/event/RegistryEvent.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraftforge/event/RegistryEvent.java b/src/main/java/net/minecraftforge/event/RegistryEvent.java index 718ed6045..4cf220c06 100644 --- a/src/main/java/net/minecraftforge/event/RegistryEvent.java +++ b/src/main/java/net/minecraftforge/event/RegistryEvent.java @@ -122,9 +122,20 @@ public class RegistryEvent> extends GenericEven return this.registry; } + /* + * This used to be fired on the Mod specific bus, and we could tell which mod was asking for mappings. + * It no longer is, so this method is useless and just returns getAllMappings. + * TODO: Ask cpw how if he wants to re-enable the ModBus rethrow. + */ + @Deprecated public ImmutableList> getMappings() { - return ImmutableList.copyOf(this.mappings.stream().filter(e -> e.key.getNamespace().equals(this.activeMod.getModId())).collect(Collectors.toList())); + return this.activeMod == null ? getAllMappings() : getMappings(this.activeMod.getModId()); + } + + public ImmutableList> getMappings(String modid) + { + return ImmutableList.copyOf(this.mappings.stream().filter(e -> e.key.getNamespace().equals(modid)).collect(Collectors.toList())); } public ImmutableList> getAllMappings()