Sueta

Ocelot

1.0.2

Allows developers to track entities without having to rely on packets or NMS.

·Plugin

Ocelot
Allows developers to track entities much more easily, without having to rely on packets or NMS. Find a tutorial here .

Where to start
To get started, add Ocelot to your plugin's dependencies. You can get the Ocelot instance like so:

Ocelot ocelot  =  Ocelot.  getInstance   (   )   ;

Once you have your Ocelot instance, you can get an `OcelotTracker` for an entity:

Entity   entity  ;  
OcelotTracker entityTracker  =  ocelot.  getTrackerFor   (  entity  )   ;

The OcelotTracker will show you which players can view the given player, and can let you set the VisibilityController , which will allow you to determine whether an entity is visible to a player.

Custom VisibilityController
An example is provided below:

public   class  VisibilityControllerDistance  implements  VisibilityController  {  
     protected   double  distance  ;  
     protected   double  distanceSquared  ;  

     public  VisibilityControllerDistance  (   double  distance  )   {  
         this  .  distance   =  distance  ;  
        distanceSquared  =  distance  *  distance  ;  
     }  

    @Override 
     public  BooleanResult isVisible  (  Player player, OcelotTracker tracker  )   {  
          Entity   entity  =  tracker.  getEntity   (   )   ;  
         if   (  entity.  getWorld   (   )   ==  player.  getWorld   (   )   &&  entity.  getLocation   (   )  .  distanceSquared   (  player.  getLocation   (   )   )   <=  distanceSquared  )   {  
             return  BooleanResult.  TRUE   ;  
         }  

         return  BooleanResult.  FALSE   ;  
     }  
 }

Once you have a VisibilityController created, you can set it for any OcelotTracker :

OcelotTracker entityTracker  ;  
VisibilityController controller  =   new  VisibilityControllerDistance  (   10   )   ;   // 10 block viewing range  
entityTracker.  setVisibilityController   (  controller  )   ;

Calling the OcelotTracker#update() method is recommended after setting the visibility controller. Note that the trackers do not persist over entity despawn and respawn.

Supported Versions
Ocelot supports these versions:

  • 1.14.4
  • 1.15
  • 1.15.1

Similar projects

Plugin →