本文整理匯總了Java中cpw.mods.fml.common.registry.GameData.getItemRegistry方法的典型用法代碼示例。如果您正苦於以下問題:Java GameData.getItemRegistry方法的具體用法?Java GameData.getItemRegistry怎麽用?Java GameData.getItemRegistry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cpw.mods.fml.common.registry.GameData
的用法示例。
在下文中一共展示了GameData.getItemRegistry方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nerfStandardRecipes
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Override
protected void nerfStandardRecipes ()
{
for (Item item : (Iterable<Item>) GameData.getItemRegistry())
{
if ((item instanceof ItemTool || item instanceof ItemSword) && !isBBTool(item))
{
String repairMaterial = BetterBeginningsHandler.getToolRepairMaterial(item);
if (!Strings.isNullOrEmpty(repairMaterial) && !OreDictionary.getOres(repairMaterial).isEmpty())
{
nerfToolRecipe(new ItemStack(item), repairMaterial);
}
}
}
}
示例2: getItemName
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
public static String getItemName(String s)
{
// If this name is a number we parse the number then check the item registry for an item with that ID.
// If the ID is valid we'll get the name, if not we'll get a null.
// If the name isn't a number just return the name again.
try
{
RegistryNamespaced rn = GameData.getItemRegistry();
int id = Integer.parseInt(s);
if(rn.containsId(id))
return rn.getNameForObject(rn.getObjectById(id));
else
return null;
}
catch (NumberFormatException e) {}
return s;
}
示例3: postInit
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Override public void postInit() {
for (Object o : GameData.getItemRegistry()) {
if (o instanceof Item) { // should always be true, but just to be sure
Item i = (Item) o;
try {
Masses.calculateMass(i, 0, 32767);
} catch (StackOverflowError error) {
continue;
} catch (Exception e) {
e.printStackTrace();
System.err.println("Dazed and confused, but trying to continue");
continue;
}
}
}
Masses.bake();
}
示例4: nerfStandardRecipes
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Override
protected void nerfStandardRecipes ()
{
for (Item item : (Iterable<Item>) GameData.getItemRegistry())
{
if (item instanceof ItemArmor)
{
ItemArmor armor = (ItemArmor) item;
ItemStack outputStack = new ItemStack(armor);
String repairMaterial = BetterBeginningsHandler.getArmorRepairMaterial(armor);
if (!Strings.isNullOrEmpty(repairMaterial))
{
String ingot = repairMaterial.startsWith("ingot")
? repairMaterial
: "ingot" + repairMaterial;
String nugget = repairMaterial.startsWith("nugget")
? repairMaterial
: "nugget" + repairMaterial;
if (!OreDictionary.getOres(ingot).isEmpty() && !OreDictionary.getOres(nugget).isEmpty() && outputStack.getItem() instanceof ItemArmor)
{
nerfArmorRecipe(outputStack, ingot, nugget);
}
}
}
}
}
示例5: registerModule
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Override
public void registerModule() {
final FMLControlledNamespacedRegistry<Item> itemRegistry = GameData.getItemRegistry();
Iterator<Item> itemIterator = itemRegistry.iterator();
while (itemIterator.hasNext()) {
Item item = itemIterator.next();
if (item != null) {
String itemName = itemRegistry.getNameForObject(item);
if (item instanceof IAncientWillContainer)
ArmorAAPI.charmRegistry.blackListCharmFromItem(itemName, CharmIDs.SIGHT);
if (item instanceof IPhantomInkable)
ArmorAAPI.charmRegistry.blackListCharmFromItem(itemName, CharmIDs.GLASS);
}
}
}
示例6: getForgeName
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
public static String getForgeName(Item item){
FMLControlledNamespacedRegistry<Item> items = GameData.getItemRegistry();
return items.getNameForObject(item);
}
示例7: processCommand
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Override
public void processCommand(ICommandSender cs, String[] args)
{
RegistryNamespaced rn = GameData.getItemRegistry();
if(cs instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) cs;
try
{
Item i = null;
ItemStack iStack = null;
switch(args.length)
{
case 0:
i = (player.getHeldItem() != null) ? player.getHeldItem().getItem() : null; break;
case 1:
i = (Item) rn.getObjectById(Integer.parseInt(args[0])); break;
case 2:
i = (Item) rn.getObjectById(Integer.parseInt(args[0])); break;
}
if(i == null)
{
Helper.toChatErr(cs, "No held item, or no such item.");
return;
}
iStack = new ItemStack(i);
int dmg = 0;
switch(args.length)
{
case 0:
iStack.setItemDamage(player.getHeldItem().getItemDamage());
dmg = iStack.getItemDamage();
break;
case 1:
iStack.setItemDamage(dmg);
break;
case 2:
dmg = Integer.parseInt(args[1]);
iStack.setItemDamage(dmg);
break;
}
if(iStack != null)
{
Helper.toChat(cs, EnumChatFormatting.GRAY + "--");
Helper.toChat(cs, EnumChatFormatting.AQUA + "NNAME: "+ rn.getIDForObject(i) + ":" + dmg);
Helper.toChat(cs, EnumChatFormatting.AQUA + "UNAME: "+ rn.getNameForObject(i));
int [] oIDs = OreDictionary.getOreIDs(iStack);
for(int j = 0; j < oIDs.length; j++)
{
Helper.toChat(cs, EnumChatFormatting.AQUA + "ONAME: "+OreDictionary.getOreName(oIDs[j]));
}
}
}
catch(NumberFormatException e)
{
Helper.toChatErr(cs, "Non-number in numeric field.");
}
}
}
示例8: onServerStart
import cpw.mods.fml.common.registry.GameData; //導入方法依賴的package包/類
@Mod.EventHandler
public void onServerStart(FMLServerStartingEvent event) {
if (MinecraftServer.getServer().getCommandManager() instanceof ServerCommandManager) {
((ServerCommandManager) MinecraftServer.getServer().getCommandManager()).registerCommand(new PokecheckmeCommand());
((ServerCommandManager) MinecraftServer.getServer().getCommandManager()).registerCommand(new AddToGrassCommand());
}
if (DEBUGMODE) {
//Here be dragons.
for (Block block : (Iterable<Block>) GameData.getBlockRegistry()) {
if (GameRegistry.findUniqueIdentifierFor(block).modId.equals("minecraft"))
continue;
String localName = block.getLocalizedName();
if (localName.contains("tile")) {
System.out.println("Block " + block.getClass().getName() + " Doesn't seem to have a name set!");
System.out.println();
}
if (block.getCreativeTabToDisplayOn() == null) {
System.out.println("Block " + block.getClass().getName() + " Doesn't seem to have a creative tab set!");
System.out.println();
}
}
for (Item item : (Iterable<Item>) GameData.getItemRegistry()) {
ItemStack itemStack = new ItemStack(item, 0, 1);
String itemName = item.getItemStackDisplayName(itemStack);
if (!itemName.getClass().getName().contains(MODID))
return;
if (itemName.contains("item.")) {
System.out.println("Item " + itemName + " doesn't seem to have a name set");
}
}
}
//////////////////////////////////////////////////////
}