Skip to content

Commit

Permalink
Add NPC_METADATA_MARKER before teleporting
Browse files Browse the repository at this point in the history
This solves an issue I have, namely that I cannot check if a "Player" is an NPC on a PlayerTeleportEvent when the NPC is spawning. Fixes https://bitbucket.org/Lolmewn/stats/issues/292/citizen-denizen-npc-issue
  • Loading branch information
Lolmewn committed Aug 1, 2016
1 parent 5163729 commit 0037068
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/citizensnpcs/npc/CitizensNPC.java
Expand Up @@ -196,6 +196,8 @@ public boolean spawn(Location at) {

entityController.spawn(at, this);

getEntity().setMetadata(NPC_METADATA_MARKER, new FixedMetadataValue(CitizensAPI.getPlugin(), true));

boolean couldSpawn = !Util.isLoaded(at) ? false : NMS.addEntityToWorld(getEntity(), SpawnReason.CUSTOM);

// send skin packets, if applicable, before other NMS packets are sent
Expand All @@ -219,8 +221,6 @@ public boolean spawn(Location at) {

NMS.setHeadYaw(getEntity(), at.getYaw());

getEntity().setMetadata(NPC_METADATA_MARKER, new FixedMetadataValue(CitizensAPI.getPlugin(), true));

// Set the spawned state
getTrait(CurrentLocation.class).setLocation(at);
getTrait(Spawned.class).setSpawned(true);
Expand Down

0 comments on commit 0037068

Please sign in to comment.