Solved Force user to open THEIR Inventory?

Discussion in 'Plugin Development' started by ccrama, Apr 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    Hello Bukkit.
    I'm trying to create an inventory GUI like so:

    (just threw that together)

    and I have all the items correctly added to an inventory, but the InventoryType.PLAYER is just a double chest inventory. Is there a way to force a user to open THEIR inventory ( like shown above ), or is there an inventorytype for this type of inventory?

    Thanks for the help,
  2. Offline


    Have you tried player.openInventory(player.getInventory()); ?
  3. Offline


    That returns a double chest with the users inventory content inside ( I'm trying to make it show their inventory items and layout).
  4. Offline


    I think the only way to accomplish this would be through packets. I've been looking around for the packet but haven't been successful in getting the inventory open. I could get every other window (crafting, anvil, enchantment table, beacon, villager trade, etc) open, but not the inventory window.

    Here's the code if you wish to play with it
    1. Player p = ...;
    2. PacketPlayOutOpenWindow openInventory = new PacketPlayOutOpenWindow(int ?, int inventoryType, String inventoryName, int numInventorySlots, boolean ?);
    3. ((CraftPlayer) p).getHandle().playerConnection.sendPacket(openInventory);

    For the ones with question marks I didn't see any difference when changing around the values. The numInventorySlots should be a multiple of 9 I believe. Good luck!
  5. Offline


    SainttX sorry for the late reply. This method crashes the client and disconnects them from the server with an internal connection error. Eclipse doesn't like all those parameters after PacketPlayOutOpenWindow either :(. I think I'll just tell the user in a message or something to open up their inventory.

    Thanks again!
Thread Status:
Not open for further replies.

Share This Page