ArmorStand moving around a middle block

Discussion in 'Plugin Development' started by AsyncProgrammer, Sep 7, 2019.

Thread Status:
Not open for further replies.
  1. Offline


    I am trying to make the armor stand rotate around the block, and not start rotating from it, which is what is happening.

    I trying to do anythig similiar to that
    But the max who i achieved is this why my armor stand doesnt rotate around the EnderChest.
    Full code:
    Fully Code (open)

    package net.arcane.caixas.executor.commands;
    import net.arcane.caixas.Loader;
    import net.arcane.caixas.Skull;
    import org.apache.commons.lang.math.RandomUtils;
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.ArmorStand;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.scheduler.BukkitRunnable;
    import org.bukkit.util.EulerAngle;
    import org.bukkit.util.Vector;
    import java.util.List;
    * Classe criada para o plugin - ArcaneChestShop
    * @author Async. Obrigado por utiliza-lo.
    * @data 06/09/2019 - 22:28.
    public class TesteCommand  {
        public String[] skulls = new String[]{"",
        public void execute(Player player, String[] args){
            for (int i = 0; i < 100; i++){
            List<Location> locations = Lists.newArrayList();
            player.getLocation().clone().add(0,-0.975, 0).getBlock().setType(Material.ENDER_CHEST);
            locations.add(player.getLocation().clone().add(0, -0.975, 0));
            Block block = player.getWorld().getBlockAt(locations.get(0));
           // ArmorStand sol = player.getWorld().spawn(player.getLocation().clone().add(0, -0.975, 00), ArmorStand.class); // spawna a ArmorStand
           // sol.setVisible(false); // coloca pra ela nao ficar visivel
           // sol.setGravity(false);
            ArmorStand terra = player.getWorld().spawn(player.getLocation().clone().add(1, -0.975, 0), ArmorStand.class); // spawna a ArmorStand
            terra.setHelmet(Skull.getCustomSkull(skulls[1])); // coloca uma cabeça nela
            terra.setVisible(true); // coloca pra ela nao ficar visivel
            final Location center = block.getLocation();
            final float radius = 1.40f;
            final float radPerSec = 3f;
            final float radPerTick = radPerSec / 20f;
            ArmorStand stand = player.getWorld().spawn(center, ArmorStand.class); // spawna a ArmorStand
            stand.setHelmet(Skull.getCustomSkull(skulls[1])); // coloca uma cabeça nela
            stand.setVisible(false); // coloca pra ela nao ficar visivel
            new BukkitRunnable() {
                int tick = 0;
                double y = 0.0;
                public void run() {
                    Location loc = getLocationAroundCircle(center, radius, radPerTick * tick);
                    stand.setVelocity(new Vector(0, 0, 0));
            }.runTaskTimer(Loader.getInstance(), 0L, 1L);
        public Location getLocationAroundCircle(Location center, double radius, double angleInRadian) {
            double x = center.getX() - radius * Math.cos(angleInRadian);
            double y = center.getY() - radius * Math.sin(angleInRadian);
            Location loc = new Location(center.getWorld(), x, y, center.getZ());
            Vector difference = center.toVector().clone().subtract(loc.toVector()); // this sets the returned location's direction toward the center of the circle
            return loc;
        public Location getCenter(Location loc) {
            return new Location(loc.getWorld(),
        private double getRelativeCoord(int i) {
            double d = i;
            d = d < 0 ? d - .5 : d + .5;
            return d;
  2. Use your getCenter() method. But you'll have to make some adjustment: the "relative" coordinates should always be +.5 not negative and the y is probably not 0.5 because of the height of the armor stand. You'll have to play around a little to find the best offset
    Last edited: Sep 8, 2019
Thread Status:
Not open for further replies.

Share This Page