use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class ItemCocktail method makeCocktail.
@Nonnull
public static ItemStack makeCocktail(MixerRecipe recipe) {
ItemStack stack = new ItemStack(ItemRegistry.cocktail);
NBTTagCompound nbt = new NBTTagCompound();
Drink drink = recipe.getCraftingResult();
nbt.setByte("DrinkID", (byte) drink.drinkId);
NBTTagList tagList = new NBTTagList();
Ingredient primary = null;
List<Ingredient> additives = new LinkedList<Ingredient>();
for (Ingredient ingredient : recipe.getIngredients()) {
NBTTagCompound ingredientNbt = new NBTTagCompound();
ingredientNbt.setByte("IngredientID", (byte) ingredient.id);
tagList.appendTag(ingredientNbt);
if (ingredient.isPrimary()) {
primary = ingredient;
} else {
additives.add(ingredient);
}
}
nbt.setTag("Ingredients", tagList);
int color = primary == null ? DEFAULT_COLOR : primary.getColor();
for (Ingredient additive : additives) {
color = ColorMixer.getInstance().alphaBlendRGBA(color, additive.getColor(), additive.getAlpha());
}
nbt.setInteger("Color", color);
stack.setTagCompound(nbt);
return stack;
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class ItemCocktail method makeCocktail.
@Nonnull
public static ItemStack makeCocktail(Ingredient[] ingredients) {
ItemStack stack = new ItemStack(ItemRegistry.cocktail);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("DrinkID", (byte) 0);
NBTTagList tagList = new NBTTagList();
Ingredient primary = null;
List<Ingredient> additives = new LinkedList<Ingredient>();
for (Ingredient ingredient : ingredients) {
NBTTagCompound ingredientNbt = new NBTTagCompound();
ingredientNbt.setByte("IngredientID", (byte) ingredient.id);
tagList.appendTag(ingredientNbt);
if (ingredient.isPrimary()) {
primary = ingredient;
} else {
additives.add(ingredient);
}
}
nbt.setTag("Ingredients", tagList);
int color = primary == null ? DEFAULT_COLOR : primary.getColor();
for (Ingredient additive : additives) {
color = ColorMixer.getInstance().alphaBlendRGBA(color, additive.getColor(), additive.getAlpha());
}
nbt.setInteger("Color", color);
stack.setTagCompound(nbt);
return stack;
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class ItemCocktail method getIngredients.
public static Ingredient[] getIngredients(ItemStack stack) {
if (stack.getItem() != ItemRegistry.cocktail || !stack.hasTagCompound()) {
return new Ingredient[0];
}
NBTTagCompound nbt = stack.getTagCompound();
NBTTagList tagList = nbt.getTagList("Ingredients", 10);
Ingredient[] ingredients = new Ingredient[tagList.tagCount()];
for (int i = 0; i < tagList.tagCount(); ++i) {
int id = ((NBTTagCompound) tagList.getCompoundTagAt(i)).getByte("IngredientID");
ingredients[i] = Ingredient.ingredientsList[id];
}
return ingredients;
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class CocktailItem method makeCocktail.
@Nonnull
public static ItemStack makeCocktail(final NonNullList<ItemStack> itemStacks) {
// TODO fixme this is so ugly ugh
final ItemStack stack = new ItemStack(TropicraftItems.COCKTAILS.get(Drink.COCKTAIL).get());
CompoundTag nbt = new CompoundTag();
nbt.putByte("DrinkID", (byte) Drink.COCKTAIL.drinkId);
ListTag tagList = new ListTag();
List<Ingredient> ingredients = new ArrayList<>();
for (ItemStack ingredientStack : itemStacks) {
ingredients.addAll(Ingredient.listIngredients(ingredientStack));
}
Collections.sort(ingredients);
Ingredient primary = null;
List<Ingredient> additives = new LinkedList<>();
for (Ingredient ingredient : ingredients) {
CompoundTag ingredientNbt = new CompoundTag();
ingredientNbt.putByte("IngredientID", (byte) ingredient.id);
tagList.add(ingredientNbt);
if (ingredient.isPrimary()) {
primary = ingredient;
} else {
additives.add(ingredient);
}
}
nbt.put("Ingredients", tagList);
int color = primary == null ? DEFAULT_COLOR : primary.getColor();
for (Ingredient additive : additives) {
color = ColorMixer.getInstance().alphaBlendRGBA(color, additive.getColor(), additive.getAlpha());
}
nbt.putInt("Color", color);
stack.setTag(nbt);
return stack;
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class CocktailItem method makeCocktail.
@Nonnull
public static ItemStack makeCocktail(MixerRecipe recipe) {
final ItemStack stack = MixerRecipes.getItemStack(recipe.getCraftingResult());
CompoundTag nbt = new CompoundTag();
Drink drink = recipe.getCraftingResult();
nbt.putByte("DrinkID", (byte) drink.drinkId);
ListTag tagList = new ListTag();
Ingredient primary = null;
List<Ingredient> additives = new LinkedList<>();
for (Ingredient ingredient : recipe.getIngredients()) {
CompoundTag ingredientNbt = new CompoundTag();
ingredientNbt.putByte("IngredientID", (byte) ingredient.id);
tagList.add(ingredientNbt);
if (ingredient.isPrimary()) {
primary = ingredient;
} else {
additives.add(ingredient);
}
}
nbt.put("Ingredients", tagList);
int color = primary == null ? DEFAULT_COLOR : primary.getColor();
for (Ingredient additive : additives) {
color = ColorMixer.getInstance().alphaBlendRGBA(color, additive.getColor(), additive.getAlpha());
}
nbt.putInt("Color", color);
stack.setTag(nbt);
return stack;
}
Aggregations