danik159

Untitled

Aug 16th, 2020
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. package me.chickenstyle.luckyblocks.utilsfolder;
  2.  
  3. import org.bukkit.Location;
  4. import org.bukkit.Material;
  5. import org.bukkit.entity.ArmorStand;
  6. import org.bukkit.entity.EntityType;
  7. import org.bukkit.inventory.ItemStack;
  8. import org.bukkit.scheduler.BukkitRunnable;
  9. import org.bukkit.util.EulerAngle;
  10. import org.bukkit.util.Vector;
  11.  
  12.  
  13.  
  14.  
  15. public class TestAnimation extends BukkitRunnable {
  16.  
  17. ArmorStand stand;
  18. Location loc;
  19.  
  20. int ticks = 0;
  21. int newTicks = 0;
  22. boolean runOnce = false;
  23.  
  24.  
  25. @SuppressWarnings("deprecation")
  26. public TestAnimation(Location loc) {
  27.  
  28. stand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
  29. stand.setArms(true);
  30. stand.setVisible(true);
  31. stand.setGravity(false);
  32.  
  33. stand.setRightArmPose(new EulerAngle(1.493 * Math.PI, -(Math.PI/4), 0));
  34. stand.setItemInHand(new ItemStack(Material.STONE_PICKAXE));
  35. this.loc = loc;
  36.  
  37. }
  38.  
  39. @Override
  40. public void run() {
  41. if (ticks < 100) {
  42. ticks++;
  43. double t = ((double) ticks%40) * Math.PI / 20;
  44. Vector v = new Vector(Math.cos(t), 0, Math.sin(t));
  45. v.multiply(.1);
  46. stand.setVelocity(v);
  47. float yaw = stand.getLocation().getYaw();
  48. yaw += 9;
  49. Location location = new Location(stand.getWorld(), stand.getLocation().getX(), stand.getLocation().getY(), stand.getLocation().getZ(), yaw, stand.getLocation().getPitch());
  50. stand.teleport(location.add(v));
  51. } else {
  52. stand.remove();
  53. cancel();
  54. return;
  55. }
  56. }
  57.  
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment