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

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

Go to download

A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.

There is a newer version: 1.6.0.1-PN
Show newest version
package cn.nukkit.inventory;

import cn.nukkit.item.Item;

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

public class RepairRecipe implements Recipe {
    
    private final Item result;
    private final List ingredients;
    private final InventoryType inventoryType;
    
    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();
    }
    
    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;
    }
    
    public InventoryType getInventoryType() {
        return inventoryType;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy