From d0b24313d3cd5b65ef07285cd0d63145ccee5c13 Mon Sep 17 00:00:00 2001 From: LexManos Date: Tue, 27 Jun 2017 16:56:42 -0700 Subject: [PATCH] Fix MissingMapping REMAP action. Closes #4069 --- src/main/java/net/minecraftforge/event/RegistryEvent.java | 6 ++++-- .../java/net/minecraftforge/registries/ForgeRegistry.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraftforge/event/RegistryEvent.java b/src/main/java/net/minecraftforge/event/RegistryEvent.java index 2a7168a1c..9c881364f 100644 --- a/src/main/java/net/minecraftforge/event/RegistryEvent.java +++ b/src/main/java/net/minecraftforge/event/RegistryEvent.java @@ -159,14 +159,16 @@ public class RegistryEvent> extends GenericEven public static class Mapping> { public final IForgeRegistry registry; + private final IForgeRegistry pool; public final ResourceLocation key; public final int id; private Action action = Action.DEFAULT; private T target; - public Mapping(IForgeRegistry registry, ResourceLocation key, int id) + public Mapping(IForgeRegistry registry, IForgeRegistry pool, ResourceLocation key, int id) { this.registry = registry; + this.pool = pool; this.key = key; this.id = id; } @@ -206,7 +208,7 @@ public class RegistryEvent> extends GenericEven public void remap(T target) { Validate.notNull(target, "Remap target can not be null"); - Validate.isTrue(registry.getKey(target) != null, String.format("The specified entry %s hasn't been registered in registry yet.", target)); + Validate.isTrue(pool.getKey(target) != null, String.format("The specified entry %s hasn't been registered in registry yet.", target)); action = Action.REMAP; this.target = target; } diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index aeabee630..3718ad113 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -751,7 +751,8 @@ public class ForgeRegistry> implements IForgeRe public MissingMappings getMissingEvent(ResourceLocation name, Map map) { List> lst = Lists.newArrayList(); - map.forEach((rl, id) -> lst.add(new MissingMappings.Mapping(this, rl, id))); + ForgeRegistry pool = RegistryManager.ACTIVE.getRegistry(name); + map.forEach((rl, id) -> lst.add(new MissingMappings.Mapping(this, pool, rl, id))); return new MissingMappings(name, this, lst); }