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;
}
java类org.bukkit.inventory.ShapelessRecipe的实例源码
CraftingModule.java 文件源码
项目:ProjectAres
阅读 20
收藏 0
点赞 0
评论 0
UpgradeItem.java 文件源码
项目:StarQuestCode
阅读 22
收藏 0
点赞 0
评论 0
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);
}
RecipeFeature.java 文件源码
项目:ultrahardcore
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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);
}
InjectorManager.java 文件源码
项目:VisloBlock
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
WaywardItems.java 文件源码
项目:Wayward
阅读 17
收藏 0
点赞 0
评论 0
@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);
}
DrinkManager.java 文件源码
项目:Wayward
阅读 23
收藏 0
点赞 0
评论 0
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);
}
CraftShapelessRecipe.java 文件源码
项目:Uranium
阅读 22
收藏 0
点赞 0
评论 0
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;
}
SigningListener.java 文件源码
项目:Sddls
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
}
}
CraftShapelessRecipe.java 文件源码
项目:ThermosRebased
阅读 22
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:Brynhildr
阅读 22
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:Thermos
阅读 24
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:KCauldron
阅读 20
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:CauldronGit
阅读 23
收藏 0
点赞 0
评论 0
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;
}
RecipeAcceptor.java 文件源码
项目:craftinomicon
阅读 30
收藏 0
点赞 0
评论 0
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);
}
CraftShapelessRecipe.java 文件源码
项目:Cauldron-Old
阅读 20
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:Cauldron-Reloaded
阅读 24
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:FFoKC
阅读 20
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:CraftBukkit
阅读 20
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:Craftbukkit
阅读 21
收藏 0
点赞 0
评论 0
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;
}
BelovedBlock.java 文件源码
项目:BelovedBlocks
阅读 21
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:Almura-Server
阅读 20
收藏 0
点赞 0
评论 0
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;
}
CraftShapelessRecipe.java 文件源码
项目:Tweakkit-Server
阅读 19
收藏 0
点赞 0
评论 0
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;
}
CmdCraft.java 文件源码
项目:Necessities
阅读 28
收藏 0
点赞 0
评论 0
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;
}
BetterRecipes.java 文件源码
项目:StarQuestCode
阅读 33
收藏 0
点赞 0
评论 0
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);
}
}
BetterRecipes.java 文件源码
项目:StarQuestCode
阅读 21
收藏 0
点赞 0
评论 0
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
}
}
}
RecipeVerifier.java 文件源码
项目:StarQuestCode
阅读 19
收藏 0
点赞 0
评论 0
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());
}
RecipeVerifier.java 文件源码
项目:StarQuestCode
阅读 21
收藏 0
点赞 0
评论 0
/**
* Returns true if the recipe contained in this verifier matches the given
* {@link ShapelessRecipe}.
*
* @param recipe
* @return True if the recipe was verified.
*/
boolean verify(ShapelessRecipe recipe) {
List<ItemStack> ingredients = recipe.getIngredientList();
for (int i = 0; i < rows; i++) {
RECIPEITEM: for (int j = 0; j < columns; j++) {
ItemStack recipeItem = matrix[i][j];
if (recipeItem == null)
continue;
for (Iterator<ItemStack> it = ingredients.iterator(); it.hasNext();) {
ItemStack ingredient = it.next();
if (ItemUtils.recipeIngredientEqualsTypeAndData(ingredient, recipeItem)) {
int amount = ingredient.getAmount();
if (amount == 1)
it.remove();
else
ingredient.setAmount(amount - 1);
continue RECIPEITEM;
}
}
// An item in the matrix is not on the ingredient list.
return false;
}
}
// If the list of ingredients was exhausted, recipe verified.
if (ingredients.size() == 0)
return true;
// Unsatisfied ingredients remain.
return false;
}
TenJava.java 文件源码
项目:jshh-t2
阅读 22
收藏 0
点赞 0
评论 0
private void setupRecipes() {
List<ShapelessRecipe> shapeless = new ArrayList<>();
ShapelessRecipe pickaxeTwo = new ShapelessRecipe(new IronPickaxeTwo())
.addIngredient(1, Material.IRON_PICKAXE)
.addIngredient(3, Material.IRON_INGOT);
shapeless.add(pickaxeTwo);
for(ShapelessRecipe r : shapeless) {
getServer().addRecipe(r);
}
}
CraftShapelessRecipe.java 文件源码
项目:Cauldron
阅读 18
收藏 0
点赞 0
评论 0
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;
}
ChimaeraWing.java 文件源码
项目:McMMOPlus
阅读 20
收藏 0
点赞 0
评论 0
public static ShapelessRecipe getChimaeraWingRecipe() {
Material ingredient = Config.getInstance().getChimaeraItem();
int amount = Config.getInstance().getChimaeraRecipeCost();
ShapelessRecipe chimeraWing = new ShapelessRecipe(getChimaeraWing(1));
chimeraWing.addIngredient(amount, ingredient);
return chimeraWing;
}