On the slot in the stock


#1

Hello!
I customize the inventory and use inventory.offer (itemstack); add item to the inventory. But how do I add something to the specified slot?I customize the inventory and use inventory.offer (itemstack); add item to the inventory. But how do I add something to the specified slot?
Thank you first!

1234
For example: how to add an apple to the position of diamond sword?


It’s my code.
The code at the red line can not be used. Which way should I use?


#2

Use SlotPos#of instead of new SlotPos()!
It is not the same.

inv.query(QueryOperationTypes.INVENTORY_PROPERTY.of(SlotPos.of(1, 1)))


#4

Thanks very much!!
This code is very useful to me…


#5

So how do I get the location of the slot?
Thanks again!!


#6
SlotPos pos = slot.getProperty(SlotPos.class, SlotPos.getDefaultKey(SlotPos.class)).get();

#7

Unfortunately。 This method looks like it can’t be used in a click event


#8

… why wouldn’t it be able to be used in a click event? Methods are methods are methods.


#9

pos.getX();
pos.getY;
This method does not return to the slot position…


#10

I don’t understand what you are saying. You are passing getTargetInventory() where I’ve written slot, right?


#11

I just want to get the coordinates of a slot simply. For example: (1, 6)


#12

So you get the SlotPos from the slot, and you can get the x and y coordinate from that.