当前位置: 首页>>代码示例>>Java>>正文


Java IRecipe类代码示例

本文整理汇总了Java中net.minecraft.item.crafting.IRecipe的典型用法代码示例。如果您正苦于以下问题:Java IRecipe类的具体用法?Java IRecipe怎么用?Java IRecipe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IRecipe类属于net.minecraft.item.crafting包,在下文中一共展示了IRecipe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeRecipe

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
/**
 * 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();
        }
    }
}
 
开发者ID:elifoster,项目名称:MakeClayValuableAgain,代码行数:16,代码来源:MakeClayValuableAgain.java

示例2: registerRecipes

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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);
}
 
开发者ID:elytra,项目名称:ThermionicsWorld,代码行数:24,代码来源:ThermionicsWorld.java

示例3: getPriority

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:RecipeSorter.java

示例4: innerUpdate

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:27,代码来源:FluidCrafterTile.java

示例5: parse

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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);
}
 
开发者ID:iChun,项目名称:Torched,代码行数:18,代码来源:RecipeTorchGun.java

示例6: onRegisterRecipe

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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");
}
 
开发者ID:LasmGratel,项目名称:FoodCraft-Reloaded,代码行数:21,代码来源:EventLoader.java

示例7: registerSpecialRecipes

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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)));
	}
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:21,代码来源:GotWood.java

示例8: getToolHeadSchematicRecipe

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
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);
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:17,代码来源:ModRecipes.java

示例9: onMessage

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:21,代码来源:SimpleCraftCommandsImplementation.java

示例10: parse

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:23,代码来源:RandoresForgeUpgradeRecipeFactory.java

示例11: register

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
@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));
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:24,代码来源:PMJeiPlugin.java

示例12: removeRecipe

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
public static void removeRecipe(Predicate<IRecipe> recipePredicate) {
	for (IRecipe recipe : CraftingManager.REGISTRY) {
		if (recipePredicate.test(recipe)) {
			removeRecipe(recipe);
		}
	}
}
 
开发者ID:modmuss50,项目名称:RecipeManipulator,代码行数:8,代码来源:RecipeManipulator.java

示例13: addDyeRecipes

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
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);
	}
}
 
开发者ID:elytra,项目名称:ThermionicsWorld,代码行数:12,代码来源:ThermionicsWorld.java

示例14: addMeatUncraftingRecipe

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
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);
}
 
开发者ID:elytra,项目名称:ThermionicsWorld,代码行数:9,代码来源:ThermionicsWorld.java

示例15: addBrickRecipes

import net.minecraft.item.crafting.IRecipe; //导入依赖的package包/类
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)
			));
	
}
 
开发者ID:elytra,项目名称:ThermionicsWorld,代码行数:28,代码来源:ThermionicsWorld.java


注:本文中的net.minecraft.item.crafting.IRecipe类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。