Guest User

Untitled

a guest
Oct 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1.    
  2.  
  3.     /**
  4.      * Gets the xOrigin for this screen, based on the screen type
  5.      * @return
  6.      *  xOrigin (-1 if error)
  7.      */
  8.     public double getXOrigin(){
  9.         switch(this.type){
  10.             case XY:
  11.                 return this.loc1.getX();
  12.             case ZY:
  13.                 return this.loc1.getZ();
  14.             case XZ:
  15.                 return this.loc1.getX();
  16.         }
  17.         return -1;
  18.     }
  19.    
  20.     /**
  21.      * Gets the yOrigin for this screen, based on the screen type
  22.      * @return
  23.      *  yOrigin (-1 if error)
  24.      */
  25.     public double getYOrigin(){
  26.         switch(this.type){
  27.             case XY:
  28.                 return this.loc1.getY();
  29.             case ZY:
  30.                 return this.loc1.getY();
  31.             case XZ:
  32.                 return this.loc1.getZ();
  33.         }
  34.         return -1;
  35.     }
  36.  
  37.     /**
  38.      * Calculates and returns a Bukkit Location of the given screen coordinates,
  39.      * keeping in mind the possible screen orientations
  40.      * @param x
  41.      *  x-coordinate (of the screen)
  42.      * @param y
  43.      *  y-coordinate (of the screen)
  44.      * @return
  45.      *  Location for use in CraftApplet
  46.      */
  47.     public Location getScreenCoordinate(double x, double y){
  48.         switch(type){
  49.         case XY:
  50.             return new Location(world, xOrigin+x, yOrigin+y, constantCoor);
  51.         case ZY:
  52.             return new Location(world, constantCoor, yOrigin+y, xOrigin+x);
  53.         case XZ:
  54.             return new Location(world, xOrigin+x, constantCoor, yOrigin+y);
  55.         }
  56.         return null;
  57.     }
Add Comment
Please, Sign In to add comment