Check for behavior controller modification - fixes #1901

This commit is contained in:
fullwall 2019-09-17 19:24:38 +08:00
parent 6f4ec9c4cc
commit 890bc4ceab

View File

@ -17,6 +17,7 @@ import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
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;
@ -48,6 +49,7 @@ public class VillagerController extends MobEntityController {
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);
@ -230,8 +232,9 @@ public class VillagerController extends MobEntityController {
@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();