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


Java Recipe类代码示例

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


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

示例1: getCraftingRecipes

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public Iterable<Recipe> getCraftingRecipes()
{
    ShapedRecipe portalRecipe = new ShapedRecipe(makeItem(getAmountPerCraft()));

    portalRecipe.shape("BOB", "PCP", "OPO");

    Dye purpleDye = new Dye(Material.INK_SACK);
    purpleDye.setColor(DyeColor.PURPLE);

    portalRecipe.setIngredient('B', Material.BLAZE_POWDER);
    portalRecipe.setIngredient('O', Material.OBSIDIAN);
    portalRecipe.setIngredient('P', Material.ENDER_PEARL);
    portalRecipe.setIngredient('C', purpleDye.toItemStack(1).getData());

    return Collections.singletonList((Recipe) portalRecipe);
}
 
开发者ID:zDevelopers,项目名称:BelovedBlocks,代码行数:18,代码来源:NetherPortalBlock.java

示例2: onCommand

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
	if (args.length == 0) return false;
	
	String recipeType = args[0];
	List<? extends Recipe> recipes = recipesByTypeMapper.apply(recipeType);
	
	if (recipes == null) {
		sender.sendMessage(ChatColor.RED + "Unknown recipe type: " + recipeType);
		return true;
	} else if (recipes.isEmpty()) {
		sender.sendMessage(ChatColor.RED + "No recipes found for type: " + recipeType);
		return true;
	}
	
	return sender instanceof Player ? listPlayer((Player) sender, recipeType, recipes) : listSender(sender, recipeType, recipes);
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:18,代码来源:ListRecipesCommandExecutor.java

示例3: getRecipesFor

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public List<Recipe> getRecipesFor(ItemStack result) {
    Validate.notNull(result, "Result cannot be null");

    List<Recipe> results = new ArrayList<Recipe>();
    Iterator<Recipe> iter = recipeIterator();
    while (iter.hasNext()) {
        Recipe recipe = iter.next();
        ItemStack stack = recipe.getResult();
        if (stack.getType() != result.getType()) {
            continue;
        }
        if (result.getDurability() == -1 || result.getDurability() == stack.getDurability()) {
            results.add(recipe);
        }
    }
    return results;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:19,代码来源:CraftServer.java

示例4: parseShapelessRecipe

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
public Recipe parseShapelessRecipe(MapModuleContext context, Element elRecipe) throws InvalidXMLException {
    ShapelessRecipe recipe = new ShapelessRecipe(parseRecipeResult(context, elRecipe));

    for(Element elIngredient : XMLUtils.getChildren(elRecipe, "ingredient", "i")) {
        MaterialPattern item = XMLUtils.parseMaterialPattern(elIngredient);
        int count = XMLUtils.parseNumber(elIngredient.getAttribute("amount"), Integer.class, 1);
        if(item.dataMatters()) {
            recipe.addIngredient(count, item.getMaterialData());
        } else {
            recipe.addIngredient(count, item.getMaterial());
        }
    }

    if(recipe.getIngredientList().isEmpty()) {
        throw new InvalidXMLException("Crafting recipe must have at least one ingredient", elRecipe);
    }

    return recipe;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:CraftingModule.java

示例5: getRecipesFor

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public List<Recipe> getRecipesFor(ItemStack result) {
       Validate.notNull(result, "Result cannot be null");

       List<Recipe> results = new ArrayList<Recipe>();
       Iterator<Recipe> iter = recipeIterator();
       while (iter.hasNext()) {
           Recipe recipe = iter.next();
           ItemStack stack = recipe.getResult();
           if (stack.getType() != result.getType()) {
               continue;
           }
           if (result.getDurability() == -1 || result.getDurability() == stack.getDurability()) {
               results.add(recipe);
           }
       }
       return results;
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:19,代码来源:TestServer.java

示例6: oakPlanksHaveAtLeastOneRecipe

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Test
public void oakPlanksHaveAtLeastOneRecipe() {
    Iterator<Recipe> iterator = Bukkit.getServer().recipeIterator();
    while (iterator.hasNext()) {
        Recipe recipe = iterator.next();
        SortedSet<ItemStack> ingredients = ingredientsGetter.getIngredients(recipe);

        boolean shownOutput = false;
        for (ItemStack ingredient : ingredients) {
            if (ingredient.getType().equals(Material.WOOD)) {
                if (!shownOutput) {
                    shownOutput = true;
                }
                MaterialData data = ingredient.getData();
            }
        }
    }
}
 
开发者ID:sciolizer,项目名称:craftinomicon,代码行数:19,代码来源:RecipeSnapshotTest.java

示例7: realTest

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Test
public void realTest() {
    MaterialRecipes materialRecipes = recipeSnapshot.getMaterialRecipes(new MaterialData(Material.WORKBENCH));
    Collection<Recipe> recipes = materialRecipes.getRecipes();
    assertEqual(recipes.size(), 1);
    Recipe first = recipes.iterator().next();
    SortedSet<ItemStack> ingredients = ingredientsGetter.getIngredients(first);
    for (ItemStack ingredient : ingredients) {
        if (ingredient != null) {
            assertEqual(ingredient.getData().getData(), (byte)-1);
        }
    }

    MaterialRecipes recipes1 = recipeSnapshot.getMaterialRecipes(new MaterialData(Material.WOOD_STAIRS));
    assertEqual(recipes1.getRecipes().size(), 1);
    Recipe theRecipe = recipes1.getRecipes().iterator().next();
    SortedSet<ItemStack> stairsIngredients = ingredientsGetter.getIngredients(theRecipe);
    for (ItemStack stairsIngredient : stairsIngredients) {
        if (stairsIngredient != null) {
            assertEqual(stairsIngredient.getData().getData(), (byte)0);
        }
    }

    Bukkit.getServer().broadcastMessage("realtest passed");
}
 
开发者ID:sciolizer,项目名称:craftinomicon,代码行数:26,代码来源:RecipeSnapshotTest.java

示例8: jungleWoodPlanksCanCreateCraftingTableAndJungleWoodStairs

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Test
public void jungleWoodPlanksCanCreateCraftingTableAndJungleWoodStairs() {
    Tree planks = new Tree(Material.WOOD);
    planks.setSpecies(TreeSpecies.JUNGLE);
    MaterialRecipes materialRecipes = recipeSnapshot.getMaterialRecipes(planks);
    boolean foundWorkBench = false;
    boolean foundJungleWoodPlanks = false;
    for (Recipe recipe : materialRecipes.getUsages()) {
        ItemStack result = recipe.getResult();
        if (Material.WORKBENCH.equals(result.getType())) {
            foundWorkBench = true;
        } else if (Material.JUNGLE_WOOD_STAIRS.equals(result.getType())) {
            foundJungleWoodPlanks = true;
        }
    }
    assertEqual(true, foundWorkBench);
    assertEqual(true, foundJungleWoodPlanks);
}
 
开发者ID:sciolizer,项目名称:craftinomicon,代码行数:19,代码来源:RecipeSnapshotTest.java

示例9: registerItem

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public void registerItem(Item item) {
	this.itemMap.put(item.getItemName(), item);
	if (item instanceof ActionItem) {
		this.actionMap.put(item.getItemName(), (ActionItem)item);
	}
	if (item instanceof Listener) {
		Bukkit.getPluginManager().registerEvents((Listener)item, ZephyrPlugin.getInstance());
	}
	
	if (item.getRecipe() != null) {
		@SuppressWarnings("deprecation")
		ItemStack stack = new ItemStack(item.getItemId(), 1);
		ItemMeta meta = stack.getItemMeta();
		meta.setDisplayName(item.getItemNameColor() + item.getItemName());
		meta.setLore(item.getItemLore());
		stack.setItemMeta(meta);
		stack.setDurability((short)item.getItemData());
		Recipe recipe = createRecipe(item.getRecipe(), stack);
		Bukkit.addRecipe(recipe);
	}
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:23,代码来源:BukkitItemManager.java

示例10: next

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
public Recipe next() {
    if (recipes.hasNext()) {
        removeFrom = recipes;
        return recipes.next().toBukkitRecipe();
    } else {
        net.minecraft.server.ItemStack item;
        if (smeltingCustom.hasNext()) {
            removeFrom = smeltingCustom;
            item = smeltingCustom.next();
        } else {
            removeFrom = smeltingVanilla;
            item = smeltingVanilla.next();
        }

        CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(item));

        return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item));
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:20,代码来源:RecipeIterator.java

示例11: getCraftingRecipes

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public Iterable<Recipe> getCraftingRecipes()
{
    ArrayList<Recipe> recipes = new ArrayList<>();
    
    ShapedRecipe baseRecipe = CraftingRecipes.shaped(makeItem(1), Material.STICK, Material.IRON_INGOT);
    
    recipes.add(CraftingRecipes.shaped(baseRecipe, "BBA", "   ", "   "));
    recipes.add(CraftingRecipes.shaped(baseRecipe, "   ", "BBA", "   "));
    recipes.add(CraftingRecipes.shaped(baseRecipe, "   ", "   ", "BBA"));
    recipes.add(CraftingRecipes.shaped(baseRecipe, "ABB", "   ", "   "));
    recipes.add(CraftingRecipes.shaped(baseRecipe, "   ", "ABB", "   "));
    recipes.add(CraftingRecipes.shaped(baseRecipe, "   ", "   ", "ABB"));
    
    return recipes;
}
 
开发者ID:zDevelopers,项目名称:BelovedBlocks,代码行数:17,代码来源:Saw.java

示例12: getRecipe

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public Recipe getRecipe() {
    ShapedRecipe recipe = new ShapedRecipe(toItemStack());
    ToughMachineFrame mf = new ToughMachineFrame();
    IntegratedCircuit ic = new IntegratedCircuit();
    registerCustomIngredients(mf, ic);
    recipe.shape("OCO", "DFP", "RGR");
    recipe.setIngredient('O', Material.OBSIDIAN);
    recipe.setIngredient('C', ic.getMaterialData());
    recipe.setIngredient('D', Material.DISPENSER);
    recipe.setIngredient('F', mf.getMaterialData());
    recipe.setIngredient('P', Material.DIAMOND_PICKAXE);
    recipe.setIngredient('R', Material.REDSTONE);
    recipe.setIngredient('G', Material.GOLD_INGOT);
    return recipe;
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:17,代码来源:AutoBuilder.java

示例13: addCustomRecipes

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
@Override
public void addCustomRecipes(CustomRecipeManager crm) {
    // add a corresponding smelter recipe for every known vanilla furnace recipe
    Iterator<Recipe> iter = Bukkit.recipeIterator();
    while (iter.hasNext()) {
        Recipe r = iter.next();
        if (r instanceof FurnaceRecipe) {
            FurnaceRecipe fr = (FurnaceRecipe) r;
            if (RecipeUtil.isVanillaSmelt(fr.getInput().getType())) {
                crm.addCustomRecipe(new SimpleCustomRecipe(this, fr.getInput(), fr.getResult(), getProcessingTime(fr.getInput())));
            }
        }
    }

    // add a processing recipe for any STB item which reports itself as smeltable
    for (String key : SensibleToolbox.getItemRegistry().getItemIds()) {
        BaseSTBItem item = SensibleToolbox.getItemRegistry().getItemById(key);
        if (item.getSmeltingResult() != null) {
            ItemStack stack = item.toItemStack();
            crm.addCustomRecipe(new SimpleCustomRecipe(this, stack, item.getSmeltingResult(), getProcessingTime(stack)));
        }
    }
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:24,代码来源:Smelter.java

示例14: ListRecipesCommandExecutor

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
public ListRecipesCommandExecutor(Function<String, ? extends List<? extends Recipe>> recipesByTypeMapper,
		Map<String, Function<? super Recipe, ? extends ItemStack>> recipeToItemMap,
		Map<String, BiConsumer<? super Recipe, ? super CommandSender>> recipeToCommandSenderDiplayMap) {
	this.recipesByTypeMapper = recipesByTypeMapper;
	this.recipeToItemMap = recipeToItemMap;
	this.recipeToCommandSenderDiplayMap = recipeToCommandSenderDiplayMap;
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:8,代码来源:ListRecipesCommandExecutor.java

示例15: listPlayer

import org.bukkit.inventory.Recipe; //导入依赖的package包/类
private boolean listPlayer(Player player, String recipeType, List<? extends Recipe> recipes) {
	Function<? super Recipe, ? extends ItemStack> representationFunction = recipeToItemMap.get(recipeType);
	if (representationFunction == null) {
		player.sendMessage(ChatColor.RED + "No representation function found for this type of recipe. Trying chat messages..");
		return listSender(player, recipeType, recipes);
	}
	
	List<? extends ItemStack> representations = recipes.stream().map(representationFunction).collect(Collectors.toList());
	player.openInventory(new ListRecipesInventoryHolder(recipeType, representations).getInventory());
	
	return true;
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:13,代码来源:ListRecipesCommandExecutor.java


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