use of net.tropicraft.core.common.drinks.Drink in project Tropicraft by Tropicraft.
the class ItemCocktail method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World world, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) {
if (stack.getTagCompound() == null) {
return;
}
Drink drink = getDrink(stack);
if (drink != null) {
tooltip.add(TextFormatting.ITALIC + I18n.format(getUnlocalizedName() + ".name"));
}
NBTTagList ingredients = stack.getTagCompound().getTagList("Ingredients", 10);
for (int i = 0; i < ingredients.tagCount(); ++i) {
NBTTagCompound ingredient = (NBTTagCompound) ingredients.getCompoundTagAt(i);
// int count = ingredient.getShort("Count");
int id = ingredient.getByte("IngredientID");
String ingredientName = Ingredient.ingredientsList[id].getIngredient().getDisplayName();
int ingredientColor = Ingredient.ingredientsList[id].getColor();
// String lvl = StatCollector.translateToLocal("enchantment.level." + count);
// par3List.add(ingredientName + " " + lvl);
tooltip.add(ingredientName);
}
}
use of net.tropicraft.core.common.drinks.Drink 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.Drink in project Tropicraft by Tropicraft.
the class ItemCocktail method onItemRightClick.
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull World worldIn, @Nonnull EntityPlayer playerIn, @Nonnull EnumHand hand) {
ItemStack stack = playerIn.getHeldItem(hand);
Drink drink = getDrink(stack);
if (drink == null) {
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
playerIn.setActiveHand(hand);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
use of net.tropicraft.core.common.drinks.Drink 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());
}
use of net.tropicraft.core.common.drinks.Drink in project Tropicraft by Tropicraft.
the class CocktailItem method appendHoverText.
@Override
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
Drink drink = getDrink(stack);
if (drink == Drink.COCKTAIL && stack.hasTag() && stack.getTag().contains("Ingredients")) {
final ListTag ingredients = stack.getTag().getList("Ingredients", 10);
for (int i = 0; i < ingredients.size(); ++i) {
CompoundTag ingredient = ingredients.getCompound(i);
int id = ingredient.getByte("IngredientID");
Component ingredientName = Ingredient.ingredientsList[id].getDisplayName();
int ingredientColor = Ingredient.ingredientsList[id].getColor();
// String lvl = StatCollector.translateToLocal("enchantment.level." + count);
// par3List.add(ingredientName + " " + lvl);
tooltip.add(ingredientName);
}
}
}
Aggregations