[NMS] Spawn Entity Player (NPC)

Discussion in 'Plugin Help/Development/Requests' started by stonebloodtv, Jan 9, 2015.

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

    stonebloodtv

    Hi !

    I need create a custom Entity Player for create npc custom on my server.
    My code is wrong, i need help :(

    Code:
    
    public class npcPlayer1 extends EntityPlayer {
    
        public npcPlayer1(MinecraftServer arg0, WorldServer arg1, GameProfile arg2, PlayerInteractManager manager) {
    
            super((MinecraftServer)arg0, (WorldServer) arg1, arg2, new PlayerInteractManager(arg1));
            playerConnection = new PlayerConnection(server, new NetworkManager(false), this);
    
            this.playerInteractManager.setGameMode(EnumGamemode.SURVIVAL);
        }
    
        public static void spawnNPC(Location l) {
    
            MinecraftServer server = MinecraftServer.getServer();
            WorldServer world = server.getWorldServer(0);
            UUID uuid = UUID.randomUUID();
            GameProfile profile = new GameProfile(uuid, "NPC-01");
            PlayerInteractManager manager = new PlayerInteractManager(world);
           
            npcPlayer1 npc = new npcPlayer1(server, world, profile, manager);
            npc.playerConnection = new PlayerConnection(server, new NetworkManager(false), npc);
            npc.setLocation(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch());
            world.addEntity(npc, SpawnReason.NATURAL);
        }
    
    }
    
    
    Error :
    Code:
    [11:31:39 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'e' i
    n plugin EclozionRPG v1
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spi
    got.jar:git-Spigot-1646]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    1) ~[spigot.jar:git-Spigot-1646]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServe
    r.java:767) ~[spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerCon
    nection.java:1043) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java
    :880) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat
    .java:65) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186
    ) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java
    :81) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:7
    34) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    89) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [spigot.jar:git-Spigot-1646]
    Caused by: java.lang.NullPointerException
            at net.minecraft.server.v1_7_R4.PlayerConnection.sendPacket(PlayerConnec
    tion.java:751) ~[spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.EntityPlayer.updateAbilities(EntityPlaye
    r.java:961) ~[spigot.jar:git-Spigot-1646]
            at net.minecraft.server.v1_7_R4.PlayerInteractManager.setGameMode(Player
    InteractManager.java:38) ~[spigot.jar:git-Spigot-1646]
            at fr.eclozion.rpg.npc.list.npcPlayer1.<init>(npcPlayer1.java:26) ~[?:?]
    
            at fr.eclozion.rpg.npc.list.npcPlayer1.spawnNPC(npcPlayer1.java:39) ~[?:
    ?]
            at fr.eclozion.rpg.CommandEclozion.onCommand(CommandEclozion.java:35) ~[
    ?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spi
    got.jar:git-Spigot-1646]
            ... 13 more
    >

    Thank you :(
     
  2. Offline

    Dragonphase

    @stonebloodtv

    Please seek support where you acquired your server mod.
     
  3. Offline

    stonebloodtv

    It's not a mod, just a plugin made by me..

    Juste i don't found the solution..
     
  4. Offline

    97WaterPolo

    @stonebloodtv
    Dragon is saying you are using Spigot, not bukkit so seek support from there, not talking about your plugin. But keep reading.

    @Dragonphase
    The bukkit forums has started to allow spigot questions here. I would say it is just in the wrong section, but it should still be answered.
     
  5. Offline

    stonebloodtv

    Whatever Spigot or Bukkit , the question is for create entity player..
    Bukkit or spigot, it's the same for me ! :)
     
Thread Status:
Not open for further replies.

Share This Page