Open a chest GUI, without a chest. Like OpenInv. [UNSOLVED]

Discussion in 'Plugin Development' started by Mike724, Dec 24, 2011.

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

    Mike724

    I've seen in plugins like OpenInv that it is possible to show a chest menu without a chest. How is this done without spout?

    Here's a picture of what I mean:
    [​IMG]

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  2. Offline

    Afforess

    Look up how Spout does it then.
     
  3. Offline

    Mike724

    Would the spoutcraft client be needed?
     
  4. Offline

    Afforess

    nope.
     
  5. Offline

    Mike724

    Alright, so i'll have to use Spout and the Spout API.

    I don't really feel like going through the huge source code for spout, lol.
     
  6. Offline

    IDragonfire

    You don't need Spoutcraft (Clientmod) or Spout (ServerPlugin).

    The Trader of Citizens implements a example ;)
     
  7. Offline

    ItsHarry

    It can be done without Spout, but you'll have too dig into some source code because nobody seems to know it by heart
     
  8. Offline

    Mike724

    I already looked at that source code, it's not really the best example because it has no comments, ect. So it's pretty hard to figure out whats really going on.:mad:
     
  9. Offline

    Kekec852

    Init code:
    Code:
    EntityPlayer ePlayer;
    CraftPlayer cPlayer;
    cPlayer = (CraftPlayer) player;
    ePlayer = cPlayer.getHandle();
    
    Opening small chest:
    Code:
    TileEntityChest chest = new  TileEntityChest ();
    ePlayer.a(chest);
    
    Opening big chest:
    Code:
    TileEntityChest ch1 = new  TileEntityChest ();
    TileEntityChest ch2 = new  TileEntityChest ();
    InventoryLargeChest lc = new InventoryLargeChest(name, ch1, ch2);
    ePlayer.a(lc);
    
     
    Mike724 likes this.
  10. Offline

    IDragonfire

    Correct ^^
    https://github.com/CitizensDev/Citi...re/net/citizensnpcs/utils/InventoryUtils.java
     
  11. Offline

    Mike724

    Thank you so much! You're a hero, seriously! :)
     
  12. Offline

    EllBristow

    This thread is marked as [UNSOLVED]... perhaps it should be updated?
     
  13. Offline

    Tster

    Sorry to reopen a thread, but what is 'name' in this case?
     
  14. Offline

    DanielSturk

    ePlayer.a(chest);
    a is underlined red and gives me the error:

    The method a(TileEntity) from the type EntityPlayer is not visible
     
  15. Offline

    CorrieKay

    Off topic: but does anyone know the texturepack/mod of the OP?
     
  16. Offline

    DanielSturk

    Do you mean how to check what texture pack the OP is using?
     
  17. Offline

    CorrieKay

    no, i just wanna know what texture pack hes using :p

    i wanna add it to my collection
     
  18. compiled jars don't have comments.

    Sphaxcraft

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  19. Offline

    Kekec852

    New versions is on how to open virtual chest:

    you need small chest like:

    TileEntityChest chest = new TileEntityChest ();

    or double one:

    TileEntityChest ch1 = new TileEntityChest ();
    TileEntityChest ch2 = new TileEntityChest ();
    InventoryLargeChest lc = new InventoryLargeChest(name, ch1, ch2);

    To open chest you need CraftInventory like this:

    for small one: CraftInventory inventory = new CraftInventory(chest);
    or for double: CraftInventory inventory = new CraftInventory(lc);

    thet you just open inventory with player.openInventory(inventory);
     
  20. Offline

    Njol

    Or you could simply use one of the Bukkit.createInventory(...) methods to create an new inventory and then open it with player.openInventory(inventory)...

    BTW: This thread is several months old and the OP is outdated.
     
    Firefly likes this.
  21. Offline

    Kekec852

    nice
     
  22. Offline

    DanielSturk

    nice, but thanks to both of you for your help. Btw, I was looking at the different InventoryType.s but I could only find a normal sized chest. How do I make a large chest with the second method? I don't think I could use
    because that data type is a InventoryLargeChest instead of a Inventory, unless there is a way to convert it?
     
  23. create an small sized chest inventory of the size 27*2 ?
     
  24. Offline

    DanielSturk

    ^a large chest, so yes, 27*2 would be the right size (6*9)
     
  25. Offline

    Mike724

    Wow this thread exploded with new replies... Several people have posted newer (working) examples on this thread, and it should be closed and set to resolved.

    Also, the texture pack is Sphax PureBDCraft
     
  26. Offline

    messageofdeath

    You can get a players inventory like this as a chest

    PHP:
    Player tplayer Bukkit.getServer().getPlayer(args[0]);
    PlayerInventory inv tplayer.getInventory();
    player.openInventory(inv);
     
    // Done that's all you need to get someone elses inventory
     
  27. I use this code in my plugin:

    Code:
    public void openGUI(Player p, int slots, String name, ItemStack[] is)
        {
            Inventory inv;
            inv = Bukkit.createInventory(null, slots, name);
            for (int i = 0; i <= slots; i++)
            {
                inv.setItem(i, is[i]);
            }
            p.openInventory(inv);
        }
     
Thread Status:
Not open for further replies.

Share This Page