Solved Fastest way to calculate if entity is in a sphere?

Discussion in 'Plugin Help/Development/Requests' started by Rabrg, Feb 17, 2015.

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

    Rabrg

    What's the fastest way to calculate if an entity is in a sphere? I'm currently using this method:
    Code:
        public boolean isEntityInSphere(final Entity entity) {
            return SPHERE_CENTER_VECTOR.distance(entity.getLocation().toVector()) <= SPHERE_RADIUS;
        }
    but I need block precision, not coordinate, and currently on the border of the sphere half of blocks are protected while the other half isn't.

    edit:Got it, mix of getting the entity's block location and ceiling the distance.
     
    Last edited: Feb 17, 2015
Thread Status:
Not open for further replies.

Share This Page