2013-08-28 08:32:01 +00:00
|
|
|
package thaumcraft.api;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import cpw.mods.fml.common.FMLLog;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Azanor
|
|
|
|
*
|
|
|
|
* This is used to gain access to the items in my mod.
|
|
|
|
* I only give some examples and it will probably still
|
|
|
|
* require a bit of work for you to get hold of everything you need.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class ItemApi {
|
|
|
|
|
|
|
|
public static ItemStack getItem(String itemString, int meta) {
|
|
|
|
ItemStack item = null;
|
|
|
|
|
|
|
|
try {
|
2013-10-06 20:38:49 +00:00
|
|
|
String itemClass = "thaumcraft.common.config.ConfigItems";
|
2013-08-28 08:32:01 +00:00
|
|
|
Object obj = Class.forName(itemClass).getField(itemString).get(null);
|
|
|
|
if (obj instanceof Item) {
|
|
|
|
item = new ItemStack((Item) obj,1,meta);
|
2013-10-06 20:38:49 +00:00
|
|
|
} else if (obj instanceof ItemStack) {
|
|
|
|
item = (ItemStack) obj;
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
FMLLog.warning("[Thaumcraft] Could not retrieve item identified by: " + itemString);
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ItemStack getBlock(String itemString, int meta) {
|
|
|
|
ItemStack item = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
String itemClass = "thaumcraft.common.config.ConfigBlocks";
|
|
|
|
Object obj = Class.forName(itemClass).getField(itemString).get(null);
|
|
|
|
if (obj instanceof Block) {
|
2013-08-28 08:32:01 +00:00
|
|
|
item = new ItemStack((Block) obj,1,meta);
|
|
|
|
} else if (obj instanceof ItemStack) {
|
|
|
|
item = (ItemStack) obj;
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
2013-10-06 20:38:49 +00:00
|
|
|
FMLLog.warning("[Thaumcraft] Could not retrieve block identified by: " + itemString);
|
2013-08-28 08:32:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Some examples
|
|
|
|
*
|
|
|
|
* Casting Wands:
|
|
|
|
* itemWandCasting
|
|
|
|
*
|
|
|
|
* Resources:
|
|
|
|
* itemEssence, itemWispEssence, itemResource, itemShard, itemNugget,
|
2013-09-01 09:36:19 +00:00
|
|
|
* itemNuggetChicken, itemNuggetBeef, itemNuggetPork, itemTripleMeatTreat
|
2013-08-28 08:32:01 +00:00
|
|
|
*
|
|
|
|
* Research:
|
|
|
|
* itemResearchNotes, itemInkwell, itemThaumonomicon
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|