类org.bukkit.inventory.ShapelessRecipe源码实例Demo

下面列出了怎么用org.bukkit.inventory.ShapelessRecipe的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: PGM   文件: CraftingModule.java
public Recipe parseShapelessRecipe(MapFactory factory, Element elRecipe)
    throws InvalidXMLException {
  ShapelessRecipe recipe = new ShapelessRecipe(parseRecipeResult(factory, elRecipe));

  for (Element elIngredient : XMLUtils.getChildren(elRecipe, "ingredient", "i")) {
    SingleMaterialMatcher 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;
}
 
源代码2 项目: Kettle   文件: RecipeIterator.java
public Recipe next() {
    if (recipes.hasNext()) {
        removeFrom = recipes;
        IRecipe recipe = recipes.next();
        if (recipe instanceof ShapedRecipe || recipe instanceof ShapelessRecipe) {
            return recipe.toBukkitRecipe();
        } else {
            return new CraftCustomModRecipe(recipe);
        }
    } else {
        net.minecraft.item.ItemStack item;
        if (smeltingCustom.hasNext()) {
            removeFrom = smeltingCustom;
            item = smeltingCustom.next();
        } else {
            removeFrom = smeltingVanilla;
            item = smeltingVanilla.next();
        }

        CraftItemStack stack = CraftItemStack.asCraftMirror(FurnaceRecipes.instance().getSmeltingResult(item));

        return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item));
    }
}
 
源代码3 项目: ProjectAres   文件: CraftingModule.java
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;
}
 
源代码4 项目: ProRecipes   文件: RecipeShapeless.java
public void unregister(){
	Iterator<org.bukkit.inventory.Recipe> it = ProRecipes.getPlugin().getServer().recipeIterator();
	org.bukkit.inventory.Recipe recipe = null;
       while(it.hasNext())
       {
           recipe = it.next();
           
           	 if (recipe != null && recipe instanceof ShapelessRecipe)
                {
                	ShapelessRecipe b = (ShapelessRecipe)recipe;
                	if(ingredientCheck(b.getIngredientList(), registerer.getIngredientList())){
                		//it.remove();
                		break;
                	}
                	
                }
           	 recipe = null;
           	 
       }
       
       if(recipe != null){
       	 ProRecipes.getPlugin().mv.getChecker().removeRecipe(it, ((ShapelessRecipe)recipe));
       }
      
}
 
源代码5 项目: Thermos   文件: CraftServer.java
@Override
public boolean addRecipe(Recipe recipe) {
    CraftRecipe toAdd;
    if (recipe instanceof CraftRecipe) {
        toAdd = (CraftRecipe) recipe;
    } else {
        if (recipe instanceof ShapedRecipe) {
            toAdd = CraftShapedRecipe.fromBukkitRecipe((ShapedRecipe) recipe);
        } else if (recipe instanceof ShapelessRecipe) {
            toAdd = CraftShapelessRecipe.fromBukkitRecipe((ShapelessRecipe) recipe);
        } else if (recipe instanceof FurnaceRecipe) {
            toAdd = CraftFurnaceRecipe.fromBukkitRecipe((FurnaceRecipe) recipe);
        } else {
            return false;
        }
    }
    toAdd.addToCraftingManager();
    //net.minecraft.item.crafting.CraftingManager.getInstance().sort(); // Cauldron - mod recipes not necessarily sortable
    return true;
}
 
源代码6 项目: UHC   文件: RecipeUtil.java
/**
 * Check if the recipe has the given material in it.
 *
 * @param recipe   the recipe to check
 * @param mat the material to look for
 * @return true if found, false if not
 */
public static boolean hasRecipeGotMaterial(Recipe recipe, Material mat) {
    Collection<ItemStack> ingredients = null;

    if (recipe instanceof ShapedRecipe) {
        ingredients = ((ShapedRecipe) recipe).getIngredientMap().values();
    } else if (recipe instanceof ShapelessRecipe) {
        ingredients = ((ShapelessRecipe) recipe).getIngredientList();
    }

    if (null == ingredients) return false;

    for (final ItemStack stack : ingredients) {
        if (stack.getType() == mat) return true;
    }

    return false;
}
 
源代码7 项目: Slimefun4   文件: TestRecipeService.java
@Test
public void testShapelessRecipeShape() {
    MinecraftRecipeService service = new MinecraftRecipeService(plugin);

    Assertions.assertThrows(IllegalArgumentException.class, () -> service.getRecipeShape(null));

    NamespacedKey key = new NamespacedKey(plugin, "shapeless_test");
    ShapelessRecipe recipe = new ShapelessRecipe(key, new ItemStack(Material.TNT_MINECART));
    MaterialChoice choice = new MaterialChoice(Material.TNT);
    recipe.addIngredient(choice);

    server.addRecipe(recipe);
    service.refresh();

    Assertions.assertArrayEquals(new RecipeChoice[] { choice }, service.getRecipeShape(recipe));
}
 
源代码8 项目: Kettle   文件: CraftShapelessRecipe.java
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;
}
 
源代码9 项目: Transport-Pipes   文件: ItemService.java
public ShapelessRecipe createShapelessRecipe(TransportPipes transportPipes, String recipeKey, ItemStack resultItem, Material... ingredients) {
    ShapelessRecipe recipe = new ShapelessRecipe(new NamespacedKey(transportPipes, recipeKey), resultItem);
    for (int i = 0; i < ingredients.length; i += 2) {
        recipe.addIngredient(ingredients[i]);
    }
    return recipe;
}
 
源代码10 项目: Thermos   文件: CraftShapelessRecipe.java
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;
}
 
源代码11 项目: UHC   文件: GlisteringMelonRecipeModule.java
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);
}
 
源代码12 项目: AdditionsAPI   文件: CustomShapelessRecipe.java
@Override
public ShapelessRecipe toBukkitRecipe(ItemStack result) {
	return toBukkitRecipe(null, result);
}
 
源代码13 项目: ProRecipes   文件: Recipes.java
public void addConflict(RecipeShapeless rec, ShapelessRecipe re){
	conflictsShapeless.put(rec, re);
}
 
源代码14 项目: AnnihilationPro   文件: Archer.java
@Override
protected void setUp()
{
	ShapelessRecipe recipe = new ShapelessRecipe(new ItemStack(Material.ARROW,3)).addIngredient(Material.FLINT).addIngredient(Material.STICK);
	Bukkit.addRecipe(recipe);	
}
 
源代码15 项目: CardinalPGM   文件: Snowflakes.java
private List<DyeColor> getColors(Recipe recipe) {
    return recipe instanceof ShapedRecipe ? getColors(((ShapedRecipe) recipe).getIngredientMap().values())
            : recipe instanceof ShapelessRecipe ? getColors(((ShapelessRecipe) recipe).getIngredientList())
            : Lists.newArrayList();
}
 
 类所在包
 类方法
 同包方法