.executeConsoleCommand() only works once

  • Hi, just thought I would mention that the code;


    Java
    event.getPlayer().executeConsoleCommand();


    doesn't work for multiple commands of spawning a skeleton


    For example;


    Java
    event.getPlayer().executeConsoleCommand("spawnnpc pig");
    event.getPlayer().executeConsoleCommand("spawnnpc cow");


    Will spawn a pig and cow, and ;


    Java
    event.getPlayer().executeConsoleCommand("spawnnpc sheep");
    event.getPlayer().executeConsoleCommand("spawnnpc sheep");


    will spawn two sheep, but;




    Java
    event.getPlayer().executeConsoleCommand("spawnnpc skeleton");
    event.getPlayer().executeConsoleCommand("spawnnpc skeleton");


    Will only spawn one skeleton, a new skeleton can only be spawned with this command after a reboot.

  • Hehe, well, this is a funny situation: if you call this command, the npc spawns in front of you. If you call this command twice in the same tick, both skeletons will be at exactly the same location, using exactly the same animations - while there are two skeletons, you will basically only see one. If they start attacking you, they are still at the same position, since the attack routine is identical for both skeletons. They will only move in different directions if they're not attacking you, or if the way is blocked.
    However, if you want to spawn a new npc, it's recommendable to use the World.spawnNpc() function instead of using the console command for it ;) If you want to get the location in front of the player, you can use this function: Utils.VectorUtils.getXYZInFrontOfPlayer()

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!