Solved Trigger Chest Open

Discussion in 'Plugin Development' started by Feindbild, Dec 12, 2014.

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

    Feindbild

    Long story short, I want to have a player open a chest on left click, in a PlayerInteractEvent.
    Is there a way to achieve this feat?
     
  2. Offline

    FabeGabeMC

    @Feindbild
    You could check if the clicked block isn't null first of all. Then, you can check if the block's state is equal to Chest (org.bukkit.block.Chest). Finally cast the block's state to a chest and open the BLOCK inventory (getBlockInventory()) not the normal inventory (getInventory()) to the player.
     
    Feindbild likes this.
  3. Offline

    Feindbild

  4. Offline

    BrentHogeling

    @Fedingbild My only concern is the fact that if you re-create that inventory, it will have no connection to the chest apart from the contents, so say if someone was to break that chest all the content could drop out, but the player may still have the inventory open. I think you get the gist, just remember to take all that into consideration :)
     
    Feindbild and SuperOriginal like this.
Thread Status:
Not open for further replies.

Share This Page