Opening an inventory?

Discussion in 'Plugin Development' started by mjmr89, Mar 17, 2011.

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

    mjmr89

    Hi, I was wondering if there was any way to force the little inventory popup to show with a given inventory? I was thinking whether or not it was possible to make a plugin that let you open chests that had a block on top, but that requires me to somehow open the inventory popup at will.
     
  2. Offline

    Edward Hand

    Yes there is. Give this a shot:
    Code:
    CraftInventory cInventory = (CraftInventory)theChest.getInventory();
    CraftPlayer cPlayer = (CraftPlayer)thePlayer;
    cPlayer.getHandle().a((IInventory)cInventory.getInventory());
     
  3. Offline

    mjmr89

    Thanks, I'll give it a try!

    Works! Mostly. It's having a problem opening double chests, it seems like that method "a" only opens a single chest. Well, it will open a double chest, but only with one side of it.. if that makes sense. Is there anywhere you're getting what that method means, or did you figure it out working on one of your plugins?

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

    Edward Hand

    I figured it out just looking in the minecraft source-code just now. I did realise it wouldn't work for double chests, but I thought it would complicate matters less to give you the solution a bit at a time ;D

    You can combine two single chests into a double chest as follows:
    Code:
    CraftInventory cInventory1 = (CraftInventory)theFirstChest.getInventory();
    CraftInventory cInventory2 = (CraftInventory)theSecondChest.getInventory();
    IInventory IChest = (IInventory)new InventoryLargeChest("Large chest", cInventory1.getInventory(), cInventory2.getInventory());
    cPlayer.getHandle().a(IChest);
    But you'll have to manually search adjacent blocks for chests to get the two separate cInventories
     
  5. Offline

    mjmr89

    Thanks! Just got working on that part of it sorta. I think I'll release this tomorrow, you're gonna get basically all of the credit though ;)
     
  6. Offline

    Deathly

    Good idea.. waiting for release :)
     
  7. Offline

    mjmr89

  8. Offline

    leslieliang

Thread Status:
Not open for further replies.

Share This Page