danik159

Untitled

Aug 17th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 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. loc.add(0.5,0,0);
  28. stand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
  29.  
  30.  
  31. stand.setArms(true);
  32. stand.setVisible(false);
  33. stand.setGravity(false);
  34. // 1.493 * Math.pi
  35. stand.setRightArmPose(new EulerAngle(-(Math.PI/2),-(Math.PI / 6.35), 0));
  36. stand.setItemInHand(new ItemStack(Material.COAL));
  37. this.loc = loc;
  38.  
  39. }
  40.  
  41. @Override
  42. public void run() {
  43. if (ticks < 100) {
  44. ticks++;
  45. double t = ((double) ticks%40) * Math.PI / 20;
  46. Vector v = new Vector(Math.cos(t), 0, Math.sin(t));
  47. v.multiply(.08275);
  48. stand.setVelocity(v);
  49. float yaw = stand.getLocation().getYaw();
  50. yaw += 9;
  51. Location location = new Location(stand.getWorld(), stand.getLocation().getX(), stand.getLocation().getY(), stand.getLocation().getZ(), yaw, stand.getLocation().getPitch());
  52. stand.teleport(location.add(v));
  53. } else {
  54. stand.remove();
  55. cancel();
  56. return;
  57. }
  58. }
  59.  
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment