All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.inventory.RepairRecipe Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.inventory;

import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.item.Item;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@PowerNukkitOnly
public class RepairRecipe implements Recipe {
    
    private final Item result;
    private final List ingredients;
    private final InventoryType inventoryType;

    @PowerNukkitOnly
    public RepairRecipe(InventoryType inventoryType, Item result, Collection ingredients) {
        this.inventoryType = inventoryType;
        this.result = result.clone();
        this.ingredients = new ArrayList<>();
    
        for (Item item : ingredients) {
            if (item.getCount() < 1) {
                throw new IllegalArgumentException("Recipe Ingredient amount was not 1 (value: " + item.getCount() + ")");
            }
            this.ingredients.add(item.clone());
        }
    }
    
    @Override
    public Item getResult() {
        return result.clone();
    }

    @PowerNukkitOnly
    public List getIngredientList() {
        List ingredients = new ArrayList<>();
        for (Item ingredient : this.ingredients) {
            ingredients.add(ingredient.clone());
        }
        
        return ingredients;
    }
    
    @Override
    public void registerToCraftingManager(CraftingManager manager) {
    
    }
    
    @Override
    public RecipeType getType() {
        return RecipeType.REPAIR;
    }

    @PowerNukkitOnly
    public InventoryType getInventoryType() {
        return inventoryType;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy