Adjusts OreDictionary to prevent invalid registrations.

Getting Ore Names for a non-existent ore will no longer automatically add that Name to the list nor generate an ID.

Tweaks a warning message in the FluidContainerRegistry. No functionality change.

Signed-off-by: King Lemming <kinglemming@gmail.com>
This commit is contained in:
King Lemming 2015-04-13 22:40:38 -04:00
parent 277495c8e4
commit 3cd7f6bd87
2 changed files with 8 additions and 3 deletions

View File

@ -171,7 +171,7 @@ public abstract class FluidContainerRegistry
}
if (data.fluid == null || data.fluid.getFluid() == null)
{
FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s (type %s) has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer));
FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer));
return false;
}
containerFluidMap.put(new ContainerKey(data.filledContainer), data);

View File

@ -344,7 +344,7 @@ public class OreDictionary
*/
public static ArrayList<ItemStack> getOres(String name) //TODO: 1.8 ArrayList -> List
{
return getOres(getOreID(name));
return nameToId.get(name) != null ? getOres(getOreID(name)) : EMPTY_LIST;
}
/**
@ -447,7 +447,12 @@ public class OreDictionary
*/
private static void registerOreImpl(String name, ItemStack ore)
{
if ("Unknown".equals(name)) return; //prevent bad IDs.
if (name == null || name.isEmpty() || "Unknown".equals(name)) return; //prevent bad IDs.
if (ore == null || ore.getItem() == null)
{
FMLLog.bigWarning("Invalid registration attempt for an Ore Dictionary item with name %s has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", name);
return; //prevent bad ItemStacks.
}
int oreID = getOreID(name);
int hash = Item.getIdFromItem(ore.getItem());