Search in sources :

Example 1 with ChestInventory

use of org.lanternpowered.server.inventory.vanilla.block.ChestInventory in project LanternServer by LanternPowered.

the class CommandOpenTestContainer method createShulkerBox.

private static ItemStack createShulkerBox() {
    final ChestInventory inventory = VanillaInventoryArchetypes.CHEST.build();
    inventory.offer(new LanternItemStack(BlockTypes.REDSTONE_BLOCK, 64));
    inventory.offer(new LanternItemStack(BlockTypes.HOPPER, 64));
    // Create the pumpkin stacks
    LanternItemStack itemStack = new LanternItemStack(BlockTypes.LIT_PUMPKIN, 20);
    inventory.offer(itemStack);
    // Create the shulker box
    itemStack = new LanternItemStack(BlockTypes.BLACK_SHULKER_BOX);
    itemStack.tryOffer(LanternKeys.INVENTORY_SNAPSHOT, InventorySnapshot.ofInventory(inventory));
    return itemStack;
}
Also used : ChestInventory(org.lanternpowered.server.inventory.vanilla.block.ChestInventory) LanternItemStack(org.lanternpowered.server.inventory.LanternItemStack)

Example 2 with ChestInventory

use of org.lanternpowered.server.inventory.vanilla.block.ChestInventory in project LanternServer by LanternPowered.

the class CommandOpenTestContainer method completeSpec.

@Override
public void completeSpec(PluginContainer pluginContainer, CommandSpec.Builder specBuilder) {
    specBuilder.executor((src, args) -> {
        if (!(src instanceof Player)) {
            throw new CommandException(t("Only players may use this command."));
        }
        final ChestInventory inventory = VanillaInventoryArchetypes.CHEST.build();
        /*
                    inventory.offer(new LanternItemStack(BlockTypes.BEDROCK, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.GLASS, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.STONE, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.SAND, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.DIRT, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.GRASS, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.PLANKS, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.LOG, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.LOG2, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.SAPLING, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.STONE_SLAB, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.STONE_SLAB2, 64));
                    inventory.offer(new LanternItemStack(BlockTypes.ENDER_CHEST, 5));
                    inventory.offer(new LanternItemStack(BlockTypes.CHEST, 5));
                    */
        inventory.offer(createShulkerBox());
        LanternItemStack itemStack = new LanternItemStack(ItemTypes.COAL, 51);
        itemStack.offer(Keys.COAL_TYPE, CoalTypes.CHARCOAL);
        inventory.offer(itemStack.copy());
        itemStack.offer(Keys.DISPLAY_NAME, Text.of("Awesome Charcoal"));
        itemStack.offer(Keys.ITEM_ENCHANTMENTS, Collections.singletonList(Enchantment.of(EnchantmentTypes.POWER, 2)));
        inventory.offer(itemStack);
        itemStack = new LanternItemStack(ItemTypes.LOG, 64);
        itemStack.offer(Keys.TREE_TYPE, TreeTypes.JUNGLE);
        inventory.offer(itemStack);
        // Custom potions
        inventory.offer(createCustomPotion("Potion of Glowing", Color.ofRgb(245, 255, 68), PotionEffect.of(PotionEffectTypes.GLOWING, 0, 500)));
        inventory.offer(createCustomPotion("Potion of Bad Luck", Color.ofRgb(130, 91, 55), PotionEffect.of(PotionEffectTypes.UNLUCK, 0, 500)));
        inventory.offer(createCustomPotion("Potion of Invisibility", Color.ofRgb(120, 255, 68), PotionEffect.of(PotionEffectTypes.INVISIBILITY, 0, 500)));
        inventory.offer(createCustomPotion("Potion of Levitation", Color.ofRgb(120, 255, 68), PotionEffect.of(PotionEffectTypes.LEVITATION, 0, 500)));
        inventory.offer(createCustomPotion("Potion of Negative Levitation", Color.ofRgb(120, 255, 68), PotionEffect.of(PotionEffectTypes.LEVITATION, -5, 500)));
        inventory.offer(createCustomPotion("Potion of Negative Levitation", Color.ofRgb(120, 255, 68), PotionEffect.of(PotionEffectTypes.LEVITATION, -10, 500)));
        ((Player) src).openInventory(inventory);
        return CommandResult.success();
    });
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) ChestInventory(org.lanternpowered.server.inventory.vanilla.block.ChestInventory) CommandException(org.spongepowered.api.command.CommandException) LanternItemStack(org.lanternpowered.server.inventory.LanternItemStack)

Aggregations

LanternItemStack (org.lanternpowered.server.inventory.LanternItemStack)2 ChestInventory (org.lanternpowered.server.inventory.vanilla.block.ChestInventory)2 CommandException (org.spongepowered.api.command.CommandException)1 Player (org.spongepowered.api.entity.living.player.Player)1