diff --git a/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java index d9d621b5b..d80f716b4 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java @@ -412,6 +412,7 @@ public class FMLControlledNamespacedRegistry> e } public void serializeDummied(Set set) { set.addAll(this.dummiedLocations); } + public boolean isDummied(ResourceLocation key){ return this.dummiedLocations.contains(key); } /** diff --git a/src/main/java/net/minecraftforge/fml/common/registry/ObjectHolderRef.java b/src/main/java/net/minecraftforge/fml/common/registry/ObjectHolderRef.java index b9e1ac7c7..6f91ea4bd 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/ObjectHolderRef.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/ObjectHolderRef.java @@ -31,6 +31,7 @@ import com.google.common.base.Throwables; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; +import net.minecraftforge.fml.common.registry.PersistentRegistryManager.PersistentRegistry; /** @@ -39,14 +40,15 @@ import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; * @author cpw * */ +@SuppressWarnings("rawtypes") class ObjectHolderRef { private Field field; private ResourceLocation injectedObject; private boolean isValid; - private IForgeRegistry registry; + private FMLControlledNamespacedRegistry registry; - - ObjectHolderRef(Field field, ResourceLocation injectedObject, boolean extractFromExistingValues) + @SuppressWarnings("unchecked") + ObjectHolderRef(Field field, ResourceLocation injectedObject, boolean extractFromExistingValues) { registry = getRegistryForType(field); @@ -58,7 +60,7 @@ class ObjectHolderRef { { Object existing = field.get(null); // nothing is ever allowed to replace AIR - if (existing == null || existing == GameData.getBlockRegistry().getDefaultValue()) + if (existing == null || existing == registry.getDefaultValue()) { this.injectedObject = null; this.field = null; @@ -97,17 +99,19 @@ class ObjectHolderRef { } } - private IForgeRegistry getRegistryForType(Field field) + @SuppressWarnings("unchecked") + private FMLControlledNamespacedRegistry getRegistryForType(Field field) { Queue> typesToExamine = new LinkedList>(); typesToExamine.add(field.getType()); - IForgeRegistry registry = null; - while (!typesToExamine.isEmpty() && registry == null) { + FMLControlledNamespacedRegistry registry = null; + while (!typesToExamine.isEmpty() && registry == null) + { Class type = typesToExamine.remove(); Collections.addAll(typesToExamine, type.getInterfaces()); if (IForgeRegistryEntry.class.isAssignableFrom(type)) { - registry = PersistentRegistryManager.findRegistryByType((Class) type); + registry = PersistentRegistry.ACTIVE.getRegistry((Class) type); final Class parentType = type.getSuperclass(); if (parentType != null) { @@ -125,7 +129,7 @@ class ObjectHolderRef { public void apply() { Object thing; - if (isValid && registry.containsKey(injectedObject)) + if (isValid && registry.containsKey(injectedObject) && !registry.isDummied(injectedObject)) { thing = registry.getValue(injectedObject); }