Solved Chest and DoubleChest

Discussion in 'Spigot Plugin Development' started by Fluddershy, May 1, 2017.

  1. Hello, real quick question. I want to make a variable for the chest a player has just interacted with.
    Right now I'm using
    Code (Text):
    Chest c = (Chest) e.getClickedBlock().getState();
    Could I possibly change that to DoubleChest, but if it was a non-doublechest, I could still use it? If not, how can I test if it is a doublechest, then continue, if it isn't a doublechest, still continue?
  2. Serializator


    What you want to do is see if the holder of the inventory from the chest is a double chest.
    Code (Text):
    Chest chest = ((Chest) event.getClickedBlock().getState());

    if(chest.getInventory().getHolder() instanceof DoubleChest) {
        /* Do something... */
    • Like Like x 1
  3. Ohhh, Thanks!!! That's basically what I was trying to do! Ill hook that with an or and add Chest! Thanks again! :)
  4. Serializator


    Glad to help ;)
  5. Wait, how would I get the entire inventory though?
  6. Serializator


    Code (Text):
    Should return the inventory from the chest, if you need the left or right side from the double chest you can cast the returned variable to a DoubleChestInventory.
  7. Oh thanks so much! I was using e#getBlockInventory() *so stupid*
    Thanks so much!! <3 <3 :):oops: