RightClick chest places block

Discussion in 'Plugin Development' started by MordorKing78, Dec 25, 2014.

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

    MordorKing78

    So I'm making a "Crate" plugin when you right click it there will spawn a chest at the location you are looking at (range of 4). After thats done I want to make it like when you right click a chest it will be gone and you will get a reward. But I have 2 problems.

    First problem:
    I don't know the best way or the "legit" way to spawn a chest were the player is looking at (I want it to be right click a chest because then you can spawn blocks in a world guard region (I HOPE))

    Second problem:
    I don't know how to detect if the player who placed the chest and then right clicks it actually placed it. Like when you place it and another player walks by right clicks the chest and enjoys his loot.

    Please you do not have to feed it all to me but some explanations with examples would be good because I have no idea what I'm doing.
     
  2. Offline

    indyetoile

    @MordorKing78
    You could try this command to check where the player is looking at: player.getTargetBlock(null , 4).

    For the second problem, you should add metadata to the chest (display name or lore), and on a right click check whether the metadata from the chest matches the e.g. player name/UUID.
     
  3. Offline

    MordorKing78

    @indyetoile How would I set a block with player.get** etc. How would I add meta data to the chest?
     
  4. Offline

    nuclearmissile

    If you want to place a chest on the surface you click without replacing the block itself, you should look into a very helpful raycast class called BlockIterator.
     
  5. Offline

    MordorKing78

    @nuclearmissile @indyetoile I did it like detected when a player right clicks on a quartz thingy he will place a chest. But somethimes what will screw up the spawn. I also gave the chest a name. So I can detect who placed the crate.
     
  6. Offline

    nuclearmissile


    @MordorKing78 Ok, you'll need to provide us some more information as to how it was screwed up if you want us to help.
     
  7. Offline

    MordorKing78

Thread Status:
Not open for further replies.

Share This Page