Search in sources :

Example 11 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class JournalDataDrawerMissing method drawRightSheet.

@Override
public void drawRightSheet(IAgriJournalItem.IPage page, IPageRenderContext context, MatrixStack transforms, ItemStack stack, IAgriJournalItem journal) {
    StringTextComponent text = new StringTextComponent("Missing Journal Data Drawer: " + page.getDataDrawerId().toString());
    context.drawText(transforms, text, 0, 0);
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 12 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class ItemToolTipHandler method addJournalTooltip.

/**
 * Adds tooltips to items that are journals (implementing ITrowel).
 */
@SubscribeEvent
@SuppressWarnings("unused")
public void addJournalTooltip(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    if (!stack.isEmpty() && stack.getItem() instanceof IAgriJournalItem) {
        IAgriJournalItem journal = (IAgriJournalItem) stack.getItem();
        int count = journal.getDiscoveredSeeds(stack).size();
        event.getToolTip().add(new StringTextComponent("" + count + " ").appendSibling(AgriToolTips.JOURNAL_SEEDS));
        event.getToolTip().add(AgriToolTips.JOURNAL_USE_1);
        event.getToolTip().add(AgriToolTips.JOURNAL_USE_2);
    }
}
Also used : StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack) IAgriJournalItem(com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 13 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class ItemToolTipHandler method addSeedBagTooltip.

/**
 * Adds tooltips to the seed bag (we must do this here to avoid the enchantment tool tip)
 */
@SubscribeEvent
@SuppressWarnings("unused")
public void addSeedBagTooltip(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    if (stack.getItem() instanceof ItemSeedBag) {
        ItemSeedBag bag = (ItemSeedBag) stack.getItem();
        ItemSeedBag.Contents contents = bag.getContents(stack);
        if (bag.isActivated(stack)) {
            // Remove previous tooltip
            if (event.getToolTip().size() > 0) {
                ITextComponent name = event.getToolTip().get(0);
                event.getToolTip().clear();
                event.getToolTip().add(name);
            }
            // Description
            event.getToolTip().add(AgriToolTips.SEED_BAG_ACTIVE);
            event.getToolTip().add(AgriToolTips.EMPTY_LINE);
            // Contents
            if (contents.getPlant().isPlant()) {
                event.getToolTip().add(new StringTextComponent("").appendSibling(AgriToolTips.SEED_BAG_CONTENTS).appendSibling(new StringTextComponent(" " + contents.getCount() + " ")).appendSibling(contents.getPlant().getSeedName()));
            } else {
                event.getToolTip().add(AgriToolTips.SEED_BAG_EMPTY);
            }
            // Sorter
            event.getToolTip().add(new StringTextComponent("").appendSibling(AgriToolTips.SEED_BAG_SORTER).appendSibling(new StringTextComponent(" ")).appendSibling(contents.getSorter().getName()));
            event.getToolTip().add(AgriToolTips.EMPTY_LINE);
            // Usage
            if (ModuleKeyboard.getInstance().isKeyPressed(Minecraft.getInstance().gameSettings.keyBindSneak)) {
                event.getToolTip().add(new StringTextComponent("").mergeStyle(TextFormatting.DARK_GRAY).appendSibling(AgriToolTips.SEED_BAG_MAIN_HAND));
                event.getToolTip().add(new StringTextComponent("").mergeStyle(TextFormatting.DARK_GRAY).appendSibling(AgriToolTips.SEED_BAG_OFF_HAND));
                event.getToolTip().add(new StringTextComponent("").mergeStyle(TextFormatting.DARK_GRAY).appendSibling(AgriToolTips.SEED_BAG_SCROLLING));
            } else {
                event.getToolTip().add(new StringTextComponent("").mergeStyle(TextFormatting.DARK_GRAY).appendSibling(AgriToolTips.SNEAK_INFO));
            }
        } else {
            event.getToolTip().add(AgriToolTips.SEED_BAG_INACTIVE_1);
            event.getToolTip().add(AgriToolTips.SEED_BAG_INACTIVE_2);
        }
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack) ItemSeedBag(com.infinityraider.agricraft.content.tools.ItemSeedBag) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 14 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class AgriWailaIrrigationBlockInfoProvider method appendBody.

@Override
public void appendBody(List<ITextComponent> tooltip, IDataAccessor accessor, IPluginConfig config) {
    TileEntity tile = accessor.getTileEntity();
    if (tile instanceof TileEntityIrrigationComponent) {
        if (tile instanceof TileEntityIrrigationChannel) {
            TileEntityIrrigationChannel channel = (TileEntityIrrigationChannel) tile;
            if (channel.hasValve()) {
                if (channel.isOpen()) {
                    tooltip.add(AgriToolTips.VALVE_INFO_OPEN);
                } else {
                    tooltip.add(AgriToolTips.VALVE_INFO_CLOSED);
                }
            }
        }
        TileEntityIrrigationComponent component = (TileEntityIrrigationComponent) tile;
        tooltip.add(new StringTextComponent(component.getContent() + " / " + component.getCapacity() + " mB"));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityIrrigationChannel(com.infinityraider.agricraft.content.irrigation.TileEntityIrrigationChannel) StringTextComponent(net.minecraft.util.text.StringTextComponent) TileEntityIrrigationComponent(com.infinityraider.agricraft.content.irrigation.TileEntityIrrigationComponent)

Example 15 with StringTextComponent

use of net.minecraft.util.text.StringTextComponent in project AgriCraft by AgriCraft.

the class SeedBagScrollHandler method tryCycleSortMode.

public boolean tryCycleSortMode(Hand hand, int delta) {
    ItemStack stack = this.getPlayer().getHeldItem(hand);
    if (stack.getItem() instanceof ItemSeedBag) {
        ItemSeedBag bag = (ItemSeedBag) stack.getItem();
        if (bag.incrementSorter(stack, delta)) {
            new MessageSyncSeedBagSortMode(hand, bag.getContents(stack).getSorterIndex()).sendToServer();
            SeedBagShakeHandler.getInstance().shake(hand);
            ItemSeedBag.Contents contents = bag.getContents(stack);
            IFormattableTextComponent message = new StringTextComponent("").appendSibling(contents.getSorter().describe()).appendSibling(new StringTextComponent(", ")).appendSibling(AgriToolTips.MSG_SEED_BAG_SHAKE);
            if (contents.getCount() <= 0) {
                message.appendSibling(new StringTextComponent(" ")).appendSibling(AgriToolTips.MSG_SEED_BAG_EMPTY);
            }
            AgriCraft.instance.getClientPlayer().sendMessage(message, Util.DUMMY_UUID);
            return true;
        }
    }
    return false;
}
Also used : MessageSyncSeedBagSortMode(com.infinityraider.agricraft.network.MessageSyncSeedBagSortMode) StringTextComponent(net.minecraft.util.text.StringTextComponent) IFormattableTextComponent(net.minecraft.util.text.IFormattableTextComponent) ItemStack(net.minecraft.item.ItemStack) ItemSeedBag(com.infinityraider.agricraft.content.tools.ItemSeedBag)

Aggregations

StringTextComponent (net.minecraft.util.text.StringTextComponent)31 ItemStack (net.minecraft.item.ItemStack)17 CompoundNBT (net.minecraft.nbt.CompoundNBT)7 TileEntity (net.minecraft.tileentity.TileEntity)5 Nonnull (javax.annotation.Nonnull)4 BlockPos (net.minecraft.util.math.BlockPos)4 ITextComponent (net.minecraft.util.text.ITextComponent)4 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)4 IGenericDataStorage (com.cjm721.overloaded.storage.IGenericDataStorage)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 IEnergyStorage (net.minecraftforge.energy.IEnergyStorage)3 TileBPMicroblock (com.bluepowermod.tile.TileBPMicroblock)2 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)2 ItemSeedBag (com.infinityraider.agricraft.content.tools.ItemSeedBag)2 BlockState (net.minecraft.block.BlockState)2 Minecraft (net.minecraft.client.Minecraft)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2