Two more corner cases in the oredictionary. Should work for all cases now.
This commit is contained in:
parent
a92f2a263b
commit
c474da04b3
1 changed files with 41 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
package net.minecraftforge.oredict;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -301,7 +302,20 @@ public class OreDictionary
|
|||
{
|
||||
if (stack == null || stack.getItem() == null) return -1;
|
||||
|
||||
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 -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = GameData.getItemRegistry().getId(registryName);
|
||||
}
|
||||
List<Integer> ids = stackToId.get(id); //Try the wildcard first
|
||||
if (ids == null || ids.size() == 0)
|
||||
{
|
||||
|
@ -323,7 +337,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));
|
||||
|
|
Loading…
Reference in a new issue