How to get inventory of a chest the old way

Discussion in 'Plugin Development' started by Borch, Mar 6, 2012.

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


    So I see that there have been modifications to the Chest/Inventory classes, and now if there is a double-chest and I do .getInventory() on one of the blocks of the chest, it will give me all the items of the double chest, even the ones technically stored in the other block.
    Now in one of my plugins when a player breaks a chest I need to get all the items that get dropped from doing so. (As you know, only the items drop that were in "that half" of the double chest)
    Right now it gives me an Inventory with all the items, and I can't determine which ones were in the half that got destroyed.
    Any way to get the old behavior back?

    Or in general: Is there any way to get the items being dropped when breaking one half of a double-chest?

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

    Father Of Time

    I would imagine you could do this with indexes. I'm not sure how you would tell which index ranges are related to which chest, but I would imagine just like before that index 0 - 26 would be one chest and 27 -53 would be the other.

    I am only speculating, but if the system works anything like mine it likely makes the chest from the event the 0-26 and the one attached to it 27-53.

    Just some food for thought, good luck with your project!
  3. Offline


    Thanks for the input! Doesn't sound too elegant, but if I can figure out which half I'm in it should do the trick.
    I'm really wondering if the bukkit devs just forgot about that case, or if we're overly stupid and just don't see it.
  4. Offline


Thread Status:
Not open for further replies.

Share This Page