Package org.bukkit.inventory

Examples of org.bukkit.inventory.Recipe


   
    // Get the output if that item was smelted
    ItemStack result = null;
    Iterator<Recipe> iter = Bukkit.recipeIterator();
    while (iter.hasNext()){
      Recipe recipe = iter.next();
      if (recipe instanceof FurnaceRecipe){
        if (((FurnaceRecipe) recipe).getInput().getType() == player.getItemInHand().getType()){
          result = recipe.getResult();
        }
      }
    }
   
    if (result != null){
View Full Code Here


        CraftingInventory inv = event.getInventory();
       
        if (!(inv instanceof CraftingInventory) || !event.getSlotType().equals(SlotType.RESULT))
            return;
       
        Recipe recipe = event.getRecipe();
       
        if (recipe == null)
            return;
       
        if (!(event.getWhoClicked() instanceof Player))
            return;
       
        Player player = (Player) event.getWhoClicked();
       
        ItemStack resultStack = recipe.getResult();
       
        if (resultStack == null)
            return;
       
        if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
View Full Code Here

        if (recipes.isEmpty()) {
            return quantity;
        }

        Recipe recipe = recipes.get(0);

        if (recipe instanceof ShapelessRecipe) {
            for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
                if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
                    quantity += ingredient.getAmount();
View Full Code Here

        inventory.setResult(callEvent.getDisplayResult());
       
        return;
      }
     
      Recipe craftedRecipe = event.getRecipe();
     
      if(craftedRecipe == null)
        return;
     
      ItemStack craftedResult = craftedRecipe.getResult();
     
      if(!RecipeManager.recipes.isCustomRecipe(craftedResult))
        return;
     
      if(craftedRecipe instanceof ShapedRecipe)
View Full Code Here

    try
    {
      if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
        return;
     
      Recipe craftRecipe = event.getRecipe();
     
      if(craftRecipe == null)
        return;
     
      ItemStack craftResult = craftRecipe.getResult();
     
      if(!RecipeManager.recipes.isCustomRecipe(craftResult))
        return;
     
      final Player player = (event.getWhoClicked() == null ? null : (Player)event.getWhoClicked());
View Full Code Here

    /**
     * Adds a recipe to the manager.
     */
    public boolean addRecipe(RecipeManager.Recipe r) {
        try {
            Recipe sh = null;

            if (r.getType() == RecipeManager.RecipeType.SHAPELESS) {
                sh = new ShapelessRecipe(r.getResult().getItemStack());
                for (CraftingItemStack is : r.getIngredients())
                    ((ShapelessRecipe) sh).addIngredient(is.getItemStack().getAmount(), is.getItemStack().getData());
View Full Code Here

        if (recipe == null) {

            Iterator<Recipe> recipes = Bukkit.recipeIterator();
            try {
                while (recipes.hasNext()) {
                    Recipe temprecipe = recipes.next();
                    if (isValidRecipe(temprecipe, inv)) {
                        recipe = temprecipe;
                    }
                }
            } catch (Exception e) {
View Full Code Here

    @Override
    public void setItem(int index, ItemStack item) {
        super.setItem(index, item);

        if (index != RESULT_SLOT) {
            Recipe recipe = getRecipe();
            if (recipe == null) {
                super.setItem(RESULT_SLOT, null);
            } else {
                super.setItem(RESULT_SLOT, recipe.getResult());
            }
        }
    }
View Full Code Here

     * Remove a layer of items from the inventory according to the current recipe.
     */
    public void craft() {
        ItemStack[] matrix = getMatrix();
        CraftingManager cm = ((GlowServer) Bukkit.getServer()).getCraftingManager();
        Recipe recipe = cm.getCraftingRecipe(matrix);

        if (recipe != null) {
            cm.removeItems(matrix, recipe);
            setMatrix(matrix);
        }
View Full Code Here

TOP

Related Classes of org.bukkit.inventory.Recipe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.