[SOLVED] Inventory issue. Can`t set item to first slot

Why I cant set ItemStack to first slot in inventory?
This is how I create inventory:
Inventory inventory = Inventory.builder().of(InventoryArchetypes.CHEST).build(GWMCrates.getInstance());
This how I set items (0 elemt from list - Emerald):
System.out.println("0th decorative item: " + decorative_items.get(0)); for (int i = 0; i < 10; i++) { inventory.query(new SlotIndex(i)).set(decorative_items.get(i)); }
And what I got:

I tried set manuaaly created items:
inventory.query(new SlotIndex(0)).set(ItemStack.of(ItemTypes.APPLE, 2)); inventory.query(new SlotIndex(1)).set(ItemStack.of(ItemTypes.APPLE, 3));
And what I got:

What Im doing wrong?

OKay, it is my temporary solution:
/* I use it because when I use * inventory.query(new SlotIndex(0)).set(item); * All goes wrong! More about that: https://forums.spongepowered.org/t/19065 */ inventory.query(new SlotPos(0, 0)).set(decorative_items.get(0)); for (int i = 1; i < 10; i++) { inventory.query(new SlotIndex(i)).set(decorative_items.get(i)); }

SlotIndexes work great for me, here’s how I’m working with them.

OrderedInventory orderedInventory = this.inventory.query(OrderedInventory.class);
        this.buttons.forEach((index, inventoryButton) -> {
            Slot slot = orderedInventory.getSlot(SlotIndex.of(index)).orElseThrow(() -> new IllegalArgumentException("Invalid index for inventory button: " + index));
            slot.set(inventoryButton.getDisplay());
        });

I’ve noticed inventories can be very finicky to work with when dealing with just the base Inventory class. Depending on what you’re trying to do, you’ll probably have to query for a certain type of inventory.

Thank you, it works fine!
OrderedInventory ordered = inventory.query(OrderedInventory.class); for (int i = 0; i < 10; i++) { ordered.getSlot(new SlotIndex(i)).get().set(decorative_items.get(i)); }

I’m sorry, what? I do not understand you.

I am sorry. Is it just a chest? Or a plugin.

Its plugin, I could not set item to first slot of inventory using plugin.

Please give me the plugin’s link,let me try it frist :slight_smile:

Im developing this plugin, and this issue is closed, and plugin is not ready now :frowning:

ahha.You are making this plugin?

Yes, I making this plugin.

:joy:I am sorry.I amnot good at Programming. If you really can’t solve it, I will say in China Forums.:sweat_smile:

Its already solved.

I have questions.1.What can the plugin. 2.When will it come out?:grin:
And make an all-out effort.:slight_smile: