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);
}
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);
}
}
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);
}
}
}
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"));
}
}
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;
}
Aggregations