use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class TileEntityDrinkMixer method addToMixer.
public boolean addToMixer(@Nonnull ItemStack ingredient) {
if (this.ingredients.get(0).isEmpty()) {
if (ingredient.getItem() != ItemRegistry.cocktail) {
Ingredient i = findMatchingIngredient(ingredient);
// is as relevant anymore. Will leave it here just in case!
if (i == null) /* || !i.isPrimary()*/
{
return false;
}
}
this.ingredients.set(0, ingredient);
syncInventory();
return true;
} else if (this.ingredients.get(1).isEmpty()) {
if (ingredient.getItem() == ItemRegistry.cocktail) {
// all cocktails already contain one
return false;
}
Ingredient ing0 = findMatchingIngredient(this.ingredients.get(0));
Ingredient i = findMatchingIngredient(ingredient);
// See above comment about isPrimary()
if (i == null || /* || i.isPrimary()*/
ing0.id == i.id) {
return false;
}
this.ingredients.set(1, ingredient);
syncInventory();
return true;
} else if (this.ingredients.get(2).isEmpty()) {
if (ingredient.getItem() == ItemRegistry.cocktail) {
// all cocktails already contain one
return false;
}
Ingredient ing0 = findMatchingIngredient(this.ingredients.get(0));
Ingredient ing1 = findMatchingIngredient(this.ingredients.get(1));
Ingredient i = findMatchingIngredient(ingredient);
// See above comment about isPrimary()
if (i == null || /* || i.isPrimary()*/
ing0.id == i.id || ing1.id == i.id) {
return false;
}
this.ingredients.set(2, ingredient);
syncInventory();
return true;
} else {
return false;
}
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class DrinkMixerRegistry method getResult.
@Nonnull
public static ItemStack getResult(NonNullList<ItemStack> ingredients) {
for (MixerRecipe recipe : recipes) {
int validIngredientsFound = 0;
for (Ingredient recipeIngredient : recipe.getIngredients()) {
for (ItemStack mixerIngredient : ingredients) {
if (ItemStack.areItemStacksEqual(recipeIngredient.getIngredient(), mixerIngredient)) {
validIngredientsFound++;
break;
}
}
}
// Make sure to only count valid ingredients (non-empty) when getting size
if (validIngredientsFound == ingredients.stream().filter(i -> !i.isEmpty()).count()) {
return ItemCocktail.makeCocktail(recipe);
}
}
List<Ingredient> is = new ArrayList<Ingredient>();
for (ItemStack ingredientStack : ingredients) {
is.addAll(Ingredient.listIngredients(ingredientStack));
}
Collections.sort(is);
return ItemCocktail.makeCocktail(is.toArray(new Ingredient[is.size()]));
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class ItemCocktail method onFoodEaten.
public ItemStack onFoodEaten(ItemStack itemstack, World world, EntityPlayer player) {
world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, world.rand.nextFloat() * 0.1F + 0.9F);
for (Ingredient ingredient : getIngredients(itemstack)) {
ingredient.onDrink(player);
}
Drink drink = getDrink(itemstack);
if (drink != null) {
drink.onDrink(player);
}
return new ItemStack(ItemRegistry.bambooMug);
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class DrinkMixerBlockEntity method addToMixer.
public boolean addToMixer(@Nonnull ItemStack ingredient) {
if (ingredients.get(0).isEmpty()) {
if (!Drink.isDrink(ingredient.getItem())) {
Ingredient i = Ingredient.findMatchingIngredient(ingredient);
// is as relevant anymore. Will leave it here just in case!
if (i == null) /* || !i.isPrimary()*/
{
return false;
}
}
ingredients.set(0, ingredient);
syncInventory();
return true;
} else if (ingredients.get(1).isEmpty()) {
if (Drink.isDrink(ingredient.getItem())) {
// all cocktails already contain one
return false;
}
Ingredient ing0 = Ingredient.findMatchingIngredient(ingredients.get(0));
Ingredient i = Ingredient.findMatchingIngredient(ingredient);
// See above comment about isPrimary()
if (i == null || /* || i.isPrimary()*/
ing0.id == i.id) {
return false;
}
ingredients.set(1, ingredient);
syncInventory();
return true;
} else if (ingredients.get(2).isEmpty()) {
if (Drink.isDrink(ingredient.getItem())) {
// all cocktails already contain one
return false;
}
Ingredient ing0 = Ingredient.findMatchingIngredient(ingredients.get(0));
Ingredient ing1 = Ingredient.findMatchingIngredient(ingredients.get(1));
Ingredient i = Ingredient.findMatchingIngredient(ingredient);
// See above comment about isPrimary()
if (i == null || /* || i.isPrimary()*/
ing0.id == i.id || ing1.id == i.id) {
return false;
}
ingredients.set(2, ingredient);
syncInventory();
return true;
} else {
return false;
}
}
use of net.tropicraft.core.common.drinks.Ingredient in project Tropicraft by Tropicraft.
the class CocktailItem method onFoodEaten.
public ItemStack onFoodEaten(ItemStack itemstack, Level world, Player player) {
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
for (Ingredient ingredient : getIngredients(itemstack)) {
ingredient.onDrink(player);
}
Drink drink = getDrink(itemstack);
if (drink != null) {
drink.onDrink(player);
}
return new ItemStack(TropicraftItems.BAMBOO_MUG.get());
}
Aggregations