svdragster

Untitled

Sep 29th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1.     public static void playEffectLine(Particle effect, Location pointA,
  2.             Location pointB, int numberOfPointsBetweenAAndB) {
  3.         int timeIterated = 0;
  4.         double xIncrement = 0.0D;
  5.         double yIncrement = 0.0D;
  6.         double zIncrement = 0.0D;
  7.         double currentX = 0.0D;
  8.         double currentY = 0.0D;
  9.         double currentZ = 0.0D;
  10.         for (int i = 0; i < numberOfPointsBetweenAAndB; i++) {
  11.             if (timeIterated > numberOfPointsBetweenAAndB) {
  12.                 return;
  13.             }
  14.             if (timeIterated == 0) {
  15.                 currentX = pointA.getX();
  16.                 currentY = pointA.getY();
  17.                 currentZ = pointA.getZ();
  18.                 xIncrement = (currentX - pointB.getX())
  19.                         / numberOfPointsBetweenAAndB;
  20.                 yIncrement = (currentY - pointB.getY())
  21.                         / numberOfPointsBetweenAAndB;
  22.                 zIncrement = (currentZ - pointB.getZ())
  23.                         / numberOfPointsBetweenAAndB;
  24.                 Location thisLoc = new Location(currentX, currentY, currentZ);
  25.                 effect.x = thisLoc.getX();
  26.                 effect.y = thisLoc.getY();
  27.                 effect.z = thisLoc.getZ();
  28.                 pointA.getWorld().spawnParticle(effect);
  29.                 timeIterated++;
  30.             } else {
  31.                 currentX -= xIncrement;
  32.                 currentY -= yIncrement;
  33.                 currentZ -= zIncrement;
  34.                 Location thisLoc = new Location(currentX, currentY, currentZ);
  35.                 effect.x = thisLoc.getX();
  36.                 effect.y = thisLoc.getY();
  37.                 effect.z = thisLoc.getZ();
  38.                 pointA.getWorld().spawnParticle(effect);
  39.                 timeIterated++;
  40.             }
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment