How do I set an ItemStack in an anvil inventory? I need the method to be supported for versions 1.8.8-1.14.4. I can create the inventory, but can't set items. This is what I have:
void open(Player player) {
Inventory createKitGUI = Bukkit.createInventory(null, InventoryType.ANVIL);
createKitGUI.setItem(1, new ItemStack(XMaterial.PAPER.parseMaterial()));
player.openInventory(createKitGUI);
}
I've tried setting in slots 0 and 1 but it doesn't work. 0 and 1 are the first 2 slots in the anvil inventory.
WHY YOU CANNOT DO THIS WITHOUT NMS
After further research I've found out this:
So your only chance is to implement an NMS solution.
ANVIL GUI
If you don't want to dive into NMS development then you can use the following API called AnvilGUI by WesJD. Here you have the documentation of this API.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.