.executeConsoleCommand() only works once

  • English

We've posted an important announcement regarding the current situation and the future of the game: Announcement

  • .executeConsoleCommand() only works once

    Hi, just thought I would mention that the code;

    Java Source Code

    1. event.getPlayer().executeConsoleCommand();


    doesn't work for multiple commands of spawning a skeleton

    For example;

    Java Source Code

    1. event.getPlayer().executeConsoleCommand("spawnnpc pig");
    2. event.getPlayer().executeConsoleCommand("spawnnpc cow");

    Will spawn a pig and cow, and ;

    Java Source Code

    1. event.getPlayer().executeConsoleCommand("spawnnpc sheep");
    2. event.getPlayer().executeConsoleCommand("spawnnpc sheep");

    will spawn two sheep, but;



    Java Source Code

    1. event.getPlayer().executeConsoleCommand("spawnnpc skeleton");
    2. event.getPlayer().executeConsoleCommand("spawnnpc skeleton");

    Will only spawn one skeleton, a new skeleton can only be spawned with this command after a reboot.
    play: server.medievalrealms.co.uk website: medievalrealms.co.uk discord: discord.medievalrealms.co.uk
  • 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()
  • Users Online 1

    1 Guest