use of org.spongepowered.api.item.inventory.menu.InventoryMenu in project SpongeCommon by SpongePowered.
the class InventoryTest method doFancyStuff.
private static void doFancyStuff(final PluginContainer plugin, final Player player) {
final GridInventory inv27Grid = player.inventory().query(PrimaryPlayerInventory.class).get().storage();
final Inventory inv27Slots = Inventory.builder().slots(27).completeStructure().plugin(plugin).build();
final Inventory inv27Slots2 = Inventory.builder().slots(27).completeStructure().plugin(plugin).build();
final ViewableInventory doubleMyInventory = ViewableInventory.builder().type(ContainerTypes.GENERIC_9X6.get()).grid(inv27Slots.slots(), Vector2i.from(9, 3), Vector2i.from(0, 0)).grid(inv27Slots2.slots(), Vector2i.from(9, 3), Vector2i.from(0, 3)).completeStructure().carrier(player).plugin(plugin).build();
final InventoryMenu menu = doubleMyInventory.asMenu();
menu.setReadOnly(true);
doubleMyInventory.set(0, ItemStack.of(ItemTypes.IRON_INGOT));
doubleMyInventory.set(8, ItemStack.of(ItemTypes.GOLD_INGOT));
doubleMyInventory.set(45, ItemStack.of(ItemTypes.EMERALD));
doubleMyInventory.set(53, ItemStack.of(ItemTypes.DIAMOND));
menu.registerSlotClick(new MySlotClickHandler(plugin, menu, doubleMyInventory));
Sponge.server().scheduler().submit(Task.builder().plugin(plugin).execute(() -> {
menu.open((ServerPlayer) player);
}).build());
}
Aggregations