Solved How to create inventory chest using nms?

Discussion in 'Spigot Plugin Development' started by Nico12, Feb 15, 2020.

Thread Status:
Not open for further replies.
  1. Good morning / evenings / nights, I try to create a chest-type inventory using nms, but honestly I don't know how, I didn't take this as a spoon feed and please don't ask why I want to use nms instead of api bukkit sometimes one He has his reasons.
    !Thanks in advance!
  2. If you can’t justify why you need to do something in one way when a better way exists then you should probably not be doing it that way. This is especially true when you are attempting to use NMS without knowing (or considering, I don’t know what your situation is) how to look at the API implementations to see how the server code creates Inventories.
  3. I simply need to create an inventory and have it run from the client
  4. That's what the api is for. Aren't you the guy that wanted to change the inventory title through NMS?
  5. Yes, until I find a way that is with a runnable, what it does is change the title and reopen the inventory, but that would be a lot of burden for the server using the api then I thought that when using nms this would run from the Customer, correct me if I'm wrong
  6. What do you mean run from the client? An Inventory is an Inventory regardless of whether you use the API or use NMS directly. Why not make it easier for yourself to write and maintain your code and use the API?
    • Like Like x 3
    • Agree Agree x 1
  7. Why can't you just make a gui using spigot?
  8. Can you do it without NMS?

    It's so much easier and it can support more than just one version of Minecraft.
    You can create a new chest GUI like so:
    Code (Java):

    Inventory gui = Bukkit.createInventory(<Player player>, <Integer size>, <String name>);
    Add any items you may want:
    Code (Java):

    gui.setItem(<Integer slot>, <ItemStack item>);
    If you don't want to show it to the player right away, you can do something like this:
    Code (Java):

    Inventory gui = Bukkit.createInventory(null, <Integer size>, <String name>);
    gui.setItem(<Integer slot>, <ItemStack item>);

    /* Show it to the player */
    • Like Like x 1
Thread Status:
Not open for further replies.