2525import net .minecraft .block .Block ;
2626import net .minecraft .block .BlockSand ;
2727import net .minecraft .item .Item ;
28+ import net .minecraft .item .ItemStack ;
2829import net .minecraft .nbt .NBTTagCompound ;
2930import net .minecraft .nbt .NBTTagList ;
3031
3132import com .google .common .base .Function ;
3233import com .google .common .base .Throwables ;
34+ import com .google .common .collect .HashBasedTable ;
3335import com .google .common .collect .ImmutableMap ;
3436import com .google .common .collect .ImmutableTable ;
3537import com .google .common .collect .ImmutableTable .Builder ;
@@ -54,6 +56,7 @@ public class GameData {
5456 private static boolean shouldContinue = true ;
5557 private static boolean isSaveValid = true ;
5658 private static ImmutableTable <String , String , Integer > modObjectTable ;
59+ private static Table <String , String , ItemStack > customItemStacks = HashBasedTable .create ();
5760 private static Map <String ,String > ignoredMods ;
5861
5962 private static boolean isModIgnoredForIdValidation (String modId )
@@ -299,4 +302,31 @@ static Block findBlock(String modId, String name)
299302 }
300303 return Block .field_71973_m [blockId ];
301304 }
305+
306+ static ItemStack findItemStack (String modId , String name )
307+ {
308+ ItemStack is = customItemStacks .get (modId , name );
309+ if (is == null )
310+ {
311+ Item i = findItem (modId , name );
312+ if (i != null )
313+ {
314+ is = new ItemStack (i , 0 ,0 );
315+ }
316+ }
317+ if (is == null )
318+ {
319+ Block b = findBlock (modId , name );
320+ if (b != null )
321+ {
322+ is = new ItemStack (b , 0 , 0 );
323+ }
324+ }
325+ return is ;
326+ }
327+
328+ static void registerCustomItemStack (String name , ItemStack itemStack )
329+ {
330+ customItemStacks .put (Loader .instance ().activeModContainer ().getModId (), name , itemStack );
331+ }
302332}
0 commit comments