Regions and squares

Discussion in 'Plugin Development' started by MCCoding, Oct 31, 2014.

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

    MCCoding

    I'm wanting to create a simple object that I can save regions in and then have the region outlined, all regions will be squares. I have created a object i'm just having trouble creating the square and checking if a player is inside of the region.

    Here is the region object:
    Code:
        public Region(String name, World world, Location location, int range) {
            this.name = name;
            this.world = world;
            this.location = location;
            this.range= range;
        }
    what I'm needing help with is creating a square and having the object store it, so then I'm able to check if players are inside or outside of it.
     
  2. Offline

    mine-care

    So if you want to keep location list of a region you need to:
    get midle location and then for x y and z have a loop that adds and decreases by 1 for as long as it is less than the region get the location add it and then continue so for example:

    location = 0,0,0 and radius = 4

    then after the first loop pass x it should be 1 then 2 then 3 then 4. then -1 then -2 then -3 then -4, and you need to get the locations of those. When its done you repeat the same for y and z =)
    Hope i helped (as much as i could)
     
Thread Status:
Not open for further replies.

Share This Page