Skip to content

Commit

Permalink
Check for behavior controller modification - fixes #1901
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Sep 17, 2019
1 parent 6f4ec9c commit 890bc4c
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -17,6 +17,7 @@
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_14_R1.BehaviorController;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.DamageSource;
import net.minecraft.server.v1_14_R1.DataWatcherObject;
Expand Down Expand Up @@ -48,6 +49,7 @@ public static class EntityVillagerNPC extends EntityVillager implements NPCHolde
private boolean blockTrades = true;
boolean calledNMSHeight = false;
private final CitizensNPC npc;
private BehaviorController<EntityVillager> previousBehaviorController;

public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World world) {
this(types, world, null);
Expand Down Expand Up @@ -230,8 +232,9 @@ public boolean isLeashed() {
@Override
public void mobTick() {
if (npc != null) {
if (this.behaviorMap == null) {
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
this.behaviorMap = NMSImpl.getBehaviorMap(this);
this.previousBehaviorController = this.getBehaviorController();
}
if (this.behaviorMap.size() > 0) {
this.behaviorMap.clear();
Expand Down

0 comments on commit 890bc4c

Please sign in to comment.