Search in sources :

Example 11 with Ingredient

use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.

the class CocktailItem method getIngredients.

public static Ingredient[] getIngredients(ItemStack stack) {
    if (!Drink.isDrink(stack.getItem()) || !stack.hasTag()) {
        return new Ingredient[0];
    }
    CompoundTag nbt = stack.getTag();
    ListTag tagList = nbt.getList("Ingredients", 10);
    Ingredient[] ingredients = new Ingredient[tagList.size()];
    for (int i = 0; i < tagList.size(); ++i) {
        final int ingredientID = (tagList.getCompound(i)).getByte("IngredientID");
        ingredients[i] = Ingredient.ingredientsList[ingredientID];
    }
    return ingredients;
}
Also used : Ingredient(net.tropicraft.core.common.drinks.Ingredient) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

Ingredient (net.tropicraft.core.common.drinks.Ingredient)11 Nonnull (javax.annotation.Nonnull)5 LinkedList (java.util.LinkedList)4 ItemStack (net.minecraft.item.ItemStack)4 Drink (net.tropicraft.core.common.drinks.Drink)4 CompoundTag (net.minecraft.nbt.CompoundTag)3 ListTag (net.minecraft.nbt.ListTag)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 ItemStack (net.minecraft.world.item.ItemStack)3 ArrayList (java.util.ArrayList)2 MixerRecipe (net.tropicraft.core.common.drinks.MixerRecipe)1