/** * Removes all recipes that produce a given item. * @param itemToRemove The item whose recipes are to be removed. */ private static void removeRecipe(Item itemToRemove) { Iterator<IRecipe> iter = CraftingManager.getInstance().getRecipeList().iterator(); while (iter.hasNext()) { IRecipe recipe = iter.next(); ItemStack out = recipe.getRecipeOutput(); if (out != ItemStack.EMPTY && out.getItem() == itemToRemove) { FMLLog.info("Removing recipe for " + out); iter.remove(); } } }
@SubscribeEvent public void registerRecipes(RegistryEvent.Register<IRecipe> evt) { IForgeRegistry<IRecipe> r = evt.getRegistry(); for(EnumEdibleMeat meat : EnumEdibleMeat.values()) { ItemStack uncraftedRaw = meat.getRawItem().copy(); uncraftedRaw.setCount(9); ItemStack uncraftedCooked = meat.getCookedItem().copy(); uncraftedCooked.setCount(9); addMeatCompressionRecipe(r, meat, false, meat.getRawItem().copy()); addMeatCompressionRecipe(r, meat, true, meat.getCookedItem().copy()); addMeatUncraftingRecipe(r, meat, false, uncraftedRaw); addMeatUncraftingRecipe(r, meat, true, uncraftedCooked); FurnaceRecipes.instance().addSmeltingRecipe( TWItems.meat(meat, false), TWItems.meat(meat, true), 0.0f); } for(BlockGemrock block : TWBlocks.GROUP_GEMROCK) addBrickRecipes(r, block); //Norfairite can be dyed. This is surprisingly hard to get right. addDyeRecipes(r, TWBlocks.NORFAIRITE_CLEAR); }
private static int getPriority(IRecipe recipe) { Class<?> cls = recipe.getClass(); Integer ret = priorities.get(cls); if (ret == null) { if (!warned.contains(cls)) { FMLLog.bigWarning("Unknown recipe class! %s Modders need to register their recipe types with %s", cls.getName(), RecipeSorter.class.getName()); warned.add(cls); } cls = cls.getSuperclass(); while (cls != Object.class) { ret = priorities.get(cls); if (ret != null) { priorities.put(recipe.getClass(), ret); FMLLog.fine(" Parent Found: %d - %s", ret, cls.getName()); return ret; } } } return ret == null ? 0 : ret; }
@Override protected void innerUpdate() { if (this.world.isRemote) return; ++tick; if (crafting.getLocked() && tick >= 40 && hasOnlyOneFluid()) { Fluid fluid = getRecipeFluid(); if (fluid == null) return; int bucketAmount = getFluidAmount(fluid); FluidStack stack = tank.drain(bucketAmount * 1000, false); if (stack != null && stack.getFluid().equals(fluid) && stack.amount == bucketAmount * 1000) { IRecipe recipe = CraftingUtils.findRecipe(world, simulateRecipeEntries(fluid)); if (recipe == null || recipe.getRecipeOutput().isEmpty()) return; if (ItemHandlerHelper.insertItem(this.output, recipe.getRecipeOutput().copy(), true).isEmpty() && areAllSolidsPresent(fluid)) { NonNullList<ItemStack> remaining = recipe.getRemainingItems(CraftingUtils.genCraftingInventory(world, simulateRecipeEntries(fluid))); for (int i = 0; i < crafting.getSlots(); ++i) { if (isStackCurrentFluid(fluid, crafting.getFilterStack(i))) continue; if (remaining.get(i).isEmpty()) crafting.getStackInSlot(i).shrink(1); else crafting.setStackInSlot(i, remaining.get(i).copy()); } tank.drain(bucketAmount * 1000, true); ItemHandlerHelper.insertItem(this.output, recipe.getRecipeOutput().copy(), false); } } tick = 0; } }
@Override public IRecipe parse(JsonContext context, JsonObject json) { String group = JsonUtils.getString(json, "group", ""); NonNullList<Ingredient> ings = NonNullList.create(); for(JsonElement ele : JsonUtils.getJsonArray(json, "ingredients")) ings.add(CraftingHelper.getIngredient(ele, context)); if(ings.isEmpty()) throw new JsonParseException("No ingredients for shapeless recipe"); if(ings.size() > 9) throw new JsonParseException("Too many ingredients for shapeless recipe"); ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context); return new RecipeTorchGun(group, itemstack, ings); }
@SubscribeEvent public void onRegisterRecipe(RegistryEvent.Register<IRecipe> event) { FruitEnumLoader loader = FoodCraftReloaded.getProxy().getLoaderManager().getLoader(FruitEnumLoader.class).get(); OreDictionary.registerOre("cakeOriginal", Items.CAKE); for (FruitType fruitType : FruitType.values()) { event.getRegistry().register(new ShapedOreRecipe(new ResourceLocation("food"), new ItemStack(loader.getInstanceMap(BlockFruitSapling.class).get(fruitType)), " F ", "FXF", " F ", 'F', "crop" + StringUtils.capitalize(fruitType.toString()), 'X', "treeSapling").setRegistryName("fruit_sapling")); event.getRegistry().register(new ShapelessOreRecipe(new ResourceLocation("food"), new ItemStack(loader.getInstanceMap(ItemFruitIcecream.class).get(fruitType)), "food" + StringUtils.capitalize(fruitType.toString()) + "juice", "foodIcecream").setRegistryName("fruit_icecream")); GameRegistry.addShapelessRecipe( new ResourceLocation(FoodCraftReloaded.MODID, NameBuilder.buildRegistryName("cake", "fruit", fruitType.toString())), new ResourceLocation(FoodCraftReloaded.MODID, "cake"), new ItemStack(loader.getInstanceMap(ItemFruitCake.class).get(fruitType)), OreIngredient.fromItem(loader.getInstanceMap(ItemFruitJuice.class).get(fruitType)), new OreIngredient("cakeOriginal") ); } event.getRegistry().register(new KitchenKnifeRecipe().setRegistryName(FoodCraftReloaded.MODID, "kitchen_knife_recipe")); event.getRegistry().register(new CakeRecipe().setRegistryName(FoodCraftReloaded.MODID, "cake")); RecipeSorter.register("foodcraftreloaded:cake", CakeRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); }
@SubscribeEvent public void registerSpecialRecipes(RegistryEvent.Register<IRecipe> event) { if (ConfigurationHandler.retrieveSaplingsMode == 2) { ResourceLocation group = new ResourceLocation(GotWood.ID); GameRegistry.addShapelessRecipe(new ResourceLocation("oak_seed"), group, new ItemStack(Blocks.SAPLING, 1, 0), Ingredient.fromStacks(new ItemStack(ItemRegistry.oak_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("spruce_seed"), group, new ItemStack(Blocks.SAPLING, 1, 1), Ingredient.fromStacks(new ItemStack(ItemRegistry.spruce_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("birch_seed"), group, new ItemStack(Blocks.SAPLING, 1, 2), Ingredient.fromStacks(new ItemStack(ItemRegistry.birch_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("jungle_seed"), group, new ItemStack(Blocks.SAPLING, 1, 3), Ingredient.fromStacks(new ItemStack(ItemRegistry.jungle_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("acacia_seed"), group, new ItemStack(Blocks.SAPLING, 1, 4), Ingredient.fromStacks(new ItemStack(ItemRegistry.acacia_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("dark_oak_seed"), group, new ItemStack(Blocks.SAPLING, 1, 5), Ingredient.fromStacks(new ItemStack(ItemRegistry.dark_oak_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("apple_seed"), group, new ItemStack(BlockRegistry.apple_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.apple_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("maple_seed"), group, new ItemStack(BlockRegistry.maple_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.maple_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("pine_seed"), group, new ItemStack(BlockRegistry.pine_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.pine_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("willow_seed"), group, new ItemStack(BlockRegistry.willow_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.willow_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("yew_seed"), group, new ItemStack(BlockRegistry.yew_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.yew_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("ebony_seed"), group, new ItemStack(BlockRegistry.ebony_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.ebony_seed))); GameRegistry.addShapelessRecipe(new ResourceLocation("fir_seed"), group, new ItemStack(BlockRegistry.fir_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.fir_seed))); } }
private static IRecipe getToolHeadSchematicRecipe(ItemStack output, String material, String type, int cost) { NonNullList<Ingredient> inputs = NonNullList.withSize(cost + 1, Ingredient.EMPTY); ItemStack schematic = new ItemStack(ModItems.schematic); NBTTagCompound nbt = new NBTTagCompound(); nbt.setString(ItemSchematic.type_tag, type); schematic.setTagCompound(nbt); Ingredient schematicIngredient = new IngredientNBT(schematic) { }; inputs.set(0, schematicIngredient); for (int i = 1; i <= cost; i++) { inputs.set(i, new OreIngredient(material)); } return new ShapelessOreRecipe(null, inputs, output); }
@Override public IMessage onMessage(CraftMessage message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; // Try crafting recipes first: List<IRecipe> matching_recipes = CraftingHelper.getRecipesForRequestedOutput(message.parameters); for (IRecipe recipe : matching_recipes) { if (CraftingHelper.attemptCrafting(player, recipe)) return null; } // Now try furnace recipes: ItemStack input = CraftingHelper.getSmeltingRecipeForRequestedOutput(message.parameters); if (input != null) { if (CraftingHelper.attemptSmelting(player, input)) return null; } return null; }
@Override public IRecipe parse(JsonContext context, JsonObject json) { int clamp = JsonUtils.getInt(json, "clamp"); boolean combining = JsonUtils.getBoolean(json, "combining"); JsonArray upgradeList = JsonUtils.getJsonArray(json, "upgrades"); Map<Ingredient, Double> upgrades = new LinkedHashMap<>(); int n = 0; for (JsonElement element : upgradeList) { if (element.isJsonObject()) { JsonObject upgrade = element.getAsJsonObject(); double amount = JsonUtils.getFloat(upgrade, "amount"); Ingredient ingredient = CraftingHelper.getIngredient(upgrade.get("ingredient"), context); upgrades.put(ingredient, amount); } else { throw new JsonSyntaxException("Expected " + n + " to be a JsonObject, was " + JsonUtils.toString(json)); } n++; } return new RandoresForgeUpgradeRecipe(clamp, combining, upgrades); }
@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)); }
public static void removeRecipe(Predicate<IRecipe> recipePredicate) { for (IRecipe recipe : CraftingManager.REGISTRY) { if (recipePredicate.test(recipe)) { removeRecipe(recipe); } } }
public static void addDyeRecipes(IForgeRegistry<IRecipe> registry, BlockColored block) { ResourceLocation group = new ResourceLocation("thermionics_world", "dye"); for(EnumDyeColor dye : EnumDyeColor.values()) { ShapelessOreRecipe recipe = new ShapelessOreRecipe(group, new ItemStack(TWBlocks.NORFAIRITE_CLEAR,1,dye.getMetadata()), new ItemStack(Items.DYE,1,dye.getDyeDamage()), new ItemStack(TWBlocks.NORFAIRITE_CLEAR,1,OreDictionary.WILDCARD_VALUE)); recipe.setRegistryName(new ResourceLocation("thermionics_world", block.getRegistryName().getResourcePath()+"_DyeTo_"+dye.getUnlocalizedName()) ); registry.register(recipe); } }
public static void addMeatUncraftingRecipe(IForgeRegistry<IRecipe> registry, EnumEdibleMeat meat, boolean cooked, ItemStack result) { ResourceLocation group = new ResourceLocation("thermionics_world", "uncompress.meat"); ShapelessOreRecipe recipe = new ShapelessOreRecipe(group, result, new ItemStack(TWBlocks.MEAT_EDIBLE, 1, BlockMeatEdible.getMetaFromValue(meat, cooked)) ); recipe.setRegistryName(new ResourceLocation("thermionics_world", meat.getName()+((cooked)?".cooked":".raw")+"_DecompressFromBlock")); registry.register(recipe); }
public static void addBrickRecipes(IForgeRegistry<IRecipe> registry, BlockGemrock gem) { ResourceLocation group = new ResourceLocation("thermionics_world", "gemrock.chisel."+gem.getUnlocalizedName()); ShapedOreRecipe a = new ShapedOreRecipe(group, new ItemStack(gem, 4, 1), "xx", "xx", 'x', new ItemStack(gem,1,0) ); a.setRegistryName(new ResourceLocation("thermionics_world", "gemrock.chisel.intoBrick."+gem.getUnlocalizedName())); registry.register(a); registry.register(recipe("gemrock.chisel."+gem.getUnlocalizedName(), new ItemStack(gem, 1, 2), new ItemStack(gem, 1, 1) )); registry.register(recipe("gemrock.chisel."+gem.getUnlocalizedName(), new ItemStack(gem, 1, 3), new ItemStack(gem, 1, 2) )); registry.register(recipe("gemrock.chisel."+gem.getUnlocalizedName(), new ItemStack(gem, 1, 4), new ItemStack(gem, 1, 3) )); registry.register(recipe("gemrock.chisel."+gem.getUnlocalizedName(), new ItemStack(gem, 1, 1), new ItemStack(gem, 1, 4) )); }
public static IRecipe getRecipe(World world, ICraftingWidget widget) { InventoryCrafting craftingGrid = widget.getCraftingGrid(); for (IRecipe recipe : CraftingManager.REGISTRY) { if (recipe.matches(craftingGrid, world)) { return recipe; } } return null; }
public void unregister() { Iterator<IRecipe> it = CraftingManager.getInstance().getRecipeList().iterator(); while (it.hasNext()) { IRecipe recipe = it.next(); ItemStack output = recipe.getRecipeOutput(); if (output != null && output.getItem() != null) { if (output.isItemEqual(new ItemStack(Items.IRON_SWORD))){ output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND); output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 6, 0), EntityEquipmentSlot.MAINHAND); } if (output.isItemEqual(new ItemStack(Items.GOLDEN_SWORD))){ output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND); output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 5, 0), EntityEquipmentSlot.MAINHAND); } if (output.isItemEqual(new ItemStack(Items.DIAMOND_SWORD))){ output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND); output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 8, 0), EntityEquipmentSlot.MAINHAND); } if (output.isItemEqual(new ItemStack(Items.WOODEN_SWORD))){ output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND); output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 4, 0), EntityEquipmentSlot.MAINHAND); } if (output.isItemEqual(new ItemStack(Items.STONE_SWORD))){ output.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 20, 0), EntityEquipmentSlot.MAINHAND); output.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier("Weapon modifier", 5, 0), EntityEquipmentSlot.MAINHAND); } } } }
@SubscribeEvent public static void registerRecipes(RegistryEvent.Register<IRecipe> event) { RecipeRegistry.alchemyRecipes.add(new AlchemyRecipe(0,0,16,32,0,0,0,0,32,64,new ItemStack(Blocks.GLASS),new ItemStack(RegistryManager.ingot_lead),new ItemStack(RegistryManager.aspectus_lead),new ItemStack(RegistryManager.ingot_lead),new ItemStack(RegistryManager.archaic_circuit),new ItemStack(Registry.ALCHEMY_GLOBE))); RecipeRegistry.meltingRecipes.add(new ItemMeltingRecipe(new ItemStack(Items.SUGAR),new FluidStack(Registry.MOLTEN_SUGAR,16),false,false)); //Nugget size -> you can combine sugar and lead into antimony without remainder and 1000 sugar store nicely in a fluid vessel ArrayList<Fluid> leveledMetals = new ArrayList<>(); leveledMetals.add(RegistryManager.fluid_molten_lead); if(ConfigManager.enableTin) //Tin sometimes doesn't exist. leveledMetals.add(RegistryManager.fluid_molten_tin); leveledMetals.add(RegistryManager.fluid_molten_iron); leveledMetals.add(RegistryManager.fluid_molten_copper); leveledMetals.add(RegistryManager.fluid_molten_silver); leveledMetals.add(RegistryManager.fluid_molten_gold); //Nickel and Aluminium are mundane materials for(int i = 0; i < leveledMetals.size()-1; i++) { int e = i+1; FluidStack currentLevel = new FluidStack(leveledMetals.get(i),4); //TODO: Adjust this and add alchemical slurry as an input (redstone is either arsenic, copper or mercury) FluidStack nextLevel = new FluidStack(leveledMetals.get(e),4); AspectRangeList aspectRange = new AspectRangeList(AspectList.createStandard(0, 0, 0, 0, (e*e) * 4), AspectList.createStandard(0, 0, 0, 0, (e*e) * 8)); //Recipe gets harder the higher level it is alchemicalMixingRecipes.add(new RecipeAlchemicalMixer(new FluidStack[]{currentLevel}, nextLevel, aspectRange)); } alchemicalMixingRecipes.add(new RecipeAlchemicalMixer(new FluidStack[]{new FluidStack(RegistryManager.fluid_molten_lead,8),new FluidStack(Registry.MOLTEN_SUGAR,4)}, new FluidStack(Registry.MOLTEN_ANTIMONY,12), new AspectRangeList(AspectList.createStandard(0, 16, 0, 16, 0), AspectList.createStandard(0, 32, 0, 24, 0)))); RecipeRegistry.stampingRecipes.add(new ItemStampingRecipe(new ItemStack(RegistryManager.shard_ember),new FluidStack(Registry.MOLTEN_ANTIMONY,144), EnumStampType.TYPE_BAR, new ItemStack(Registry.SIGNET_ANTIMONY), false, false)); }
@Override public void register(IModRegistry registry) { STACKS = registry.getJeiHelpers().getStackHelper(); for (IRecipe recipe : ForgeRegistries.RECIPES) { if (recipe instanceof RecipeBase) { registry.addRecipes(Collections.singletonList(recipe), VanillaRecipeCategoryUid.CRAFTING); } } registry.handleRecipes(RecipeBase.class, JEIRecipePony::create, VanillaRecipeCategoryUid.CRAFTING); }
private void initMECTHandlers() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException { for (String ctName : Config.CRAFTING_TABLE_NAMES) { String camelCaseCTName = new StringBuilder(ctName) .replace(0, 1, Character.toString(Character.toUpperCase(ctName.charAt(0)))).toString(); List<IRecipe> recipes = (List<IRecipe>) LOTRRecipes.class .getDeclaredField((ctName.equals("blueDwarven") ? "blueMountains" : ctName).concat("Recipes")) .get(null); Class<? extends GuiContainer> guiClass = (Class<? extends GuiContainer>) Class .forName("lotr.client.gui.LOTRGuiCraftingTable$".concat(camelCaseCTName)); List<RecipeAntihandler> antihandlers = getAntihandlersForMECT(ctName); if (NeiLotr.mod.getConfig().isShapedMECTRecipeHandlerEnabled(ctName)) { BasicCTShapedRecipeHandler shapedHandler = new BasicCTShapedRecipeHandler(nextId(), guiClass, ctName); antihandlers.forEach(shapedHandler::addAntihandler); recipeLoader.registerStaticRecipeLoaderWithIRecipe(shapedHandler, recipes); registeredHandlers.add(shapedHandler); } if (NeiLotr.mod.getConfig().isShapelessMECTRecipeHandlerEnabled(ctName)) { BasicCTShapelessRecipeHandler shapelessHandler = new BasicCTShapelessRecipeHandler(nextId(), guiClass, ctName); getSubhandlersForMECT(ctName, shapelessHandler).forEach(shapelessHandler::addSubhandler); antihandlers.forEach(shapelessHandler::addAntihandler); recipeLoader.registerStaticRecipeLoaderWithIRecipe(shapelessHandler, recipes); registeredHandlers.add(shapelessHandler); } } }
public CachedRecipe getCachedRecipe(IRecipe recipe) { CachedRecipe ret = null; if (recipe instanceof ShapedRecipes) { ret = new ExtendedCachedShapedRecipe((ShapedRecipes) recipe); } else if (recipe instanceof ShapedOreRecipe) { ret = new ExtendedCachedShapedRecipe((ShapedOreRecipe) recipe); } return ret; }
public static List<IRecipe> getPoisonedWeaponRecipes() { List<IRecipe> ret = new ArrayList<>(); CraftingManager.getInstance().getRecipeList().forEach(recipe -> { if (recipe instanceof LOTRRecipePoisonWeapon) { ret.add((IRecipe) recipe); } }); return ret; }
/** Register recipes */ @SubscribeEvent public void onRecipeRegistry(Register<IRecipe> e) { ACCraftingManager.addCraftingRecipes(); for(IRecipe r : RECIPES_TO_REGISTER) { e.getRegistry().register(r); } RECIPES_TO_REGISTER.clear(); Log.logger.info("Recipes registered."); }
public static Collection<CachedRecipe> getCachedRecipes(AdvancedRecipeLoading loader, Collection<IRecipe> recipes) { List<CachedRecipe> ret = new ArrayList<>(); recipes.forEach(recipe -> { CachedRecipe cachedRecipe = loader.getCachedRecipe(recipe); if (cachedRecipe != null) { ret.add(cachedRecipe); } }); return ret; }
@SubscribeEvent public void registerRecipes(RegistryEvent.Register<IRecipe> event) { for (IInitializer init : initList) { init.register(); } }
public void registerRecipes(final Map<ResourceLocation, IRecipe> recipes, Object ingotStackOrString){ recipes.put(new ResourceLocation(Metalworks.MODID, "pickaxe_" + this.material.name()), new ShapedOreRecipe(null, pickaxe, "mmm", " s ", " s ", 'm', ingotStackOrString, 's', "stickWood")); recipes.put(new ResourceLocation(Metalworks.MODID, "axe_" + this.material.name()), new ShapedOreRecipe(null, axe, "mm", "ms", " s", 'm', ingotStackOrString, 's', "stickWood")); recipes.put(new ResourceLocation(Metalworks.MODID, "sword_" + this.material.name()), new ShapedOreRecipe(null, sword, "m", "m", "s", 'm', ingotStackOrString, 's', "stickWood")); recipes.put(new ResourceLocation(Metalworks.MODID, "shovel_" + this.material.name()), new ShapedOreRecipe(null, shovel, "m", "s", "s", 'm', ingotStackOrString, 's', "stickWood")); }
@SubscribeEvent public static void onPlayerJoinWorld(EntityJoinWorldEvent event) { if (event.getEntity() instanceof EntityPlayer) { for (RecipeList recipeList : RecipeBookClient.ALL_RECIPES) { Iterator<IRecipe> it = recipeList.getRecipes().iterator(); while (it.hasNext()) { IRecipe recipe = it.next(); if (CommonProxy.removed_recipes.contains(recipe.getRegistryName())) { it.remove(); } } } } }
@Override public IRecipe parse(JsonContext context, JsonObject json) { ShapedOreRecipe recipe = ShapedOreRecipe.factory(context, json); ShapedPrimer primer = new ShapedPrimer(); primer.width = recipe.getWidth(); primer.height = recipe.getHeight(); primer.mirrored = JsonUtils.getBoolean(json, "mirrored", true); primer.input = recipe.getIngredients(); return new RemoveCartridgeRecipe(new ResourceLocation(MeeCreeps.MODID, "remove_cartridge_factory"), recipe.getRecipeOutput(), primer); }
/** * Initializes statistics related to craftable items. Is only called after both block and item stats have been * initialized. */ private static void initCraftableStats() { Set<Item> set = Sets.<Item>newHashSet(); for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) { ItemStack itemstack = irecipe.getRecipeOutput(); if (!itemstack.func_190926_b()) { set.add(irecipe.getRecipeOutput().getItem()); } } for (ItemStack itemstack1 : FurnaceRecipes.instance().getSmeltingList().values()) { set.add(itemstack1.getItem()); } for (Item item : set) { if (item != null) { int i = Item.getIdFromItem(item); String s = getItemName(item); if (s != null) { CRAFTS_STATS[i] = (new StatCrafting("stat.craftItem.", s, new TextComponentTranslation("stat.craftItem", new Object[] {(new ItemStack(item)).getTextComponent()}), item)).registerStat(); } } } replaceAllSimilarBlocks(CRAFTS_STATS); }
public static void removeCraftingRecipe(Item item) { @SuppressWarnings("unchecked") List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); Iterator<IRecipe> iterator = recipes.iterator(); while (iterator.hasNext()) { ItemStack is = iterator.next().getRecipeOutput(); if (is != null && is.getItem() == item) iterator.remove(); } }
public static String makeUnique(IForgeRegistry<IRecipe> registry, String baseName) { String result = baseName.replace(':', '.'); if (!registry.containsKey(new ResourceLocation("thermionics",result))) return "thermionics:"+result; int i=0; while (registry.containsKey(new ResourceLocation("thermionics",result+"."+i))) i++; return "thermionics:"+result+"."+i; }
/** * Callback for when the crafting matrix is changed. */ @Override public void onCraftMatrixChanged(IInventory inventoryIn) { ItemStack stack = ItemStack.EMPTY; List<IRecipe> recipes = TF2CraftingManager.INSTANCE.getRecipeList(); if (currentRecipe >= 0 && currentRecipe < recipes.size() && recipes.get(currentRecipe).matches(this.craftMatrix, world)) stack = getReplacement(player, recipes.get(currentRecipe).getCraftingResult(this.craftMatrix)); // ?TF2CraftingManager.INSTANCE.getRecipeList().get(currentRecipe)TF2CraftingManager.INSTANCE.findMatchingRecipe(this.craftMatrix, // this.world); else stack = getReplacement(player, TF2CraftingManager.INSTANCE.findMatchingRecipe(this.craftMatrix, this.world)); this.craftResult.setInventorySlotContents(0, stack); }
private static void removeFirstRecipeFor(Item item) { for (Object recipe : CraftingManager.getInstance().getRecipeList()) if (recipe != null) { ItemStack stack = ((IRecipe) recipe).getRecipeOutput(); if (stack != null && stack.getItem() == item) { CraftingManager.getInstance().getRecipeList().remove(recipe); return; } } }
/** * Retrieves an ItemStack that has multiple recipes for it. */ @Nullable public ItemStack findMatchingRecipe(InventoryCrafting craftMatrix, World worldIn) { for (IRecipe irecipe : this.recipes) if (irecipe.matches(craftMatrix, worldIn)) return irecipe.getCraftingResult(craftMatrix); return ItemStack.EMPTY; }
@SubscribeEvent public static void registerRecipes (RegistryEvent.Register<IRecipe> event) { IForgeRegistry<IRecipe> registry = event.getRegistry(); OreDictionary.registerOre("ingotWroughtIron", EnumMaterial.WROUGHT_IRON_INGOT.getItemStack(material)); OreDictionary.registerOre("nuggetWroughtIron", EnumMaterial.WROUGHT_IRON_NUGGET.getItemStack(material)); OreDictionary.registerOre("materialWax", EnumMaterial.WAX.getItemStack(material)); OreDictionary.registerOre("materialPressedWax", EnumMaterial.WAX.getItemStack(material)); GameRegistry.addSmelting(EnumMaterial.CANDELILLA.getItemStack(material), EnumMaterial.WAX.getItemStack(material), 0); }
/** * Initializes statistics related to craftable items. Is only called after both block and item stats have been * initialized. */ private static void initCraftableStats() { Set<Item> set = Sets.<Item>newHashSet(); for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) { if (irecipe.getRecipeOutput() != null) { set.add(irecipe.getRecipeOutput().getItem()); } } for (ItemStack itemstack : FurnaceRecipes.instance().getSmeltingList().values()) { set.add(itemstack.getItem()); } for (Item item : set) { if (item != null) { int i = Item.getIdFromItem(item); String s = func_180204_a(item); if (s != null) { objectCraftStats[i] = (new StatCrafting("stat.craftItem.", s, new ChatComponentTranslation("stat.craftItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat(); } } } replaceAllSimilarBlocks(objectCraftStats); }
public static ItemStack findMatchingRecipe(Iterable<IRecipe> recipes, InventoryCrafting craftMatrix, World worldIn) { for (IRecipe irecipe : recipes) { if (irecipe.matches(craftMatrix, worldIn)) { return irecipe.getCraftingResult(craftMatrix); } } return ItemStack.EMPTY; }
private List<IRecipe> createTestRecipes(Item result) { return Lists.newArrayList(new ShapedRecipes("group", 1, 1, NonNullList.from(Ingredient.EMPTY, Ingredient.fromItem(Items.ITEM_FRAME)), new ItemStack(result)), new ShapedRecipes("group", 2, 2, NonNullList.from(Ingredient.EMPTY, Ingredient.fromStacks(new ItemStack(Blocks.STONE)), Ingredient.fromStacks(new ItemStack(Blocks.STONE)), Ingredient.fromStacks(new ItemStack(Blocks.LOG)), Ingredient.fromStacks(new ItemStack(Blocks.LOG))), new ItemStack(result))); }