use of com.infinityraider.agricraft.content.tools.ItemSeedBag 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 com.infinityraider.agricraft.content.tools.ItemSeedBag 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