Fix MissingMapping REMAP action. Closes #4069

This commit is contained in:
LexManos 2017-06-27 16:56:42 -07:00
parent 7281708df6
commit d0b24313d3
2 changed files with 6 additions and 3 deletions

View file

@ -159,14 +159,16 @@ public class RegistryEvent<T extends IForgeRegistryEntry<T>> extends GenericEven
public static class Mapping<T extends IForgeRegistryEntry<T>>
{
public final IForgeRegistry<T> registry;
private final IForgeRegistry<T> pool;
public final ResourceLocation key;
public final int id;
private Action action = Action.DEFAULT;
private T target;
public Mapping(IForgeRegistry<T> registry, ResourceLocation key, int id)
public Mapping(IForgeRegistry<T> registry, IForgeRegistry<T> pool, ResourceLocation key, int id)
{
this.registry = registry;
this.pool = pool;
this.key = key;
this.id = id;
}
@ -206,7 +208,7 @@ public class RegistryEvent<T extends IForgeRegistryEntry<T>> 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;
}

View file

@ -751,7 +751,8 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
public MissingMappings<?> getMissingEvent(ResourceLocation name, Map<ResourceLocation, Integer> map)
{
List<MissingMappings.Mapping<V>> lst = Lists.newArrayList();
map.forEach((rl, id) -> lst.add(new MissingMappings.Mapping<V>(this, rl, id)));
ForgeRegistry<V> pool = RegistryManager.ACTIVE.getRegistry(name);
map.forEach((rl, id) -> lst.add(new MissingMappings.Mapping<V>(this, pool, rl, id)));
return new MissingMappings<V>(name, this, lst);
}