Advertisement
Guest User

Line Effect Drawer

a guest
May 5th, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. public static void playEffectLine(Effect effect, int effectData, Location pointA, Location pointB, int numberOfPointsBetweenAAndB) {
  2.     int timeIterated = 0;
  3.     double xIncrement = 0, yIncrement = 0, zIncrement = 0;
  4.     double currentX = 0, currentY = 0, currentZ = 0;
  5.     for(int i = 0; i < numberOfPointsBetweenAAndB; i++) {
  6.         if(timeIterated > numberOfPointsBetweenAAndB) return;
  7.         if(timeIterated == 0) {
  8.             currentX = pointA.getX();
  9.             currentY = pointA.getY();
  10.             currentZ = pointA.getZ();
  11.             xIncrement = (currentX - pointB.getX()) / numberOfPointsBetweenAAndB;
  12.             yIncrement = (currentY - pointB.getY()) / numberOfPointsBetweenAAndB;
  13.             zIncrement = (currentZ - pointB.getZ()) / numberOfPointsBetweenAAndB;
  14.             Location thisLoc = new Location(pointA.getWorld(), currentX, currentY, currentZ);
  15.             pointA.getWorld().playEffect(thisLoc, effect, effectData);
  16.             timeIterated++;
  17.             continue;
  18.         }
  19.         currentX -= xIncrement;
  20.         currentY -= yIncrement;
  21.         currentZ -= zIncrement;
  22.         Location thisLoc = new Location(pointA.getWorld(), currentX, currentY, currentZ);
  23.         pointA.getWorld().playEffect(thisLoc, effect, effectData);
  24.         timeIterated++;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement