Java 类net.minecraftforge.fml.common.registry.ForgeRegistries 实例源码

项目:harshencastle    文件:HarshenBlocks.java   
public static void register() {
    for(Block block : HarshenConfigs.BLOCKS.allComponants)
        if(HarshenConfigs.BLOCKS.isEnabled(block))
        {
            ForgeRegistries.BLOCKS.register(block);
            if(blocksWithItems.contains(block))
            {
                ItemBlock item = block instanceof IMetaItemBlock ? add(block) : new ItemBlock(block);
                item.setRegistryName(block.getRegistryName());
                item.setMaxStackSize(blockStackSize.get(block));
                ForgeRegistries.ITEMS.register(item);
            }

        }

}
项目:harshencastle    文件:TileEntityHarshenSpawner.java   
public EntityLivingBase getEntity(ItemStack stack)
{
    if(stack.getItem() == Item.getItemFromBlock(Blocks.AIR)
            || stack.equals(ItemStack.EMPTY))
    {
        this.entity = null;
        return null;
    }
    try
    {
        this.entity = (EntityLivingBase) ForgeRegistries.ENTITIES.getValue((ItemMonsterPlacer.getNamedIdFrom(stack))).newInstance(world);

    }
    catch (NullPointerException e) {
    }
    return this.entity;
}
项目:ToolBelt    文件:Config.java   
private static ItemStack parseItemStack(String itemString)
{
    Matcher matcher = itemRegex.matcher(itemString);

    if (!matcher.matches())
    {
        ToolBelt.logger.warn("Could not parse item " + itemString);
        return ItemStack.EMPTY;
    }

    Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(matcher.group("item")));
    if (item == null)
    {
        ToolBelt.logger.warn("Could not parse item " + itemString);
        return ItemStack.EMPTY;
    }

    String anyString = matcher.group("meta");
    String metaString = matcher.group("meta");
    int meta = Strings.isNullOrEmpty(anyString)
            ? (Strings.isNullOrEmpty(metaString) ? 0 : Integer.parseInt(metaString))
            : OreDictionary.WILDCARD_VALUE;

    return new ItemStack(item, 1, meta);
}
项目:PurificatiMagicae    文件:PMJeiPlugin.java   
@Override
public void register(IModRegistry registry)
{

    for(MagibenchRegistry.Tier t : PurMag.INSTANCE.getMagibenchRegistry().getTiers())
    {
        registry.addRecipeCatalyst(new ItemStack(ItemRegistry.magibench, 1, t.getTier()), MagibenchRecipeCategory.ID);
        registry.addRecipeCatalyst(new ItemStack(ItemRegistry.magibench, 1, t.getTier()), VanillaRecipeCategoryUid.CRAFTING);
    }
    registry.handleRecipes(AbstractMagibenchRecipeWrapper.class, recipe -> recipe, MagibenchRecipeCategory.ID);

    List<AbstractMagibenchRecipeWrapper> lst = new ArrayList<>();
    for(IRecipe rec : ForgeRegistries.RECIPES)
    {
        if(rec instanceof MagibenchRecipe)
            lst.add(new MagibenchShapedRecipeWrapper((MagibenchRecipe)rec, registry.getJeiHelpers().getStackHelper()));
        if(rec instanceof MagibenchShapelessRecipe)
            lst.add(new MagibenchShapelessRecipeWrapper((MagibenchShapelessRecipe)rec, registry.getJeiHelpers().getStackHelper()));
    }
    registry.addRecipes(lst, MagibenchRecipeCategory.ID);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(new MagibenchTransferInfo(MagibenchRecipeCategory.ID));
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(new MagibenchTransferInfo(VanillaRecipeCategoryUid.CRAFTING));
}
项目:Adventurers-Toolbox    文件:ModRecipes.java   
public static void initMaterialItems() {
    haft_map.put(new ItemStack(Items.STICK), ModMaterials.HAFT_WOOD);
    haft_map.put(new ItemStack(Items.BONE), ModMaterials.HAFT_BONE);
    haft_map.put(new ItemStack(Items.BLAZE_ROD), ModMaterials.HAFT_BLAZE_ROD);
    haft_map.put(new ItemStack(Blocks.END_ROD), ModMaterials.HAFT_END_ROD);

    Item haft = ForgeRegistries.ITEMS.getValue(new ResourceLocation("betterwithmods:material"));
    Item witherBone = ForgeRegistries.ITEMS.getValue(new ResourceLocation("nex:item_bone_wither"));
    if(haft != null) haft_map.put(new ItemStack(haft, 1, 36), ModMaterials.HAFT_IMPROVED);
    if(witherBone != null) haft_map.put(new ItemStack(witherBone, 1, 0), ModMaterials.HAFT_WITHER_BONE);

    handle_map.put(new ItemStack(ModItems.handle, 1, 0), ModMaterials.HANDLE_CLOTH);
    handle_map.put(new ItemStack(ModItems.handle, 1, 1), ModMaterials.HANDLE_LEATHER);
    //handle_map.put(new ItemStack(ModItems.handle, 1, 2), ModMaterials.HANDLE_WOOD);
    //handle_map.put(new ItemStack(ModItems.handle, 1, 3), ModMaterials.HANDLE_BONE);
    handle_map.put(new ItemStack(Items.STICK, 1, 0), ModMaterials.HANDLE_WOOD);
    handle_map.put(new ItemStack(Items.BONE, 1, 0), ModMaterials.HANDLE_BONE);

    adornment_map.put(new ItemStack(Items.DIAMOND), ModMaterials.ADORNMENT_DIAMOND);
    adornment_map.put(new ItemStack(Items.EMERALD), ModMaterials.ADORNMENT_EMERALD);
    adornment_map.put(new ItemStack(Items.QUARTZ), ModMaterials.ADORNMENT_QUARTZ);
    adornment_map.put(new ItemStack(Items.PRISMARINE_CRYSTALS), ModMaterials.ADORNMENT_PRISMARINE);
    adornment_map.put(new ItemStack(Items.ENDER_PEARL), ModMaterials.ADORNMENT_ENDER_PEARL);
}
项目:VillagerTrades    文件:VillagerRegistryHelper.java   
public static List<Map.Entry<Integer, String>> getProfessionIdsAndNamesSortedById()
{
    List<Map.Entry<Integer, String>> professions = new ArrayList<Map.Entry<Integer, String>>();

    for (VillagerRegistry.VillagerProfession profession : ForgeRegistries.VILLAGER_PROFESSIONS.getValues())
    {
        @SuppressWarnings("deprecation")
        int id = VillagerRegistry.getId(profession);
        String name = profession.getRegistryName().toString();
        professions.add(new AbstractMap.SimpleEntry<Integer, String>(id, name));
    }

    Collections.sort(professions, new Comparator<Map.Entry<Integer, String>>()
    {
        @Override
        public int compare(Map.Entry<Integer, String> o1, Map.Entry<Integer, String> o2)
        {
            return o1.getKey() - o2.getKey();
        }
    });

    return professions;

}
项目:FoodCraft-Reloaded    文件:EnumLoader.java   
/**
     * Attempt to register all entries from {@link #enumInstanceMap} to {@link ForgeRegistries}.
     * @see ForgeRegistries
     */
    public void register() {
        enumInstanceMap.forEach((instanceClass, enumMap) -> {
            if (IForgeRegistryEntry.class.isAssignableFrom(instanceClass))
                enumMap.values().stream().map(o -> (IForgeRegistryEntry<? extends IForgeRegistryEntry<?>>) o)
//                    .map(o -> new RegisterHandler(o))
                    .forEach(o -> {
//                    TODO RegisterManager.getInstance().putRegister(o);
                        if (o instanceof Item) {
                            ForgeRegistries.ITEMS.register((Item) o);
                            if (o instanceof OreDictated)
                                Arrays.stream(((OreDictated) o).getOreDictNames()).forEach(s -> OreDictionary.registerOre(s, (Item) o));
                        }
                        else if (o instanceof Block) {
                            ForgeRegistries.BLOCKS.register((Block) o);
                            if (o instanceof OreDictated)
                                Arrays.stream(((OreDictated) o).getOreDictNames()).forEach(s -> OreDictionary.registerOre(s, (Block) o));
                        }
                    });
            else if (Fluid.class.isAssignableFrom(instanceClass))
                enumMap.values().stream().map(o -> (Fluid) o).forEach(fluid -> {
                    FluidRegistry.registerFluid(fluid);
                    FluidRegistry.addBucketForFluid(fluid);
                });
        });
    }
项目:FoodCraft-Reloaded    文件:LiqueurLoader.java   
@Load
public void loadLiqueurs() {
    ForgeRegistries.ITEMS.getKeys().stream().filter(s -> s.getResourcePath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).forEach(liqueur -> {
        for (LiqueurType liqueurType : LiqueurTypes.values()) {
            if (liqueurType == LiqueurTypes.NORMAL)
                continue;
            ItemLiqueur typedLiqueur = new ItemLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur))));
            typedLiqueur.setLiqueurType(liqueurType);
            typedLiqueur.setRegistryName(liqueur.getRegistryName().getResourceDomain(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getResourcePath());
            typedLiqueur.setUnlocalizedName(liqueur.getUnlocalizedName());
            ForgeRegistries.ITEMS.register(typedLiqueur);
            OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur);
            OreDictionary.registerOre("listAllliqueur", typedLiqueur);
            OreDictionary.registerOre("listAllfoods", typedLiqueur);
            cachedLiqueurs.add(typedLiqueur);
        }
    });
}
项目:FoodCraft-Reloaded    文件:ItemLoader.java   
@Load
public void registerItems() {
    for (Field field : FCRItems.class.getFields()) {
        field.setAccessible(true);
        try {
            RegItem annoItem = field.getAnnotation(RegItem.class);
            if (annoItem == null)
                continue;

            Item item = (Item) field.get(null);
            ForgeRegistries.ITEMS.register(item.setRegistryName(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName(annoItem.value())).setUnlocalizedName(NameBuilder.buildUnlocalizedName(annoItem.value())));

            Arrays.stream(annoItem.oreDict()).forEach(s -> OreDictionary.registerOre(s, item));
        } catch (Throwable e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register item " + field.toGenericString(), e);
        }
    }
}
项目:FoodCraft-Reloaded    文件:BlockLoader.java   
@Load
public void registerBlocks() {
    for (Field field : FCRBlocks.class.getFields()) {
        field.setAccessible(true);
        RegBlock anno = field.getAnnotation(RegBlock.class);
        if (anno==null) continue;

        try {
            Block block = (Block) field.get(null);
            ForgeRegistries.BLOCKS.register(block.setRegistryName(NameBuilder.buildRegistryName(anno.value())).setUnlocalizedName(NameBuilder.buildUnlocalizedName(anno.value())));

            //Register item block.
            Class<? extends ItemBlock> itemClass = anno.itemClass();
            Constructor<? extends ItemBlock> con = itemClass.getConstructor(Block.class);
            con.setAccessible(true);
            ForgeRegistries.ITEMS.register(con.newInstance(block).setRegistryName(block.getRegistryName()).setUnlocalizedName(block.getUnlocalizedName()));

            Arrays.asList(anno.oreDict()).forEach(s -> OreDictionary.registerOre(s, block));
        } catch (Exception e) {
            FoodCraftReloaded.getLogger().warn("Un-able to register block " + field.toGenericString(), e);
        }
    }
}
项目:ModularMachinery    文件:FuelItemHelper.java   
public static void initialize() {
    NonNullList<ItemStack> stacks = NonNullList.create();
    for (Item i : ForgeRegistries.ITEMS) {
        CreativeTabs tab = i.getCreativeTab();
        if(tab != null) {
            i.getSubItems(tab, stacks);
        }
    }
    List<ItemStack> out = new LinkedList<>();
    for (ItemStack stack : stacks) {
        int burn = TileEntityFurnace.getItemBurnTime(stack); //Respects vanilla values.
        if(burn > 0) {
            out.add(stack);
        }
    }
    knownFuelStacks = ImmutableList.copyOf(out);
}
项目:ModularMachinery    文件:BlockArray.java   
public static IBlockStateDescriptor getDescriptor(String strElement) throws JsonParseException {
    int meta = -1;
    int indexMeta = strElement.indexOf('@');
    if(indexMeta != -1 && indexMeta != strElement.length() - 1) {
        try {
            meta = Integer.parseInt(strElement.substring(indexMeta + 1));
        } catch (NumberFormatException exc) {
            throw new JsonParseException("Expected a metadata number, got " + strElement.substring(indexMeta + 1), exc);
        }
        strElement = strElement.substring(0, indexMeta);
    }
    ResourceLocation res = new ResourceLocation(strElement);
    Block b = ForgeRegistries.BLOCKS.getValue(res);
    if(b == null || b == Blocks.AIR) {
        throw new JsonParseException("Couldn't find block with registryName '" + res.toString() + "' !");
    }
    if(meta == -1) {
        return new IBlockStateDescriptor(b);
    } else {
        return new IBlockStateDescriptor(b.getStateFromMeta(meta));
    }
}
项目:metamorph    文件:BlockMorph.java   
@Override
public void fromNBT(NBTTagCompound tag)
{
    super.fromNBT(tag);

    if (tag.hasKey("Block"))
    {
        Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("Block")));

        if (block != null)
        {
            this.block = tag.hasKey("Meta") ? block.getStateFromMeta(tag.getByte("Meta")) : block.getDefaultState();
        }
    }

    if (tag.hasKey("Pos"))
    {
        int[] pos = tag.getIntArray("Pos");

        if (pos.length == 3)
        {
            this.blockPos = new BlockPos(pos[0], pos[1], pos[2]);
        }
    }
}
项目:metamorph    文件:BlockMorph.java   
@Override
public void toNBT(NBTTagCompound tag)
{
    super.toNBT(tag);

    if (this.block != null)
    {
        tag.setString("Block", ForgeRegistries.BLOCKS.getKey(this.block.getBlock()).toString());
        tag.setByte("Meta", (byte) this.block.getBlock().getMetaFromState(this.block));
    }

    if (this.blockPos != null)
    {
        tag.setIntArray("Pos", new int[] {this.blockPos.getX(), this.blockPos.getY(), this.blockPos.getZ()});
    }
}
项目:AquaRegia    文件:BlockDumper.java   
public static void dump() {
    try (final PrintWriter writer = new PrintWriter("AquaRegia_BlockDump_" + (FMLCommonHandler.instance().getEffectiveSide().isClient() ? "Client" : "Server") + ".txt", "UTF-8")) {
        writer.println("Name - toString");

        StreamSupport.stream(ForgeRegistries.BLOCKS.spliterator(), false)
                .filter(block -> block.getRegistryName().getResourceDomain().equals(AquaRegia.MODID))
                .forEach(block -> {
                    final Item item = Item.getItemFromBlock(block);
                    if (item != null) {
                        writer.printf("%s - %s\n", item.getUnlocalizedName(), item.toString());
                    }
                });
    } catch (Exception e) {
        Logger.fatal(e, "Exception dumping blocks");

    }
}
项目:Gravestone-mod-Extended    文件:ZombieVillagerCorpseHelper.java   
public static List<ItemStack> getDefaultCorpses() {
    List<ItemStack> list = new ArrayList<>();

    list.add(createCorpse(0, 1)); // Farmer - farmer
    list.add(createCorpse(0, 2)); // Farmer - fisherman
    list.add(createCorpse(0, 3)); // Farmer - shepherd
    list.add(createCorpse(0, 4)); // Farmer - fletcher
    list.add(createCorpse(1, 1)); // Librarian - librarian
    list.add(createCorpse(1, 2)); // Librarian - cartographer
    list.add(createCorpse(2, 1)); // Priest - cleric
    list.add(createCorpse(3, 1)); // Smith - armor
    list.add(createCorpse(3, 2)); // Smith - weapon
    list.add(createCorpse(3, 3)); // Smith - tool
    list.add(createCorpse(4, 1)); // Butcher - butcher
    list.add(createCorpse(4, 2)); // Butcher - leather
    list.add(createCorpse(5, 1)); // Nitwit - nitwit

    List<VillagerRegistry.VillagerProfession> villagers = ForgeRegistries.VILLAGER_PROFESSIONS.getValues();
    for (VillagerRegistry.VillagerProfession villagerProfession : villagers) {
        list.add(createCorpse(VillagerRegistry.getId(villagerProfession), villagerProfession.getRandomCareer(RANDOM)));
    }

    return list;
}
项目:Gravestone-mod-Extended    文件:VillagerCorpseHelper.java   
public static List<ItemStack> getDefaultCorpses() {
    List<ItemStack> list = new ArrayList<>();

    list.add(getDefaultVillagerCorpse(0, 1)); // Farmer - farmer
    list.add(getDefaultVillagerCorpse(0, 2)); // Farmer - fisherman
    list.add(getDefaultVillagerCorpse(0, 3)); // Farmer - shepherd
    list.add(getDefaultVillagerCorpse(0, 4)); // Farmer - fletcher
    list.add(getDefaultVillagerCorpse(1, 1)); // Librarian - librarian
    list.add(getDefaultVillagerCorpse(1, 2)); // Librarian - cartographer
    list.add(getDefaultVillagerCorpse(2, 1)); // Priest - cleric
    list.add(getDefaultVillagerCorpse(3, 1)); // Smith - armor
    list.add(getDefaultVillagerCorpse(3, 2)); // Smith - weapon
    list.add(getDefaultVillagerCorpse(3, 3)); // Smith - tool
    list.add(getDefaultVillagerCorpse(4, 1)); // Butcher - butcher
    list.add(getDefaultVillagerCorpse(4, 2)); // Butcher - leather
    list.add(getDefaultVillagerCorpse(5, 1)); // Nitwit - nitwit

    List<VillagerRegistry.VillagerProfession> villagers = ForgeRegistries.VILLAGER_PROFESSIONS.getValues();
    for (VillagerRegistry.VillagerProfession villagerProfession : villagers) {
        list.add(getDefaultVillagerCorpse(VillagerRegistry.getId(villagerProfession), villagerProfession.getRandomCareer(RANDOM)));
    }

    return list;
}
项目:Gravestone-mod-Extended    文件:VillagersHandler.java   
public static void registerVillagers() {
    undertakerProfession = new VillagerRegistry.VillagerProfession(UNDERTAKER_NAME, Resources.UNDERTAKER, Resources.UNDERTAKER_ZOMBIE);
    IForgeRegistry<VillagerRegistry.VillagerProfession> villagerProfessions = ForgeRegistries.VILLAGER_PROFESSIONS;
    villagerProfessions.register(undertakerProfession);

    undertakerCareer = new VillagerRegistry.VillagerCareer(undertakerProfession, UNDERTAKER_NAME);
    undertakerCareer.addTrade(1,
            new EntityVillager.ListItemForEmeralds(new ItemStack(Items.SKULL, 1), new EntityVillager.PriceInfo(5, 10)),// skeleton
            new EntityVillager.ListItemForEmeralds(new ItemStack(Items.SKULL, 1, 2), new EntityVillager.PriceInfo(5, 10))// zombie
    );
    undertakerCareer.addTrade(2,
            new EntityVillager.ListItemForEmeralds(new ItemStack(Items.SKULL, 1, 3), new EntityVillager.PriceInfo(10, 20)),// steve
            new EntityVillager.ListItemForEmeralds(new ItemStack(Items.SKULL, 1, 4), new EntityVillager.PriceInfo(15, 25))// creeper
    );
    undertakerCareer.addTrade(3, new EntityVillager.ListItemForEmeralds(new ItemStack(Items.SKULL, 1, 1), new EntityVillager.PriceInfo(25, 35)));// wither
}
项目:DynamicSurroundings    文件:BlockState.java   
public static void forEach(final Consumer<IBlockState> func) {
    final Iterator<Block> itr = ForgeRegistries.BLOCKS.iterator();
    while (itr.hasNext()) {
        final Block block = itr.next();
        if (block != null) {
            final BlockStateContainer container = block.getBlockState();
            if (container != null) {
                final ImmutableList<IBlockState> states = container.getValidStates();
                if (states != null) {
                    for (final IBlockState s : states)
                        func.accept(s);
                }
            }
        }
    }
}
项目:Malgra    文件:Extractor.java   
@SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    if (stack.getItem() == Items.extractor) {
        event.getToolTip().subList(1, event.getToolTip().size()).clear();
        int malgra = 0;
        int maxMalgra = 0;
        if (stack.hasTagCompound()) {
            malgra = stack.getTagCompound().getInteger("malgra");
            ExtractorContainer container = (ExtractorContainer) (ForgeRegistries.ITEMS.getValue(new ResourceLocation(stack.getTagCompound().getString("container"))));
            maxMalgra = container.getStorage();
        } else {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setInteger("malgra", malgra);
            stack.getTagCompound().setString("container", Items.tinyContainer.getUnlocalizedName().substring(5));
        }
        event.getToolTip().add(Utils.translateToLocal("item.manaExtractor.malgraStored") + ": " + malgra + "/" + maxMalgra);
        if (stack.hasTagCompound()) {
            ExtractorTip tip = (ExtractorTip) (ForgeRegistries.ITEMS.getValue(new ResourceLocation(stack.getTagCompound().getString("tip"))));
            if (tip != null)
                event.getToolTip().add((tip.getMaterial().getDamageVsEntity() + 4) + " " + Utils.translateToLocal("attribute.name.generic.attackDamage"));
        }
    }
}
项目:CodeChickenLib    文件:SimpleCreativeTab.java   
/**
 * Create a SimpleCreativeTab!
 * The tab icon will be "baked" when the icon is requested the first time.
 * If the item cannot be found it will throw a RuntimeException, This can be avoided by setting "-Dccl.ignoreInvalidTabItem=true" in your command line args, this will default the tab to Redstone.
 *
 * @param tabLabel The label to be displayed, This WILL be localized by minecraft.
 * @param name     The item to find in the Item Registry e.g "minecraft:redstone" or "chickenchunks:chickenChunkLoader"
 * @param meta     The metadata of the item.
 */
@Deprecated//I Recommend using The Supplier variant.
public SimpleCreativeTab(String tabLabel, String name, int meta) {
    this(tabLabel, () -> {
        ItemStack stack = new ItemStack(Items.REDSTONE);
        ResourceLocation location = new ResourceLocation(name);
        Item item = ForgeRegistries.ITEMS.getValue(location);
        if (item == null) {
            String error = String.format("Error creating SimpleCreativeTab with name %s, unable to find \"%s\" in the Item Registry. Please ensure the name of the item is correct.", tabLabel, name);
            if (IGNORE_INVALID) {
                CCLLog.big(Level.WARN, error);
            } else {
                throw new IllegalArgumentException(error);
            }
        } else {
            stack = new ItemStack(item, 1, meta);
        }
        return stack;
    });
}
项目:TMT-Refraction    文件:Utils.java   
@Nullable
public static ItemStack getStackFromString(String itemId) {
    ResourceLocation location = new ResourceLocation(itemId);
    ItemStack stack = null;

    if (ForgeRegistries.ITEMS.containsKey(location)) {
        Item item = ForgeRegistries.ITEMS.getValue(location);
        if (item != null) stack = new ItemStack(item);

    } else if (ForgeRegistries.BLOCKS.containsKey(location)) {
        Block block = ForgeRegistries.BLOCKS.getValue(location);
        if (block != null) stack = new ItemStack(block);

    }
    return stack;
}
项目:TFC2    文件:TFC.java   
private void applyFoodValues(FoodReader reader)
{
    for(FoodJSON f : reader.foodList)
    {
        ResourceLocation rl = new ResourceLocation(f.itemName);
        Item i = ForgeRegistries.ITEMS.getValue(rl);
        if(i == null)
        {
            log.warn("FoodRegistry -> Item not found when searching ItemRegistry for object ->" + f.itemName);
            continue;
        }
        if(!(i instanceof IFood))
        {
            log.warn("Item ->" + f.itemName + " is not of type IFood");
            continue;
        }
        //IFood food = (IFood)i;
        //food.setExpirationTimer(f.decayTime);
        //food.setFoodGroup(f.foodGroup);

        FoodRegistry.getInstance().registerFood(f);
    }
}
项目:TechStack-s-HeavyMachineryMod    文件:TileEntityAssemblyTable.java   
public List<String> getFriendlyIngredentList() {
    List<String> returnValue = new ArrayList<String>();
    if (!getStackInSlot(0).isEmpty()) {
        if (getStackInSlot(0).getItem() instanceof ItemBlueprint) {

            for (ItemBlueprint.BlueprintIngredent ingredent : ((ItemBlueprint) getStackInSlot(0).getItem()).ingredents) {
                String ingredentName = ingredent.getName();
                Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(ingredentName));
                if (item != null) {
                    returnValue.add(item.getItemStackDisplayName(new ItemStack(item)) + " X " + ingredent.getCount());

                } else {
                    LogHelper.info("An Ingredent is null Tell Tech please!" + ingredentName);
                }
            }
        }
    }
    return returnValue;
}
项目:Culinary-Cultivation    文件:ModItems.java   
private static Item registerItem(Item item, String name, CreativeTabs tab) {
    ResourceLocation resourceLocation = new ResourceLocation(Reference.MOD_ID, name);
    item.setUnlocalizedName(resourceLocation.toString());
    item.setRegistryName(resourceLocation);
    item.setCreativeTab(tab);
    ForgeRegistries.ITEMS.register(item);

    if (item instanceof IOreDictEntry) {
        IOreDictEntry entry = (IOreDictEntry) item;
        OreDictHelper.entries.add(entry);
    }

    if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
        if (item.getHasSubtypes()) {
            NonNullList<ItemStack> subItems = NonNullList.create();
            item.getSubItems(tab, subItems);
            for (ItemStack stack : subItems) {
                String subItemName = item.getUnlocalizedName(stack).replace("item.culinarycultivation:", "");
                ModelLoader.setCustomModelResourceLocation(item, stack.getItemDamage(), new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, subItemName), "inventory"));
            }
        } else {
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MOD_ID, name), "inventory"));
        }
    }
    return item;
}
项目:Kingdom-Keys-Re-Coded    文件:GuiRecipeList.java   
@Override
protected void drawSlot (int var1, int var2, int var3, int var4, Tessellator var5) {
    SynthesisRecipeCapability.ISynthesisRecipe RECIPES = Minecraft.getMinecraft().player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null);

    int colour = 0xFFFFFF;
    if (parent.isRecipeUsable(RECIPES.getKnownRecipes().get(var1))) {
        colour = 0x55FF55;
    }
        Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, RECIPES.getKnownRecipes().get(var1).substring(5)));
    if (item instanceof ItemKeyblade) {
        drawStats((ItemKeyblade)item, var1, var3, colour);
    } else if (item instanceof ItemOrgWeapon) {
        drawStats((ItemOrgWeapon) item, var1, var3, colour);
    } else {
        this.f.drawString(f.trimStringToWidth(Utils.translateToLocal(RECIPES.getKnownRecipes().get(var1).toString() + ".name"), listWidth - 1), this.left + 3, var3 + 2, colour);
        this.ir.renderItemAndEffectIntoGUI(new ItemStack(item), this.left + 3, var3 + 12);
    }

}
项目:Easy-Editors    文件:SyntaxEnchant.java   
@Override
public IGuiCommandSlot[] setupCommand() {
    target = new CommandSlotPlayerSelector();

    enchantment = new CommandSlotEnchantment(true) {
        @Override
        public void checkValid() throws UIInvalidException {
            super.checkValid();
            Enchantment enchantment = ForgeRegistries.ENCHANTMENTS.getValue(getEnchantment());
            int level = getLevel();
            if (level < enchantment.getMinLevel() || level > enchantment.getMaxLevel()) {
                throw new UIInvalidException(
                        Translate.GUI_COMMANDEDITOR_PLAYERSELECTOR_ENCHANTMENTINVALID_LEVELOUTOFBOUNDS,
                        enchantment.getMinLevel(), enchantment.getMaxLevel());
            }
        }
    };

    return new IGuiCommandSlot[] {
            CommandSlotLabel.createLabel(Translate.GUI_COMMANDEDITOR_ENCHANT_TARGET,
                    Translate.GUI_COMMANDEDITOR_ENCHANT_TARGET_TOOLTIP,
                    new CommandSlotRectangle(target, Colors.playerSelectorBox.color)),
            CommandSlotLabel.createLabel(Translate.GUI_COMMANDEDITOR_ENCHANT_ENCHANTMENT,
                    Translate.GUI_COMMANDEDITOR_ENCHANT_ENCHANTMENT_TOOLTIP, enchantment) };
}
项目:Easy-Editors    文件:CommandSlotEntity.java   
@Override
public int readFromArgs(String[] args, int index) throws CommandSyntaxException {
    if (index >= args.length)
        throw new CommandSyntaxException();
    ResourceLocation key = new ResourceLocation(args[index]);
    boolean valid = ForgeRegistries.ENTITIES.containsKey(key);
    if (EntityList.LIGHTNING_BOLT.equals(key) && includeLightning) {
        valid = true;
    } else if (GuiSelectEntity.PLAYER.equals(key) && includePlayer) {
        valid = true;
    } else if (ArrayUtils.contains(additionalOptions, key)) {
        valid = true;
    }
    if (!valid) {
        throw new CommandSyntaxException();
    }
    setEntity(key);
    return 1;
}
项目:Easy-Editors    文件:GuiSelectBlock.java   
private static List<IBlockState> createAllowedValues(boolean allowSubBlocks,
        Predicate<IBlockState> allowBlockStatePredicate) {
    List<IBlockState> blocks = Lists.newArrayList();
    for (Block block : ForgeRegistries.BLOCKS) {
        if (allowSubBlocks) {
            List<IBlockState> variantStates = getAllVariantStates(block,
                    BlockPropertyRegistry.getVariantProperties(block));
            for (IBlockState variantState : variantStates) {
                if (allowBlockStatePredicate.apply(variantState)) {
                    blocks.add(variantState);
                }
            }
        } else {
            IBlockState defaultState = block.getDefaultState();
            if (allowBlockStatePredicate.apply(defaultState)) {
                blocks.add(defaultState);
            }
        }
    }
    return blocks;
}
项目:Easy-Editors    文件:GuiSelectItem.java   
private static List<ItemStack> createAllowedValues(boolean allowSubItems,
        Predicate<ItemStack> allowItemStackPredicate) {
    List<ItemStack> values = Lists.newArrayList();
    for (Item item : ForgeRegistries.ITEMS) {
        if (allowSubItems) {
            NonNullList<ItemStack> subItems = NonNullList.create();
            item.getSubItems(item, null, subItems);
            for (ItemStack subItem : subItems) {
                if (allowItemStackPredicate.apply(subItem)) {
                    values.add(subItem);
                }
            }
        } else {
            ItemStack stackToAdd = new ItemStack(item);
            if (allowItemStackPredicate.apply(stackToAdd)) {
                values.add(stackToAdd);
            }
        }
    }
    return values;
}
项目:TFC2    文件:TFC.java   
private void applyFoodValues(FoodReader reader)
{
    for(FoodJSON f : reader.foodList)
    {
        ResourceLocation rl = new ResourceLocation(f.itemName);
        Item i = ForgeRegistries.ITEMS.getValue(rl);
        if(i == null)
        {
            log.warn("FoodRegistry -> Item not found when searching ItemRegistry for object ->" + f.itemName);
            continue;
        }
        if(!(i instanceof IFood))
        {
            log.warn("Item ->" + f.itemName + " is not of type IFood");
            continue;
        }
        //IFood food = (IFood)i;
        //food.setExpirationTimer(f.decayTime);
        //food.setFoodGroup(f.foodGroup);

        FoodRegistry.getInstance().registerFood(f);
    }
}
项目:enderutilities    文件:MissingMappingEventHandler.java   
@SubscribeEvent
public static void onMissingMappingEventBlocks(RegistryEvent.MissingMappings<Block> event)
{
    List<Mapping<Block>> list = event.getMappings();
    Map<String, String> renameMap = TileEntityID.getMap();

    for (Mapping<Block> mapping : list)
    {
        ResourceLocation oldLoc = mapping.key;
        String newName = renameMap.get(oldLoc.toString());

        if (newName != null)
        {
            Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(newName));

            if (block != null && block != Blocks.AIR)
            {
                mapping.remap(block);
                EnderUtilities.logger.info("Re-mapped block '{}' => '{}'", oldLoc, newName);
            }
        }
    }
}
项目:enderutilities    文件:MissingMappingEventHandler.java   
@SubscribeEvent
public static void onMissingMappingEventItems(RegistryEvent.MissingMappings<Item> event)
{
    List<Mapping<Item>> list = event.getMappings();
    Map<String, String> renameMap = TileEntityID.getMap();

    for (Mapping<Item> mapping : list)
    {
        ResourceLocation oldLoc = mapping.key;
        String newName = renameMap.get(oldLoc.toString());

        if (newName != null)
        {
            Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(newName));

            if (item != null && item != Items.AIR)
            {
                mapping.remap(item);
                EnderUtilities.logger.info("Re-mapped item '{}' => '{}'", oldLoc, newName);
            }
        }
    }
}
项目:enderutilities    文件:TargetData.java   
public boolean isTargetBlockUnchanged()
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null)
    {
        return false;
    }

    World world = server.getWorld(this.dimension);
    if (world == null)
    {
        return false;
    }

    IBlockState iBlockState = world.getBlockState(this.pos);
    Block block = iBlockState.getBlock();
    ResourceLocation rl = ForgeRegistries.BLOCKS.getKey(block);
    int meta = block.getMetaFromState(iBlockState);

    // The target block unique name and metadata matches what we have stored
    return this.blockMeta == meta && rl != null && this.blockName.equals(rl.toString());
}
项目:enderutilities    文件:BlackLists.java   
public static void registerTeleportBlacklist(String[] blacklist)
{
    TELEPORT_BLACKLIST_CLASSES.clear();

    for (String name : blacklist)
    {
        EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(name));

        if (entry != null && entry.getEntityClass() != null)
        {
            TELEPORT_BLACKLIST_CLASSES.add(entry.getEntityClass());
        }
        else
        {
            EnderUtilities.logger.warn("Unknown Entity type '{}' on the teleport blacklist", name);
        }
    }
}
项目:AbyssalCraft    文件:NecroDataCapabilityStorage.java   
@Override
public void readNBT(Capability<INecroDataCapability> capability, INecroDataCapability instance, EnumFacing side, NBTBase nbt) {

    NBTTagCompound properties = (NBTTagCompound)nbt;

    NBTTagList l = properties.getTagList("entityTriggers", 8);
    for(int i = 0; i < l.tagCount(); i++)
        if(ForgeRegistries.ENTITIES.containsKey(new ResourceLocation(l.getStringTagAt(i))))
            instance.triggerEntityUnlock(l.getStringTagAt(i));
    l = properties.getTagList("biomeTriggers", 8);
    for(int i = 0; i < l.tagCount(); i++)
        if(ForgeRegistries.BIOMES.containsKey(new ResourceLocation(l.getStringTagAt(i))))
            instance.triggerBiomeUnlock(l.getStringTagAt(i));
    l = properties.getTagList("dimensionTriggers", 3);
    for(int i = 0; i < l.tagCount(); i++)
        if(DimensionManager.isDimensionRegistered(l.getIntAt(i)))
            instance.triggerDimensionUnlock(l.getIntAt(i));
}
项目:Runes-of-Wizardry    文件:Utils.java   
/**
 * Finds the possible recipes for a given ItemStack (Ignores NBT).
 * totally "borrowed" from Blood Magic (WayOfTime - CC-BY) https://github.com/WayofTime/BloodMagic/blob/9004bccba1e648ccccafc68644b74ada95e44f6f/src/main/java/WayofTime/bloodmagic/util/helper/RecipeHelper.java
 * @param stack
 * @return
 */
public static List<IRecipe> getRecipesForOutput(ItemStack stack) {
    List<IRecipe> recipes = new LinkedList<>();
    for (IRecipe recipe : ForgeRegistries.RECIPES.getValues()) {
        if (recipe != null) {
            ItemStack resultStack = recipe.getRecipeOutput();
            if (!resultStack.isEmpty()) {
                if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
                    recipes.add(recipe);
                }
            }
        }
    }

    return recipes;
}
项目:pnc-repressurized    文件:ProgWidgetCC.java   
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 ':'!");
    Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName));
    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;
}
项目:pnc-repressurized    文件:CraftingRegistrator.java   
public static void init() {

    //While static recipes are defined for the empty air canisters, for the recipe book and tools like JEI,
    //The following is defined to make them work for any air canister, and transfer the charge to the crafted item.
    //TODO dynamically create these, based on the json defined lay-outs, as currently the json recipes are ignored when
    //they get changed by resource pack creators.
    ForgeRegistries.RECIPES.register(new RecipeGun("dyeYellow", Itemss.VORTEX_CANNON));
    ForgeRegistries.RECIPES.register(new RecipeGun("dyeOrange", Itemss.PNEUMATIC_WRENCH));
    ForgeRegistries.RECIPES.register(new RecipeGun("dyeRed", Itemss.LOGISTICS_CONFIGURATOR));
    ForgeRegistries.RECIPES.register(new RecipeGun("dyeBlue", Itemss.CAMO_APPLICATOR));
    ForgeRegistries.RECIPES.register(new RecipePneumaticHelmet());
    ForgeRegistries.RECIPES.register(new RecipeManometer());
    ForgeRegistries.RECIPES.register(new RecipeAmadronTablet());

    ForgeRegistries.RECIPES.register(new RecipeColorDrone());
    ForgeRegistries.RECIPES.register(new RecipeLogisticToDrone());
    ForgeRegistries.RECIPES.register(new RecipeGunAmmo());

    if (ONE_PROBE != null) ForgeRegistries.RECIPES.register(new RecipeOneProbe());

    GameRegistry.addSmelting(Itemss.FAILED_PCB, new ItemStack(Itemss.EMPTY_PCB, 1, Itemss.EMPTY_PCB.getMaxDamage()), 0);

    addPressureChamberRecipes();
    addAssemblyRecipes();
    addThermopneumaticProcessingPlantRecipes();
    registerAmadronOffers();
    addCoolingRecipes();
}
项目:pnc-repressurized    文件:CraftingRegistrator.java   
private static void scanForFluids(ShapedOreRecipe recipe) {
    for (int i = 0; i < recipe.getIngredients().size(); i++) {
        Ingredient ingredient = recipe.getIngredients().get(i);
        for (ItemStack stack : ingredient.getMatchingStacks()) {
            FluidStack fluid = FluidUtil.getFluidContained(stack);
            if (fluid != null) {
                ForgeRegistries.RECIPES.register(new RecipeFluid(recipe, i));
            }
        }
    }
}