Solved Check if the Placed chest connect to other chests

Discussion in 'Plugin Development' started by mr_nice1107, Oct 25, 2019.

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

    mr_nice1107

    Hey there!
    Sorry for the long title but I don't find a shorter one...

    Ok I want to make a plugin that should lock chests...
    It worked well so far, but now I got some problems with dobblechests

    For example you have a locked chest! noone except of you can acces this chest

    Now you place a chest next to it
    The system should automaticly do 2 things
    first:
    check if the player who sets the secound chest next to that has is the owner of the first chest
    and secound:
    add the locking to the secound chest

    the secound thing is no big deal if you know how the first workes...

    so my question:
    Is there a way to check if the chest a player places do connect to a nother chest

    and I have another question
    Is it possible to block a redstone singal?
    For example a pressureplate or something like that
    Is there any event or something like that?

    I use the 1.14.4

    Thanks in advance for all the answers!
     
    Last edited: Oct 25, 2019
  2. Offline

    robertlit

    BlockPlaceEvent -> if placed block is a chest -> heck if the placed chest has a chest nearby, if it does, get the owner of the first chest, if it is not the player who placed the second chest cancel the event.
     
    baenii likes this.
  3. Offline

    Kars

    You are using 1.14 so you can only connect a chest to another chest by placing it while crouch clicking the other chest, correct?

    On PlayerInteractEvent, if he has a chest in his hand + is crouching + is targeting another chest.. Do what you gotta do.
     
  4. Offline

    robertlit

    Pretty sure it's the opposite, if you crouch, it won't connect.
     
  5. @Kars That's not really what he want's to do if I understood him correctly.

    @robertlit That actually should be all u need to get your thing working.
     
  6. Offline

    mr_nice1107

    Ok, at first thank you for your answers!
    But that don't change anything im my case!
    I want to check if a block (in no event!) that I get from anywhere is connected to another chest!
    I found a solution:

    1. check if the block is a chest/trappedchest
    2. get the chestholders
    3. check if they are instance of double chest!

    Like this:
    Code:
    if (block.getType().equals(Material.CHEST)) {
      (Chest) block.getState()
      InventoryHolder holder = chest.getInventory().getHolder();
      if (holder instanceof DoubleChest) {
        // DO STUF
    }}
    The problem in 1.14 is that you can place chests neare to each other...
    And yes when you are holding shift while placing a chest will prevents the chest to get conected!

    So I think this question is solved! Thank you very much!
     
Thread Status:
Not open for further replies.

Share This Page