Java Code Examples for cpw.mods.fml.common.registry.GameRegistry#findItem()

The following examples show how to use cpw.mods.fml.common.registry.GameRegistry#findItem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecipeHandlerLaserDrill.java    From NEI-Integration with MIT License 6 votes vote down vote up
@Override
public void prepare() {
    laserOres = MFRRegistry.getLaserOres();
    for (WeightedRandom.Item ore : laserOres) {
        totalWeight += ore.itemWeight;
    }
    
    laserPreferredOres = new HashMap<Integer, List<ItemStack>>();
    for (int i = 0; i <= 15; i++) {
        List<ItemStack> preferredOres = MFRRegistry.getLaserPreferredOres(i);
        laserPreferredOres.put(i, preferredOres);
    }
    
    TileEntityLaserDrillPrecharger dummyPrecharger = new TileEntityLaserDrillPrecharger();
    TileEntityLaserDrill dummyDrill = new TileEntityLaserDrill();
    energyPerOperation = dummyPrecharger.getActivationEnergy() * dummyDrill.getWorkMax();
    dummyPrecharger = null;
    dummyDrill = null;
    
    laserFocus = GameRegistry.findItem("MineFactoryReloaded", "laserfocus");
    if (laserFocus == null) {
        laserFocus = GameRegistry.findItem("MineFactoryReloaded", "item.mfr.laserfocus");
    }
}
 
Example 2
Source File: ConverterItemStackInbound.java    From OpenPeripheral with MIT License 6 votes vote down vote up
@Override
public Object toJava(IConverter registry, Object o, Class<?> required) {
	if (required == ItemStack.class && o instanceof Map) {
		Map<?, ?> m = (Map<?, ?>)o;

		// TODO check
		Object id = m.get("id");
		Preconditions.checkArgument(id instanceof String, "Invalid item id");

		String[] parts = ((String)id).split(":");
		Preconditions.checkArgument(parts.length == 2, "Invalid item id");
		String modId = parts[0];
		String name = parts[1];
		Item item = GameRegistry.findItem(modId, name);

		int quantity = getIntValue(m, "qty", 1);
		int dmg = getIntValue(m, "dmg", 0);

		return new ItemStack(item, quantity, dmg);
	}
	return null;
}
 
Example 3
Source File: MyTown.java    From MyTown2 with The Unlicense 6 votes vote down vote up
/**
 * Checks the config to see if there are any wrong values.
 * Throws an exception if there is a problem.
 */
private void checkConfig() {
    // Checking cost item
    if(EconomyProxy.isItemEconomy()) {
        String[] split = Config.instance.costItemName.get().split(":");
        if (split.length < 2 || split.length > 3) {
            throw new ConfigException("Field costItem has an invalid value. Template: (modid):(unique_name)[:meta]. Use \"minecraft\" as modid for vanilla items/blocks.");
        }

        if (GameRegistry.findItem(split[0], split[1]) == null) {
            throw new ConfigException("Field costItem has an invalid modid or unique name of the item. Template: (modid):(unique_name)[:meta]. Use \"minecraft\" as modid for vanilla items/blocks.");
        }

        if (split.length > 2 && (!StringUtils.tryParseInt(split[2]) || Integer.parseInt(split[2]) < 0)) {
            throw new ConfigException("Field costItem has an invalid metadata. Template: (modid):(unique_name)[:meta]. Use \"minecraft\" as modid for vanilla items/blocks.");
        }
    }
}
 
Example 4
Source File: ProgWidgetCC.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private ProgWidgetItemFilter getItemFilter(String itemName, int damage, boolean useMetadata, boolean useNBT, boolean useOreDict, boolean useModSimilarity) throws IllegalArgumentException{
    if(!itemName.contains(":")) throw new IllegalArgumentException("Item/Block name doesn't contain a ':'!");
    String[] itemParts = itemName.split(":");
    Item item = GameRegistry.findItem(itemParts[0], itemParts[1]);
    if(item == null) throw new IllegalArgumentException("Item not found for the name \"" + itemName + "\"!");
    ProgWidgetItemFilter itemFilter = new ProgWidgetItemFilter();
    itemFilter.setFilter(new ItemStack(item, 1, damage));
    itemFilter.specificMeta = damage;
    itemFilter.useMetadata = useMetadata;
    itemFilter.useNBT = useNBT;
    itemFilter.useOreDict = useOreDict;
    itemFilter.useModSimilarity = useModSimilarity;
    return itemFilter;
}
 
Example 5
Source File: Thaumcraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void init(){
    ItemStack lapis = new ItemStack(Items.dye, 1, 4);
    Item shard = GameRegistry.findItem(ModIds.THAUMCRAFT, "ItemShard");
    if(shard != null) {
        GameRegistry.addRecipe(new ItemStack(Itemss.machineUpgrade, 1, 10), "lal", "bcd", "lel", 'l', lapis, 'a', new ItemStack(shard, 1, 0), 'b', new ItemStack(shard, 1, 1), 'c', new ItemStack(shard, 1, 6), 'd', new ItemStack(shard, 1, 3), 'e', new ItemStack(shard, 1, 4));
    } else {
        Log.error("Thaumcraft shard item couldn't be found! Registry name has changed? Thaumcraft Upgrade has no recipe!");
    }
}
 
Example 6
Source File: BlockNameConversion.java    From Chisel with GNU General Public License v2.0 5 votes vote down vote up
public static Item findItem(String oldname)
{
    FMLLog.getLogger().trace("findItem() START " + oldname);
    Item item = null;
    for (int i = 0; i < NameConversions.MAX && item == null; i++)
    {
        FMLLog.getLogger().trace("findItem()       Checking for " + NameConversions.conversion(oldname, i));
        item = GameRegistry.findItem(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
    }

    return item;
}
 
Example 7
Source File: BCItems.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
public static void init() {
    SimplyJetpacks.logger.info("Stealing BuildCraft's items");
    
    if (Loader.isModLoaded("BuildCraft|Transport")) {
        pipeFluidStone = new ItemStack(GameRegistry.findItem("BuildCraft|Transport", "item.buildcraftPipe.pipefluidsstone"));
        pipeEnergyGold = new ItemStack(GameRegistry.findItem("BuildCraft|Transport", "item.buildcraftPipe.pipepowergold"));
    } else {
        pipeFluidStone = "blockGlass";
        pipeEnergyGold = "dustRedstone";
    }
    
    if (Loader.isModLoaded("BuildCraft|Energy")) {
        Block engine = GameRegistry.findBlock("BuildCraft|Core", "engineBlock");
        if (engine == null) {
            engine = GameRegistry.findBlock("BuildCraft|Energy", "engineBlock");
        }
        
        engineCombustion = new ItemStack(engine, 1, 2);
    } else {
        engineCombustion = "gearIron";
    }
    
    if (Loader.isModLoaded("BuildCraft|Factory")) {
        tank = new ItemStack(GameRegistry.findBlock("BuildCraft|Factory", "tankBlock"));
    } else {
        tank = "blockGlass";
    }
    
    if (Loader.isModLoaded("BuildCraft|Silicon")) {
        chipsetGold = new ItemStack(GameRegistry.findItem("BuildCraft|Silicon", "redstoneChipset"), 1, 2);
    } else {
        chipsetGold = "gearGold";
    }
}
 
Example 8
Source File: EIOItems.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
public static void init() {
    SimplyJetpacks.logger.info("Stealing Ender IO's items");
    
    capacitorBankOld = new ItemStack(GameRegistry.findBlock("EnderIO", "blockCapacitorBank"));
    
    Block capBankBlock = GameRegistry.findBlock("EnderIO", "blockCapBank");
    capacitorBank = new ItemStack(capBankBlock, 1, 2);
    capacitorBankVibrant = new ItemStack(capBankBlock, 1, 3);
    
    redstoneConduit = new ItemStack(GameRegistry.findItem("EnderIO", "itemRedstoneConduit"), 1, 2);
    
    Item energyConduitItem = GameRegistry.findItem("EnderIO", "itemPowerConduit");
    energyConduit1 = new ItemStack(energyConduitItem, 1, 0);
    energyConduit2 = new ItemStack(energyConduitItem, 1, 1);
    energyConduit3 = new ItemStack(energyConduitItem, 1, 2);
    
    Item capacitorItem = GameRegistry.findItem("EnderIO", "itemBasicCapacitor");
    basicCapacitor = new ItemStack(capacitorItem, 1, 0);
    doubleCapacitor = new ItemStack(capacitorItem, 1, 1);
    octadicCapacitor = new ItemStack(capacitorItem, 1, 2);
    
    Item machinePartItem = GameRegistry.findItem("EnderIO", "itemMachinePart");
    machineChassis = new ItemStack(machinePartItem, 1, 0);
    basicGear = new ItemStack(machinePartItem, 1, 1);
    
    Item materialsItem = GameRegistry.findItem("EnderIO", "itemMaterial");
    pulsatingCrystal = new ItemStack(materialsItem, 1, 5);
    vibrantCrystal = new ItemStack(materialsItem, 1, 6);
    enderCrystal = new ItemStack(materialsItem, 1, 8);
}
 
Example 9
Source File: ItemIcon.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
private static ItemStack findDrawStack(String itemId, int meta) {
	if (Strings.isNullOrEmpty(itemId)) return null;
	String[] itemSplit = itemId.split(":");
	if (itemSplit.length != 2) return null;

	Item item = GameRegistry.findItem(itemSplit[0], itemSplit[1]);
	if (item == null) return null;

	return new ItemStack(item, 1, meta);
}
 
Example 10
Source File: WitcheryIntegration.java    From GardenCollection with MIT License 5 votes vote down vote up
private static void initWood () {
    Block log = GameRegistry.findBlock(MOD_ID, "witchlog");
    Block leaf = GameRegistry.findBlock(MOD_ID, "witchleaves");
    Item sapling = GameRegistry.findItem(MOD_ID, "witchsapling");

    WoodRegistry woodReg = WoodRegistry.instance();

    for (int i = 0; i < 3; i++)
        woodReg.registerWoodType(log, i);

    SaplingRegistry saplingReg = SaplingRegistry.instance();

    for (int i = 0; i < 3; i++)
        saplingReg.registerSapling(sapling, i, log, i, leaf, i);
}
 
Example 11
Source File: ConfigManager.java    From GardenCollection with MIT License 5 votes vote down vote up
private void parseStrangePlantItems (Property property) {
    String[] entries = property.getStringList();
    if (entries == null || entries.length == 0) {
        strangePlantDrops = new ItemStack[0];
        return;
    }

    List<ItemStack> results = new ArrayList<ItemStack>();

    for (String entry : entries) {
        UniqueMetaIdentifier uid = new UniqueMetaIdentifier(entry);
        int meta = (uid.meta == OreDictionary.WILDCARD_VALUE) ? 0 : uid.meta;

        Item item = GameRegistry.findItem(uid.modId, uid.name);
        if (item != null) {
            results.add(new ItemStack(item, 1, meta));
            continue;
        }

        Block block = GameRegistry.findBlock(uid.modId, uid.name);
        if (block != null) {
            item = Item.getItemFromBlock(block);
            if (item != null) {
                results.add(new ItemStack(item, 1, meta));
                continue;
            }
        }
    }

    strangePlantDrops = new ItemStack[results.size()];
    for (int i = 0; i < results.size(); i++)
        strangePlantDrops[i] = results.get(i);
}
 
Example 12
Source File: TinkersConstructIntegration.java    From GardenCollection with MIT License 5 votes vote down vote up
public static void init () {
    if (!Loader.isModLoaded(MODID))
        return;

    Item toolHatchet = GameRegistry.findItem(MODID, "hatchet");
    Item toolLumberAxe = GameRegistry.findItem(MODID, "lumberaxe");

    WoodPostRecipe.axeList.add(toolHatchet);
    WoodPostRecipe.axeList.add(toolLumberAxe);
}
 
Example 13
Source File: BlockNameConversion.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public static Item findItem(String oldname) {
	FMLLog.getLogger().trace("[Chisel 2] findItem() START " + oldname);
	Item item = null;
	for (int i = 0; i < NameConversions.MAX && item == null; i++) {
		FMLLog.getLogger().trace("[Chisel 2] findItem()       Checking for " + NameConversions.conversion(oldname, i));
		item = GameRegistry.findItem(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
	}

	return item;
}
 
Example 14
Source File: RecipeHandlerComposter.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void prepare() {
    fertilizer = GameRegistry.findItem("MineFactoryReloaded", "fertilizer");
    if (fertilizer == null) {
        fertilizer = GameRegistry.findItem("MineFactoryReloaded", "item.mfr.fertilizer");
    }
    
    TileEntityComposter dummy = new TileEntityComposter();
    sewagePerOperation = dummy.getWorkMax() * 20;
    energyPerOperation = dummy.getActivationEnergy() * dummy.getWorkMax();
    dummy = null;
}
 
Example 15
Source File: RecipeHandlerMeatPacker.java    From NEI-Integration with MIT License 5 votes vote down vote up
@Override
public void prepare() {
    meatIngot = GameRegistry.findItem("MineFactoryReloaded", "meat.ingot.raw");
    meatNugget = GameRegistry.findItem("MineFactoryReloaded", "meat.nugget.raw");
    if (meatIngot == null || meatNugget == null) {
        meatIngot = GameRegistry.findItem("MineFactoryReloaded", "item.mfr.meat.ingot.raw");
        meatNugget = GameRegistry.findItem("MineFactoryReloaded", "item.mfr.meat.nugget.raw");
    }
    
    TileEntityMeatPacker dummy = new TileEntityMeatPacker();
    fluidPerOperation = dummy.getWorkMax() * 2;
    energyPerOperation = dummy.getActivationEnergy() * dummy.getWorkMax();
    dummy = null;
}
 
Example 16
Source File: ExtraBiomesXLIntegration.java    From GardenCollection with MIT License 4 votes vote down vote up
private static void initWood () {
    Block log1 = GameRegistry.findBlock(MOD_ID, "log1");
    Block log2 = GameRegistry.findBlock(MOD_ID, "log2");
    Block log3 = GameRegistry.findBlock(MOD_ID, "mini_log_1");

    Block leaf1 = GameRegistry.findBlock(MOD_ID, "leaves_1"); // Brown, Orange, Purple, Yellow
    Block leaf2 = GameRegistry.findBlock(MOD_ID, "leaves_2"); // Bald Cyprus, Japanese Maple, Shrub, Rainbow Eucalyptus
    Block leaf3 = GameRegistry.findBlock(MOD_ID, "leaves_3"); // Sakura
    Block leaf4 = GameRegistry.findBlock(MOD_ID, "leaves_4"); // Fir, Redwood, Acacia, Cyprus

    Item sapling = GameRegistry.findItem(MOD_ID, "saplings_1");
    Item sapling2 = GameRegistry.findItem(MOD_ID, "saplings_2");

    WoodRegistry woodReg = WoodRegistry.instance();

    woodReg.registerWoodType(log1, 0); // Fir
    woodReg.registerWoodType(log1, 1); // Acacia
    woodReg.registerWoodType(log1, 2); // Cyprus
    woodReg.registerWoodType(log1, 3); // Japanese Maple

    woodReg.registerWoodType(log2, 0); // Rainbow Eucalyptus
    woodReg.registerWoodType(log2, 1); // Autumn
    woodReg.registerWoodType(log2, 2); // Bald Cyprus
    woodReg.registerWoodType(log2, 3); // Redwood

    woodReg.registerWoodType(log3, 0); // Sakura

    SaplingRegistry saplingReg = SaplingRegistry.instance();

    saplingReg.registerSapling(sapling, 0, log2, 1, leaf1, 0); // Umber Autumn
    saplingReg.registerSapling(sapling, 1, log2, 1, leaf1, 1); // Goldenrod Autumn
    saplingReg.registerSapling(sapling, 2, log2, 1, leaf1, 2); // Vermillion Autumn
    saplingReg.registerSapling(sapling, 3, log2, 1, leaf1, 3); // Citrine Autumn
    saplingReg.registerSapling(sapling, 4, log1, 0, leaf4, 0); // Fir
    saplingReg.registerSapling(sapling, 5, log2, 3, leaf4, 1); // Redwood
    saplingReg.registerSapling(sapling, 6, log1, 1, leaf4, 2); // Acacia
    saplingReg.registerSapling(sapling, 7, log1, 2, leaf4, 3); // Cyprus

    saplingReg.registerSapling(sapling2, 0, log2, 2, leaf2, 0); // Bald Cyprus
    saplingReg.registerSapling(sapling2, 1, log1, 3, leaf2, 1); // Japanese Maple
    saplingReg.registerSapling(sapling2, 2, log1, 3, leaf2, 2); // Japanese Maple Shrub
    saplingReg.registerSapling(sapling2, 3, log2, 0, leaf2, 3); // Rainbow Eucalyptus
    saplingReg.registerSapling(sapling2, 4, log3, 0, leaf3, 0); // Sakura
}
 
Example 17
Source File: UniqueMetaIdentifier.java    From GardenCollection with MIT License 4 votes vote down vote up
public Item getItem () {
    return GameRegistry.findItem(modId, name);
}
 
Example 18
Source File: BiomesOPlenty.java    From GardenCollection with MIT License 4 votes vote down vote up
private void initWood () {
    Block log1 = GameRegistry.findBlock(MOD_ID, "logs1");
    Block log2 = GameRegistry.findBlock(MOD_ID, "logs2");
    Block log3 = GameRegistry.findBlock(MOD_ID, "logs3");
    Block log4 = GameRegistry.findBlock(MOD_ID, "logs4");
    Block bamboo = GameRegistry.findBlock(MOD_ID, "bamboo");

    Block leaf1 = GameRegistry.findBlock(MOD_ID, "leaves1");
    Block leaf2 = GameRegistry.findBlock(MOD_ID, "leaves2");
    Block leaf3 = GameRegistry.findBlock(MOD_ID, "leaves3");
    Block leaf4 = GameRegistry.findBlock(MOD_ID, "leaves4");
    Block leafc1 = GameRegistry.findBlock(MOD_ID, "colorizedLeaves1");
    Block leafc2 = GameRegistry.findBlock(MOD_ID, "colorizedLeaves2");
    Block leafApple = GameRegistry.findBlock(MOD_ID, "appleLeaves");
    Block leafPersimmon = GameRegistry.findBlock(MOD_ID, "persimmonLeaves");

    Item sapling = GameRegistry.findItem(MOD_ID, "saplings");
    Item sapling2 = GameRegistry.findItem(MOD_ID, "colorizedSaplings");

    WoodRegistry woodReg = WoodRegistry.instance();

    woodReg.registerWoodType(log1, 0);
    woodReg.registerWoodType(log1, 1);
    woodReg.registerWoodType(log1, 2);
    woodReg.registerWoodType(log1, 3);

    woodReg.registerWoodType(log2, 0);
    woodReg.registerWoodType(log2, 1);
    woodReg.registerWoodType(log2, 2);
    woodReg.registerWoodType(log2, 3);

    woodReg.registerWoodType(log3, 0);
    woodReg.registerWoodType(log3, 1);
    woodReg.registerWoodType(log3, 2);
    woodReg.registerWoodType(log3, 3);

    woodReg.registerWoodType(log4, 0);
    woodReg.registerWoodType(log4, 1);
    woodReg.registerWoodType(log4, 2);
    woodReg.registerWoodType(log4, 3);

    SaplingRegistry saplingReg = SaplingRegistry.instance();

    saplingReg.registerSapling(sapling, 0, Blocks.log, 0, leafApple, 0);
    saplingReg.registerSapling(sapling, 1, Blocks.log, 2, leaf1, 0); // Autumn Tree
    saplingReg.registerSapling(sapling, 2, bamboo, 0, leaf1, 1); // Bamboo
    saplingReg.registerSapling(sapling, 3, log2, 1, leaf1, 2); // Magic Tree
    saplingReg.registerSapling(sapling, 4, log1, 2, leaf1, 3); // Dark Tree
    saplingReg.registerSapling(sapling, 5, log3, 2, leaf2, 0); // Dead Tree
    saplingReg.registerSapling(sapling, 6, log1, 3, leaf2, 1); // Fir Tree
    saplingReg.registerSapling(sapling, 7, log2, 0, leaf2, 2); // Loftwood Tree
    saplingReg.registerSapling(sapling, 8, Blocks.log2, 1, leaf2, 3); // Autumn Tree
    saplingReg.registerSapling(sapling, 9, Blocks.log, 0, leaf3, 0); // Origin Tree
    saplingReg.registerSapling(sapling, 10, log1, 1, leaf3, 1); // Pink Cherry Tree
    saplingReg.registerSapling(sapling, 11, Blocks.log, 0, leaf3, 2); // Maple Tree
    saplingReg.registerSapling(sapling, 12, log1, 1, leaf3, 3); // White Cherry Tree
    saplingReg.registerSapling(sapling, 13, log4, 1, leaf4, 0); // Hellbark
    saplingReg.registerSapling(sapling, 14, log4, 2, leaf4, 1); // Jacaranda
    saplingReg.registerSapling(sapling, 15, Blocks.log, 0, leafPersimmon, 0); // Persimmon Tree

    saplingReg.registerSapling(sapling2, 0, log1, 0, leafc1, 0); // Sacred Oak Tree
    saplingReg.registerSapling(sapling2, 1, log2, 2, leafc1, 1); // Mangrove Tree
    saplingReg.registerSapling(sapling2, 2, log2, 3, leafc1, 2 | 4); // Palm Tree
    saplingReg.registerSapling(sapling2, 3, log3, 0, leafc1, 3); // Redwood Tree
    saplingReg.registerSapling(sapling2, 4, log3, 1, leafc2, 0); // Willow Tree
    saplingReg.registerSapling(sapling2, 5, log4, 0, leafc2, 1); // Pine Tree
    saplingReg.registerSapling(sapling2, 6, log4, 3, leafc2, 2); // Mahogany Tree

    Map<String, int[]> saplingBank1 = new HashMap<String, int[]>();
    saplingBank1.put("small_oak", new int[] { 0, 1, 3, 5, 8, 9, 10, 11, 12, 14, 15 });
    saplingBank1.put("small_pine", new int[] { 2 });
    saplingBank1.put("small_spruce", new int[] { 4, 6, 7 });

    Map<String, int[]> saplingBank2 = new HashMap<String, int[]>();
    saplingBank2.put("small_oak", new int[] { 1 });
    saplingBank2.put("small_pine", new int[] { 3, 5 });
    saplingBank2.put("small_palm", new int[] { 2 });
    saplingBank2.put("small_willow", new int[] { 4 });
    saplingBank2.put("small_mahogany", new int[] { 6 });
    saplingBank2.put("large_oak", new int[] { 0 });

    Map<Item, Map<String, int[]>> banks = new HashMap<Item, Map<String, int[]>>();
    banks.put(GameRegistry.findItem(MOD_ID, "saplings"), saplingBank1);
    banks.put(GameRegistry.findItem(MOD_ID, "colorizedSaplings"), saplingBank2);

    SmallTreeRegistryHelper.registerSaplings(banks);
}
 
Example 19
Source File: Compat.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
public static Item getItem(String mod, String item) throws ItemNotFoundException {
    Item target = GameRegistry.findItem(mod, item);
    if(target == null)
        throw new ItemNotFoundException(mod, item);
    return target;
}
 
Example 20
Source File: ItemSupplier.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static Item getItem(String itemName){
    return GameRegistry.findItem("PneumaticCraft", itemName);
}