Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.chickenstyle.luckyblocks.utilsfolder;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.entity.ArmorStand;
- import org.bukkit.entity.EntityType;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.util.EulerAngle;
- import org.bukkit.util.Vector;
- public class TestAnimation extends BukkitRunnable {
- ArmorStand stand;
- Location loc;
- int ticks = 0;
- boolean runOnce = false;
- @SuppressWarnings("deprecation")
- public TestAnimation(Location loc) {
- loc.add(0.5,0,0);
- stand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
- stand.setArms(true);
- stand.setVisible(true);
- stand.setGravity(false);
- // 1.493 * Math.pi
- stand.setRightArmPose(new EulerAngle(-(Math.PI / 2), -0.69, 0));
- stand.setItemInHand(new ItemStack(Material.COAL));
- this.loc = loc;
- }
- @Override
- public void run() {
- if (ticks < 100) {
- ticks++;
- double t = ((double) ticks%40) * Math.PI / 20;
- stand.teleport(getLocationAroundCircle(loc, 1, t));
- } else {
- stand.remove();
- cancel();
- return;
- }
- }
- private Location getLocationAroundCircle(Location center, double radius, double angleInRadian) {
- double x = center.getX() + radius * Math.cos(angleInRadian);
- double z = center.getZ() + radius * Math.sin(angleInRadian);
- double y = center.getY();
- Location loc = new Location(center.getWorld(), x, y, z);
- Vector difference = center.toVector().clone().subtract(loc.toVector());
- loc.setDirection(difference);
- return loc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment