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;
- int newTicks = 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(false);
- stand.setGravity(false);
- // 1.493 * Math.pi
- stand.setRightArmPose(new EulerAngle(-(Math.PI/2),-(Math.PI / 6.35), 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;
- Vector v = new Vector(Math.cos(t), 0, Math.sin(t));
- v.multiply(.08275);
- stand.setVelocity(v);
- float yaw = stand.getLocation().getYaw();
- yaw += 9;
- Location location = new Location(stand.getWorld(), stand.getLocation().getX(), stand.getLocation().getY(), stand.getLocation().getZ(), yaw, stand.getLocation().getPitch());
- stand.teleport(location.add(v));
- } else {
- stand.remove();
- cancel();
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment