Location help

Discussion in 'Plugin Development' started by someguyonthestreet, Aug 18, 2015.

Thread Status:
Not open for further replies.
  1. I need help getting a players west and east locations by a couple blocks. This is what I kind of want it to look like if I were to spawn a falling block or entity at the locations https://gyazo.com/7d03f281a488d951cf63ea518cb101e8.

    I have tried to do this but all I have is this (and it doesn't work)
        public void onJoin(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            Villager vA = spawn(player, player.getLocation().add(1, 1, 1).getBlock().getRelative(BlockFace.WEST).getLocation());
            Villager vB = spawn(player, player.getLocation().add(1, 1, 1).getBlock().getRelative(BlockFace.EAST).getLocation());
            new BukkitRunnable() {
                public void run() {
                    vB.teleport(player.getLocation().add(1, 1, 1).getBlock().getRelative(BlockFace.WEST).getLocation());
                    vA.teleport(player.getLocation().add(1, 1, 1).getBlock().getRelative(BlockFace.WEST).getLocation());
            }.runTaskTimer(this, 0L, 0L);
        public Villager spawn(Player player, Location location) {
            Villager v = (Villager) player.getWorld().spawnEntity(player.getLocation(), EntityType.VILLAGER);
            return v;
  2. Offline


    What doesn't work any errors/stacktraces?

    Edit: What is the runnable doing?
  3. The locations don't work, they are spawning behind me sometimes, etc. The runnable to teleporting them to that location, its quite obvious
  4. Offline


  5. No it isn't, it is supposed to teleport the villagers to that location every moment. But the locations are messed up
  6. Offline


    Yes not completely sure what you want, however to get 3 blocks east try using this:
    I'm not sure why you where adding from the players location, but the ".getRelative()" can have a second arg which is how many blocks in that direction.
  7. thanks thats what I was looking for
Thread Status:
Not open for further replies.

Share This Page