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


Java ShapelessRecipe类代码示例

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


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

示例1: parseShapelessRecipe

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的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

示例2: UpgradeItem

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
public UpgradeItem(SQTechDrill plugin)
{
	this.main = plugin;
	upgradeItem = new ItemStack(Material.WRITTEN_BOOK);
	
	BookMeta bookMeta = (BookMeta) upgradeItem.getItemMeta();
	//bookMeta.setDisplayName(ChatColor.BLUE + "" + ChatColor.ITALIC + "Drill Upgrade");
	bookMeta.setAuthor(ChatColor.AQUA + "Drill");
	bookMeta.setPages("Test pgae 1\n s","asgsgge 2");
	bookMeta.setGeneration(BookMeta.Generation.ORIGINAL);
	bookMeta.setTitle(ChatColor.BLUE + "" + ChatColor.ITALIC + "Drill Upgrade");
	upgradeItem.setItemMeta(bookMeta);
	
	ShapelessRecipe recipe = new ShapelessRecipe(upgradeItem);
	
	//TODO temp recipe
	recipe.addIngredient(Material.DIRT); //Adds the specified ingredient.
	
	main.getServer().addRecipe(recipe);
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:21,代码来源:UpgradeItem.java

示例3: enableCallback

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
/**
 * Add our recipes
 */
@Override
protected void enableCallback()
{
    //Make a recipe that will return a golden carrot when the right shape is made
    ShapedRecipe newGoldenCarrot = new ShapedRecipe(new ItemStack(Material.GOLDEN_CARROT, 1));
    //8 gold ingots surrounding an apple
    newGoldenCarrot.shape("AAA", "ABA", "AAA");
    newGoldenCarrot.setIngredient('A', Material.GOLD_INGOT);
    newGoldenCarrot.setIngredient('B', Material.CARROT_ITEM);
    Bukkit.addRecipe(newGoldenCarrot);

    //Make the recipe for glistering melons minus a set shape (glistering melon is speckled melon in code
    ShapelessRecipe newGlisteringMelon = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON, 1));
    //1 gold ingot with a melon
    newGlisteringMelon.addIngredient(Material.GOLD_BLOCK);
    newGlisteringMelon.addIngredient(Material.MELON);
    Bukkit.addRecipe(newGlisteringMelon);
}
 
开发者ID:Eluinhost,项目名称:ultrahardcore,代码行数:22,代码来源:RecipeFeature.java

示例4: injectRecipes

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static void injectRecipes()
{
	ShapedRecipe slimeBlock = new ShapedRecipe(new ItemStack(
			Material.getMaterial("slime"))).shape(
			new String[] { "###", "###", "###" }).setIngredient('#',
			Material.SLIME_BALL);
	Bukkit.getServer().addRecipe(slimeBlock);
	ShapelessRecipe deslimeBlock = new ShapelessRecipe(new ItemStack(
			Material.SLIME_BALL, 9));
	deslimeBlock.addIngredient(Material.getMaterial("slime"));
	Bukkit.getServer().addRecipe(deslimeBlock);

	ShapedRecipe redSandStone = new ShapedRecipe(new ItemStack(Material.getMaterial("red_sandstone")))
			.shape(new String[] { "   ", "## ", "## " }).setIngredient('#',
					Material.SAND, 1);
	Bukkit.getServer().addRecipe(redSandStone);
	
}
 
开发者ID:Vislo,项目名称:VisloBlock,代码行数:20,代码来源:InjectorManager.java

示例5: onEnable

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
@Override
public void onEnable() {
    ConfigurationSerialization.registerClass(CustomItemStackImpl.class);
    ConfigurationSerialization.registerClass(CustomMaterialImpl.class);
    recipeManager = new RecipeManager(this);
    recipeManager.setupRecipes();
    saveResource("music/canon.mid", false);
    jingleNoteManager = new JingleNoteManager();
    registerListeners(new EntityShootBowListener(this), new PlayerQuitListener(this));
    Map<Character, ItemStack> harpIngredients = new HashMap<>();
    harpIngredients.put('s', new ItemStack(Material.STRING));
    harpIngredients.put('S', new ItemStack(Material.STICK));
    CustomMaterial harp = new CustomMaterialImpl("Harp", Material.BOW, new String[] {"ssS", "ssS", "ssS"}, harpIngredients);
    addMaterial(harp);
    Map<Character, ItemStack> bandageIngredients = new HashMap<>();
    bandageIngredients.put('w', new ItemStack(Material.WOOL, 1));
    CustomMaterial bandage = new CustomMaterialImpl("Bandage", Material.PAPER, new String[] {"www"}, bandageIngredients);
    addMaterial(bandage);
    ShapelessRecipe bandageRecipe = new ShapelessRecipe(new CustomItemStackImpl(bandage, 3).toMinecraftItemStack());
    bandageRecipe.addIngredient(Material.LEATHER_CHESTPLATE);
    getServer().addRecipe(bandageRecipe);
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:23,代码来源:WaywardItems.java

示例6: setupRecipes

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
public void setupRecipes() {
    ShapelessRecipe beerRecipe = new ShapelessRecipe(getDrink("Beer")).addIngredient(Material.WHEAT).addIngredient(Material.POTION).addIngredient(Material.POTATO_ITEM).addIngredient(Material.SUGAR);
    plugin.getServer().addRecipe(beerRecipe);
    ShapelessRecipe wineRecipe = new ShapelessRecipe(getDrink("Wine")).addIngredient(Material.MELON).addIngredient(Material.POTION);
    plugin.getServer().addRecipe(wineRecipe);
    ShapelessRecipe sherryRecipe = new ShapelessRecipe(getDrink("Sherry")).addIngredient(5, Material.MELON).addIngredient(Material.POTION);
    plugin.getServer().addRecipe(sherryRecipe);
    ShapelessRecipe vodkaRecipe = new ShapelessRecipe(getDrink("Vodka")).addIngredient(Material.POISONOUS_POTATO).addIngredient(Material.POTION);
    plugin.getServer().addRecipe(vodkaRecipe);
    ShapelessRecipe whiskyRecipe = new ShapelessRecipe(getDrink("Whisky")).addIngredient(5, Material.WHEAT).addIngredient(Material.POTION);
    plugin.getServer().addRecipe(whiskyRecipe);
    ShapelessRecipe rumRecipe = new ShapelessRecipe(getDrink("Rum")).addIngredient(Material.SUGAR_CANE).addIngredient(Material.POTION);
    plugin.getServer().addRecipe(rumRecipe);
    ShapelessRecipe ciderRecipe = new ShapelessRecipe(getDrink("Cider")).addIngredient(Material.APPLE).addIngredient(Material.POTION);
    plugin.getServer().addRecipe(ciderRecipe);
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:17,代码来源:DrinkManager.java

示例7: fromBukkitRecipe

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
public static CraftShapelessRecipe fromBukkitRecipe(ShapelessRecipe recipe) {
    if (recipe instanceof CraftShapelessRecipe) {
        return (CraftShapelessRecipe) recipe;
    }
    CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getResult());
    for (ItemStack ingred : recipe.getIngredientList()) {
        ret.addIngredient(ingred.getType(), ingred.getDurability());
    }
    return ret;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftShapelessRecipe.java

示例8: onSaddleSign

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
@EventHandler
public void onSaddleSign(final PrepareItemCraftEvent event) {
    if (event.getRecipe() instanceof ShapelessRecipe) {
        final ShapelessRecipe recipe = (ShapelessRecipe)event.getRecipe();
        if (recipe.getIngredientList().equals(Sddls.recipe.getIngredientList())) {
            final Player player = (Player) event.getView().getPlayer();
            ItemStack saddle = null;
            for (final ItemStack item : event.getInventory().getMatrix())
                if (item.getType() == Material.SADDLE) saddle = item;
            saddle = Sddls.signSaddle(saddle, player);
            event.getInventory().setResult(saddle);
        }
    }
}
 
开发者ID:piratjsk,项目名称:Sddls,代码行数:15,代码来源:SigningListener.java

示例9: fromBukkitRecipe

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
public static CraftShapelessRecipe fromBukkitRecipe(ShapelessRecipe recipe) {
    if (recipe instanceof CraftShapelessRecipe) {
        return (CraftShapelessRecipe) recipe;
    }
    CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getKey(), recipe.getResult());
    for (ItemStack ingred : recipe.getIngredientList()) {
        ret.addIngredient(ingred.getType(), ingred.getDurability());
    }
    return ret;
}
 
开发者ID:MagicDroidX,项目名称:Brynhildr,代码行数:11,代码来源:CraftShapelessRecipe.java

示例10: accept

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
public static <T> T accept(Recipe recipe, RecipeVisitor<T> visitor) {
    if (recipe instanceof ShapedRecipe) {
        ShapedRecipe shapedRecipe = (ShapedRecipe) recipe;
        return visitor.visit(shapedRecipe);
    } else if (recipe instanceof ShapelessRecipe) {
        ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe;
        return visitor.visit(shapelessRecipe);
    } else if (recipe instanceof FurnaceRecipe) {
        FurnaceRecipe furnaceRecipe = (FurnaceRecipe) recipe;
        return visitor.visit(furnaceRecipe);
    }
    return visitor.visitOther(recipe);
}
 
开发者ID:sciolizer,项目名称:craftinomicon,代码行数:14,代码来源:RecipeAcceptor.java

示例11: getUncraftingRecipe

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
protected Recipe getUncraftingRecipe()
{
    ItemStack ingredient = getIngredient();
    if(ingredient == null) return null;
    ingredient = ingredient.clone();
    ingredient.setAmount(getMatterRatio());
    
    ShapelessRecipe recipe = new ShapelessRecipe(ingredient);
    recipe.addIngredient(makeItem(1).getData());
    return recipe;
}
 
开发者ID:zDevelopers,项目名称:BelovedBlocks,代码行数:12,代码来源:BelovedBlock.java

示例12: commandUse

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
public boolean commandUse(CommandSender sender, String[] args) {
    Variables var = Necessities.getVar();
    if (sender instanceof Player) {
        Material mat;
        Player p = (Player) sender;
        if (args.length == 0) {
            p.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You must enter an item to craft.");
            return true;
        }
        mat = Material.fromString(args[0]);
        if (Bukkit.getRecipesFor(mat.getBukkitMaterial().toItemStack(1)).isEmpty()) {
            p.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "There are no recipes to craft that item.");
            return true;
        }
        HashMap<ItemStack, Integer> items = new HashMap<>();
        Recipe r = Bukkit.getRecipesFor(mat.getBukkitMaterial().toItemStack(1)).get(0);
        if (r instanceof ShapedRecipe) {
            ShapedRecipe s = (ShapedRecipe) r;
            for (Character c : s.getIngredientMap().keySet())
                if (s.getIngredientMap().get(c) != null)
                    items.put(s.getIngredientMap().get(c), items.containsKey(s.getIngredientMap().get(c)) ? items.get(s.getIngredientMap().get(c)) + 1 : 1);
        } else if (r instanceof ShapelessRecipe)
            for (ItemStack i : ((ShapelessRecipe) r).getIngredientList())
                items.put(i, items.containsKey(i) ? items.get(i) + 1 : 1);
        for (Map.Entry<ItemStack, Integer> itemStackIntegerEntry : items.entrySet())
            Bukkit.broadcastMessage(itemStackIntegerEntry.getValue() + " " + itemStackIntegerEntry.getKey().getType().toString());
        Bukkit.broadcastMessage("results in " + r.getResult().getAmount() + ' ' + r.getResult().getType().toString());
    } else
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You must be a player to craft items.");
    return true;
}
 
开发者ID:pupnewfster,项目名称:Necessities,代码行数:32,代码来源:CmdCraft.java

示例13: addAllRecipes

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
static void addAllRecipes (FileConfiguration config) {
	
	if (config.getBoolean("allowFleshSmelt")) {
		Bukkit.addRecipe(new FurnaceRecipe(new ItemStack(Material.LEATHER),Material.ROTTEN_FLESH));
	}
	
	if (config.getBoolean("allowJerky")){
		ShapelessRecipe jerky = new ShapelessRecipe(new ItemStack(Material.RAW_BEEF));
		jerky.addIngredient(2, Material.ROTTEN_FLESH);
		jerky.addIngredient(Material.SUGAR);
		Bukkit.addRecipe(jerky);		
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:14,代码来源:BetterRecipes.java

示例14: removeAllRecipes

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
static void removeAllRecipes() {
	Recipe recipe;
	
	// Check iterator for any of our recipes, if so, remove them
	Iterator<Recipe> iter = Bukkit.recipeIterator();
	while (iter.hasNext()) {
		recipe = iter.next();
		
		// Check if this Recipe is one of the ones we are responsible for
		// First, Furnace Recipes
		try {
			if (recipe instanceof FurnaceRecipe) {
				if ((Material.LEATHER == recipe.getResult().getType()) &&
					(Material.ROTTEN_FLESH == ((FurnaceRecipe) recipe).getInput().getType())){
						iter.remove();
				}
			}
			
			// Check for our Shapeless Recipes
			if (recipe instanceof ShapelessRecipe) {
				if (Material.RAW_BEEF == recipe.getResult().getType()) {
					List<ItemStack> ingredients = ((ShapelessRecipe) recipe).getIngredientList();
					if (3 == ingredients.size() &&
						ingredients.contains(new ItemStack(Material.ROTTEN_FLESH)) &&
						ingredients.contains(new ItemStack(Material.SUGAR))) {
						iter.remove();
					}
				}
			}
		}
		catch (NullPointerException e) {
			System.out.print("[ERROR]: Failed to process Recipe iterator");
			e.printStackTrace();
			// Don't rethrow, attempt recovery
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:38,代码来源:BetterRecipes.java

示例15: collect

import org.bukkit.inventory.ShapelessRecipe; //导入依赖的package包/类
Transaction collect(ShapelessRecipe recipe) {
    List<ItemStack> ingredients = recipe.getIngredientList();
    List<ItemStack> collected = new ArrayList<ItemStack>(ingredients.size());
    INGREDIENTS: for (ItemStack ingredient : ingredients) {
        for (ItemStack item : collected) {
            if (ItemUtils.itemEqualsTypeAndData(item, ingredient)) {
                item.setAmount(item.getAmount() + ingredient.getAmount());
                continue INGREDIENTS;
            }
        }
        collected.add(ingredient);
    }
    return new Transaction(collected, recipe.getResult());
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:15,代码来源:RecipeVerifier.java


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