本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
}
示例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");
}
示例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);
}
示例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);
}
}
示例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));
}
}
示例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;
}
示例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;
}
示例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)));
}
}
}
示例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;
}
示例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;
}