Vector

Discussion in 'Spigot Plugin Development' started by Danique, May 16, 2016.

  1. Can someone tell me a code that i can use to calculate the right and left location as vector of an entity.

    Danique
     
  2. What you want to do?
     
  3. I want to calculate the vector of the left and right side of an entity
     
  4. Code (Text):
        public void run()
        {
            if(!(Main.head.size() == 2)) {
                return;
            }
            Location loc = pos(Main.head.get(0), 90, -1);
            Main.follower.get(0).teleport(loc);
            Location loc1 = pos(Main.head.get(0), 270, -1);
            Main.follower.get(1).teleport(loc1);
            Location loc3 = pos(Main.head.get(1), 90, -1);
            Main.follower.get(2).teleport(loc3);
           
            Location loc4 = pos(Main.head.get(1), 270, -1);
            Main.follower.get(3).teleport(loc4);
        }
        public Location pos(Entity center, int graden, int direction) {
            double amt = 1.5;
            final float newZ = (float)(center.getLocation().getZ() + ( amt * Math.sin(Math.toRadians(center.getLocation().getYaw() + graden * direction))));
             
            final float newX = (float)(center.getLocation().getX() + ( amt * Math.cos(Math.toRadians(center.getLocation().getYaw() + graden * direction))));
            return (new Location(center.getWorld(), newX, center.getLocation().getY(), newZ));
        }
    First i did it with teleport. But when you're in a cart that is teleport. it won't because that is disabled.
     
  5. Don't bump within 24 hours!
     
    • Agree Agree x 1