Check if player enters a certain area (cuboid)

Discussion in 'Plugin Development' started by FlawlezZ, May 2, 2014.

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

    FlawlezZ

    Hey,

    I'm currently making a plugin and I don't know how to check if player enters a certain cuboid. I searched a bit around on this forum and I found some possibilities with PlayerMoveEvent (which is not very efficient), but nothing with a cuboid.

    Currently I am saving the selection (highest and lowest point) with WorldEdit (which shall be maintained) and want to check if a player has entered the selection. Can you recommend me on how I can trigger that check and how I check the coordinates (to execute code when a player is in that cuboid)

    Greetings
     
  2. Offline

    Superckl1

    FlawlezZ

    Create two Vectors (you can do that with Location.to vector) that represent two opposite vertices of the cuboid. You can then do Vector.isInAABB to check if a vector is in the cuboid represented by the vertices. The vertices need to be passed in max-min order. You can determine that with Vector.get maximum and getMinimum.

    You can use the location from PlayerMoveEvent.getTo.
     
Thread Status:
Not open for further replies.

Share This Page