下面列出了org.bukkit.Bukkit#addRecipe ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public GoldenHeadsModule() {
setId("GoldenHeads");
this.iconName = ICON_NAME;
this.icon.setType(Material.SKULL_ITEM);
this.icon.setDurability(PlayerHeadProvider.PLAYER_HEAD_DATA);
this.icon.setWeight(ModuleRegistry.CATEGORY_APPLES);
// register the new recipe
final ShapedRecipe modified = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1))
.shape("AAA", "ABA", "AAA")
.setIngredient('A', Material.GOLD_INGOT)
.setIngredient('B', Material.SKULL_ITEM, PlayerHeadProvider.PLAYER_HEAD_DATA);
Bukkit.addRecipe(modified);
}
@Override
public void registerRecipes() {
BaseDuctType<Pipe> pipeBaseDuctType = ductRegister.baseDuctTypeOf("pipe");
DuctType ductType;
ductType = pipeBaseDuctType.ductTypeOf("White");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "white_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "a a", " a "}, 'a', Material.GLASS));
ductType = pipeBaseDuctType.ductTypeOf("Blue");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "blue_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.LAPIS_LAZULI));
ductType = pipeBaseDuctType.ductTypeOf("Red");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "red_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', LegacyUtils.getInstance().getRedDye()));
ductType = pipeBaseDuctType.ductTypeOf("Yellow");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "yellow_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', LegacyUtils.getInstance().getYellowDye()));
ductType = pipeBaseDuctType.ductTypeOf("Green");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "green_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', LegacyUtils.getInstance().getGreenDye()));
ductType = pipeBaseDuctType.ductTypeOf("Black");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "black_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.INK_SAC));
ductType = pipeBaseDuctType.ductTypeOf("Golden");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "golden_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.GOLD_BLOCK));
ductType = pipeBaseDuctType.ductTypeOf("Iron");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "iron_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.IRON_BLOCK));
ductType = pipeBaseDuctType.ductTypeOf("Ice");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "ice_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.SNOW_BLOCK));
ductType = pipeBaseDuctType.ductTypeOf("Void");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "void_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.OBSIDIAN));
ductType = pipeBaseDuctType.ductTypeOf("Extraction");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "extraction_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Tag.PLANKS.getValues()));
ductType = pipeBaseDuctType.ductTypeOf("Crafting");
ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "crafting_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.CRAFTING_TABLE));
wrenchRecipe = itemService.createShapedRecipe(transportPipes, "wrench", itemService.getWrench(), new String[]{" a ", "aba", " a "}, 'a', Material.REDSTONE, 'b', Material.STICK);
Bukkit.addRecipe(wrenchRecipe);
}
public GoldenCarrotRecipeModule() {
setId("GoldenCarrotRecipe");
this.iconName = ICON_NAME;
this.icon.setType(Material.GOLDEN_CARROT);
this.icon.setWeight(ModuleRegistry.CATEGORY_RECIPIES);
// register the new recipe
final ShapedRecipe modified = new ShapedRecipe(new ItemStack(Material.GOLDEN_CARROT, 1))
.shape("AAA", "ABA", "AAA")
.setIngredient('A', Material.GOLD_INGOT)
.setIngredient('B', Material.CARROT_ITEM);
Bukkit.addRecipe(modified);
}
public GlisteringMelonRecipeModule() {
setId("GlisteringMelonRecipe");
this.iconName = ICON_NAME;
this.icon.setType(Material.SPECKLED_MELON);
this.icon.setWeight(ModuleRegistry.CATEGORY_RECIPIES);
final ShapelessRecipe modified = new ShapelessRecipe(new ItemStack(Material.SPECKLED_MELON, 1))
.addIngredient(1, Material.GOLD_BLOCK)
.addIngredient(1, Material.MELON);
Bukkit.addRecipe(modified);
}
@SuppressWarnings("unchecked")
public void register() {
//basic recipes
for (int c = 0; c < 16; c++) {
@SuppressWarnings("deprecation")
ShapedRecipe defaultBanners = new ShapedRecipe(new ItemStack(Carbon.injector().bannerItemMat, 1, (short) (15 - c))).shape(new String[] { "www", "www", " s " }).setIngredient('w', Material.WOOL, c).setIngredient('s', Material.STICK);
Bukkit.addRecipe(defaultBanners);
}
//patterns recipe
CraftingManager.getInstance().getRecipes().add(new RecipesBannerPatterns());
//copy recipe
CraftingManager.getInstance().getRecipes().add(new RecipesBannerCopy());
}
public void setDuctRecipe(Recipe ductRecipe) {
this.ductRecipe = ductRecipe;
Bukkit.addRecipe(ductRecipe);
}
@Deprecated
public CustomRecipe registerBukkitRecipe(ItemStack result) {
Recipe recipe = toBukkitRecipe(result);
Bukkit.addRecipe(recipe);
return this;
}
public CustomRecipe registerBukkitRecipe(NamespacedKey key, ItemStack result) {
Recipe recipe = toBukkitRecipe(key, result);
Bukkit.addRecipe(recipe);
return this;
}
@Override
protected void setUp()
{
ShapelessRecipe recipe = new ShapelessRecipe(new ItemStack(Material.ARROW,3)).addIngredient(Material.FLINT).addIngredient(Material.STICK);
Bukkit.addRecipe(recipe);
}
@Override
protected void onEnable() {
final boolean recipeExists = Iterators.any(Bukkit.recipeIterator(), IS_NOTCH_APPLE_RECIPE);
if (!recipeExists) Bukkit.addRecipe(NOTCH_APPLE_RECIPE);
}