Teleporting Entities

Discussion in 'Plugin Development' started by TheoDoorHolder, Sep 1, 2016.

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

    TheoDoorHolder

    I need help on finding a way to teleport an entity to a player that runs a command.

    Code:
        public void testForEntity(Player player, String[] args) {
            Location loc = player.getLocation();
            World w = player.getWorld();
            if (args[0].equalsIgnoreCase("pig")) {
               
                hashmap.remove(player.getName());
                hashmap.put(player.getName(), true);
               
                w.spawnEntity(loc, EntityType.PIG);
    
                while (hashmap.get(player.getName()) == true) {
                    loc = player.getLocation();
                    //while the value is true in the hashmap, I need the entity teleporting to the player
                }           
            }
        
     
  2. Offline

    Payless

    if you are trying to make it like a pet where it follows maybe try a repeating task to repeat the teleportation.
     
  3. Offline

    Zombie_Striker

  4. Offline

    Marti201

    This is going to block the main thread. Look into scheduler programming.

    If you're trying to make a pet plugin, don't constantly teleport the pet to the player, it's inefficient and annoying. Custom entities are the solution.
     
    Zombie_Striker likes this.
  5. Offline

    TheoDoorHolder

    Okay thank you, I will work to fix that
     
Thread Status:
Not open for further replies.

Share This Page