1.8.8 NPE while creating NPC

Discussion in 'Spigot Plugin Development' started by Kompye, Mar 29, 2020.

  1. Hello. What does ((EntityPlayer)this.tracker).playerConnection = Class not loaded : net.minecraft.server.v1_8_R3.EntityPlayer mean?

    I am getting this error when joining my server after creating a player npc
    Code (Text):
    [11:17:20 ERROR]: Encountered an unexpected exception
    java.lang.NullPointerException
            at net.minecraft.server.v1_8_R3.EntityTrackerEntry.broadcastIncludingSelf(EntityTrackerEntry.java:288) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityTrackerEntry.b(EntityTrackerEntry.java:253) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityTrackerEntry.track(EntityTrackerEntry.java:179) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.EntityTracker.updatePlayers(EntityTracker.java:177) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:803) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
    I remote debugged it and I got the thing above in the intellij console
     
  2. It will be difficult receiving support when using an unsupported platform (nms) and a 5 years (?) outdated version.
     
    • Funny Funny x 1
    • Winner Winner x 1
  3. Send there your source code please !
     
  4. Code (Java):
        public static void createSpecialItemNPC(Dungeon plugin, Player p) {

            Location npcLocation = new Location(Bukkit.getWorld("world"), 246, 174, 1279);

            MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
            WorldServer world = ((CraftWorld) npcLocation.getWorld()).getHandle();
            GameProfile gameProfile = new GameProfile(UUID.randomUUID(), Chat.color("&aTester"));

            PlayerNPC npc = new PlayerNPC(server, world, gameProfile, new PlayerInteractManager(world));

            PlayerConnection connection = ((CraftPlayer)p).getHandle().playerConnection;
            world.addEntity(npc);
            connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
            connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));

            npc.setLocation(npcLocation.getX(), npcLocation.getY(), npcLocation.getZ(), 0, 0);

        }
    The error started happening after adding world.addEntity(npc)
     
  5. This can happen from time to time. If you've started the server in debug mode over IntelliJ, it basically hooks into it and does some "magic" behind the curtains so that it can run the debugger the way it does and can do "magic" things like hot code swapping.

    Just do a clean restart of the server and most of the time it will fix "Class not found" and "Class not loaded" Exceptions.
    If this doesn't fix the issues, try running it without the debugger and after this, if it's still not working, please let us know :)
     
    • Informative Informative x 1
  6. yup it fixed it, ty
    but I still get the error when joining the server.

    One thing I realized now is that the error states that EntityTrackerEntry.java:288 is the problem, which is
    AsyncCatcher.catchOp("entity add");

    Also as I said this started happening after adding world.addEntity(npc), and it's first row is also
    AsyncCatcher.catchOp("entity add");