Try and fix registry NPE when substitution is active.

This commit is contained in:
cpw 2015-12-23 14:11:17 -05:00
parent bcecf59a87
commit 53227982e3
2 changed files with 13 additions and 4 deletions

View File

@ -718,7 +718,7 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespacedDefaul
blockedIds.add(id); blockedIds.add(id);
} }
public void noitifyCallbacks() public void notifyCallbacks()
{ {
if (addCallback == null) if (addCallback == null)
return; return;
@ -728,4 +728,15 @@ public class FMLControlledNamespacedRegistry<I> extends RegistryNamespacedDefaul
addCallback.onAdd(i, this.underlyingIntegerMap.get(i)); addCallback.onAdd(i, this.underlyingIntegerMap.get(i));
} }
} }
@Override
public ResourceLocation getNameForObject(I p_177774_1_)
{
ResourceLocation rl = super.getNameForObject(p_177774_1_);
if (rl == null)
{
rl = activeSubstitutions.inverse().get(p_177774_1_);
}
return rl;
}
} }

View File

@ -23,7 +23,6 @@ import org.apache.logging.log4j.Level;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockAir; import net.minecraft.block.BlockAir;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -33,7 +32,6 @@ import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.StartupQuery; import net.minecraftforge.fml.common.StartupQuery;
import net.minecraftforge.fml.common.ZipperUtil; import net.minecraftforge.fml.common.ZipperUtil;
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
/** /**
@ -257,7 +255,7 @@ public class PersistentRegistryManager
// This happens when connecting to a server that doesn't have this registry. // This happens when connecting to a server that doesn't have this registry.
// Such as a 1.8.0 Forge server with 1.8.8+ Forge. // Such as a 1.8.0 Forge server with 1.8.8+ Forge.
// We must however, re-fire the callbacks as some internal data may be corrupted {potions} // We must however, re-fire the callbacks as some internal data may be corrupted {potions}
toRegistry.noitifyCallbacks(); toRegistry.notifyCallbacks();
} }
else else
{ {