Search in sources :

Example 1 with Drink

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Drink(net.tropicraft.core.common.drinks.Drink) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with Drink

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);
}
Also used : Ingredient(net.tropicraft.core.common.drinks.Ingredient) Drink(net.tropicraft.core.common.drinks.Drink) ItemStack(net.minecraft.item.ItemStack)

Example 3 with Drink

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);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) Drink(net.tropicraft.core.common.drinks.Drink) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 4 with Drink

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());
}
Also used : Ingredient(net.tropicraft.core.common.drinks.Ingredient) Drink(net.tropicraft.core.common.drinks.Drink) ItemStack(net.minecraft.world.item.ItemStack)

Example 5 with Drink

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);
        }
    }
}
Also used : Drink(net.tropicraft.core.common.drinks.Drink) Component(net.minecraft.network.chat.Component) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

Drink (net.tropicraft.core.common.drinks.Drink)13 Nonnull (javax.annotation.Nonnull)5 ItemStack (net.minecraft.item.ItemStack)5 ItemStack (net.minecraft.world.item.ItemStack)5 Ingredient (net.tropicraft.core.common.drinks.Ingredient)4 LinkedList (java.util.LinkedList)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 ListTag (net.minecraft.nbt.ListTag)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Component (net.minecraft.network.chat.Component)1 ActionResult (net.minecraft.util.ActionResult)1 EnumActionResult (net.minecraft.util.EnumActionResult)1 InteractionResultHolder (net.minecraft.world.InteractionResultHolder)1 Player (net.minecraft.world.entity.player.Player)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 DrinkMixerBlockEntity (net.tropicraft.core.common.block.tileentity.DrinkMixerBlockEntity)1 TileEntityDrinkMixer (net.tropicraft.core.common.block.tileentity.TileEntityDrinkMixer)1