I’m encountering a NullPointerException in Citizens when a player is killed by an NPC equipped with the Sentinel trait. The error originates in net.citizensnpcs.nms.v1_21_R3.util.NMSImpl.markPoseDirty and occurs during the NPCLinkToPlayerEvent. It seems the NPC’s Minecraft entity handle becomes null, causing Citizens to fail when updating the NPC’s state post-kill.
Steps to Reproduce:
Create a Citizens NPC with the following setup:
Entity type: PLAYER
Add SentinelTrait
Configure Sentinel: sentinel.addTarget("PLAYERS"), sentinel.reach = 3.2, sentinel.fightback = true, sentinel.setHealth(20.0)
Spawn the NPC in the game world.
Allow the NPC to attack and kill a player (e.g., via melee combat).
Observe the server console for the error.
Message: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.getEntityData()" because "handle" is null
Location: NMSImpl.markPoseDirty(NMSImpl.java:1231)
Event: NPCLinkToPlayerEvent
Stack Trace: Starts at net.citizensnpcs.EventListen.onNPCLinkToPlayer(EventListen.java:534) and involves entity tracking updates (ChunkMap$TrackedEntity). The full trace is lengthy; I can provide it via pastebin or Discord if needed.
Expected Behavior:
The NPC should kill the player without causing a server error, and Citizens should handle the NPC’s state update (e.g., pose or visibility) gracefully.
Actual Behavior:
The server logs a NullPointerException, indicating Citizens tries to access the NPC’s entity data after its handle becomes null, likely due to the player’s death altering the game state.