Hi, I really need help with NMS to spawn an NPC in 1.21.
Here's my code:
But, nothing happens...
And 1.21 is really different from 1.20.1 that's why I can't just do the same thing than in the Kody Simpson tutorial. ( it's
I searched on the web but nothing can really help me ( I think because 1.21 is recent )
Of course I'm using mojang mappings
Here's my code:
Java:
private static void spawnNPC(Player p) { // there's no problem with the player
CraftPlayer craftP = (CraftPlayer) p;
ServerPlayer sp = craftP.getHandle();
MinecraftServer server = sp.getServer();
ServerLevel level = sp.serverLevel();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Billy Bob");
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, new ClientInformation("dqs", 2, ChatVisiblity.HIDDEN, true, 3, HumanoidArm.LEFT, true, true));
ServerEntity npcServerEntity = new ServerEntity(level, sp, 0, false, packet -> { }, Set.of()); // someone on a forum said to do that ...*1
npc.setPos(p.getX(), p.getY(), p.getZ());
ServerGamePacketListenerImpl ps = sp.connection;
ps.send(new ClientboundAddEntityPacket(npc, npcServerEntity)); // *1... and put it here
}
But, nothing happens...
And 1.21 is really different from 1.20.1 that's why I can't just do the same thing than in the Kody Simpson tutorial. ( it's
ClientboundAddEntityPacket
and no ClientboundAddPlayerPacket
)I searched on the web but nothing can really help me ( I think because 1.21 is recent )
Of course I'm using mojang mappings