mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 23:13:15 +00:00
Merge branch '1.7.10' - fix up some oredictionary and substitution related issues
This commit is contained in:
commit
112c41a707
4 files changed
+98
-14
No files matched your search
@@ -13,6 +13,8 @@ import java.util.RandomAccess;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -29,7 +31,9 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
|
||||
public class OreDictionary
|
||||
{
|
||||
@@ -324,7 +328,20 @@ public class OreDictionary
|
||||
|
||||
Set<Integer> set = new HashSet<Integer>();
|
||||
|
||||
int id = Item.getIdFromItem(stack.getItem());
|
||||
// HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet
|
||||
// IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about.
|
||||
// APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game.
|
||||
String registryName = stack.getItem().delegate.name();
|
||||
int id;
|
||||
if (registryName == null)
|
||||
{
|
||||
FMLLog.log(Level.DEBUG, "Attempted to find the oreIDs for an unregistered object (%s). This won't work very well.", stack);
|
||||
return new int[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
id = GameData.getItemRegistry().getId(registryName);
|
||||
}
|
||||
List<Integer> ids = stackToId.get(id);
|
||||
if (ids != null) set.addAll(ids);
|
||||
ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16));
|
||||
@@ -428,9 +445,29 @@ public class OreDictionary
|
||||
private static void registerOreImpl(String name, ItemStack ore)
|
||||
{
|
||||
if ("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());
|
||||
// HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet
|
||||
// IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about.
|
||||
// APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game.
|
||||
String registryName = ore.getItem().delegate.name();
|
||||
int hash;
|
||||
if (registryName == null)
|
||||
{
|
||||
FMLLog.bigWarning("A broken ore dictionary registration with name %s has occurred. It adds an item (type: %s) which is currently unknown to the game registry. This dictionary item can only support a single value when"
|
||||
+ " registered with ores like this, and NO I am not going to turn this spam off. Just register your ore dictionary entries after the GameRegistry.\n"
|
||||
+ "TO USERS: YES this is a BUG in the mod "+Loader.instance().activeModContainer().getName()+" report it to them!", name, ore.getItem().getClass());
|
||||
hash = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = GameData.getItemRegistry().getId(registryName);
|
||||
}
|
||||
if (ore.getItemDamage() != WILDCARD_VALUE)
|
||||
{
|
||||
hash |= ((ore.getItemDamage() + 1) << 16); // +1 so 0 is significant
|
||||
@@ -474,7 +511,18 @@ public class OreDictionary
|
||||
if (ores == null) continue;
|
||||
for (ItemStack ore : ores)
|
||||
{
|
||||
int hash = Item.getIdFromItem(ore.getItem());
|
||||
// HACK: use the registry name's ID. It is unique and it knows about substitutions
|
||||
String name = ore.getItem().delegate.name();
|
||||
int hash;
|
||||
if (name == null)
|
||||
{
|
||||
FMLLog.log(Level.DEBUG, "Defaulting unregistered ore dictionary entry for ore dictionary %s: type %s to -1", getOreName(id), ore.getItem().getClass());
|
||||
hash = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = GameData.getItemRegistry().getId(name);
|
||||
}
|
||||
if (ore.getItemDamage() != WILDCARD_VALUE)
|
||||
{
|
||||
hash |= ((ore.getItemDamage() + 1) << 16); // +1 so meta 0 is significant
|
||||
|
||||
Reference in new issue
Block a user