Checking if a certain block is in a certain radius

Discussion in 'Plugin Development' started by johnny boy, Apr 8, 2017.

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

    johnny boy

    I have a plugin that disallows sponge from being able to soak up water, I know I need a for loop checking if in a certain radius, a block is water, set the block to water.. But how would I "select" that radius??
     
  2. Offline

    Zombie_Striker

    @MemeplexOwner
    Are you developing a plugin, or are you using an existing plugin? If its the former, how do you want to select it? If its the latter, what plugin are you using?
     
  3. Offline

    johnny boy

    I am making my own plugin, and I want to select the sphere of the sponges radius. I don't know how to select it..
     
  4. Offline

    Zombie_Striker

    @MemeplexOwner
    1. Create an arraylist. This is all the blocks of water.
    2. Get the location of the sponge.
    3. Create three for int loops: for the X, Y, and Z. It will start at the coordinate minus the radius, and loop until it is equal to coordinates plus radius.
    4. If the distance between those two locations is less than or equal to a radius (do this using Location#distance(Location-2) ), add it to the array.
     
Thread Status:
Not open for further replies.

Share This Page