Java Code Examples for cn.nukkit.item.Item#setLore()

The following examples show how to use cn.nukkit.item.Item#setLore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockShulkerBoxUndyed.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item toItem() {
    Item item = Item.get(Item.SHULKER_BOX, this.meta);
    BlockEntity blockEntity = this.level.getBlockEntity(this);
    if (blockEntity instanceof BlockEntityShulkerBox) {
        item.setNamedTag(blockEntity.namedTag);
        List<String> lore = new ArrayList<>();
        int count = 0;
        Collection<Item> items = ((BlockEntityShulkerBox) blockEntity).getInventory().getContents().values();
        for (Item i : items) {
            lore.add(i.getName() + " x" + i.getCount());
            ++count;
            if (count == 5 && items.size() - count > 0){
                lore.add("and " + (items.size() - count) + " more...");
                break;
            }
        }
        item.setLore((String[])lore.toArray(new String[lore.size()]));
    }
    return item;
}
 
Example 2
Source File: BlockShulkerBox.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Item toItem() {
    Item item = Item.get(Item.SHULKER_BOX, this.meta);
    BlockEntity blockEntity = this.level.getBlockEntity(this);
    if (blockEntity instanceof BlockEntityShulkerBox) {
        item.setNamedTag(blockEntity.namedTag);
        List<String> lore = new ArrayList<>();
        int count = 0;
        Collection<Item> items = ((BlockEntityShulkerBox) blockEntity).getInventory().getContents().values();
        for (Item i : items) {
            lore.add(i.getName() + " x" + i.getCount());
            ++count;
            if (count == 5 && items.size() - count > 0){
                lore.add("and " + (items.size() - count) + " more...");
                break;
            }
        }
        item.setLore((String[])lore.toArray(new String[lore.size()]));
    }
    return item;
}