Search in sources :

Example 1 with MessageSyncSeedBagSortMode

use of com.infinityraider.agricraft.network.MessageSyncSeedBagSortMode 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

ItemSeedBag (com.infinityraider.agricraft.content.tools.ItemSeedBag)1 MessageSyncSeedBagSortMode (com.infinityraider.agricraft.network.MessageSyncSeedBagSortMode)1 ItemStack (net.minecraft.item.ItemStack)1 IFormattableTextComponent (net.minecraft.util.text.IFormattableTextComponent)1 StringTextComponent (net.minecraft.util.text.StringTextComponent)1