mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 20:25:19 +01:00
Check for behavior controller modification - fixes #1901
This commit is contained in:
parent
6f4ec9c4cc
commit
890bc4ceab
@ -17,6 +17,7 @@ import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
|||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.Util;
|
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.BlockPosition;
|
||||||
import net.minecraft.server.v1_14_R1.DamageSource;
|
import net.minecraft.server.v1_14_R1.DamageSource;
|
||||||
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
||||||
@ -48,6 +49,7 @@ public class VillagerController extends MobEntityController {
|
|||||||
private boolean blockTrades = true;
|
private boolean blockTrades = true;
|
||||||
boolean calledNMSHeight = false;
|
boolean calledNMSHeight = false;
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
private BehaviorController<EntityVillager> previousBehaviorController;
|
||||||
|
|
||||||
public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World world) {
|
public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World world) {
|
||||||
this(types, world, null);
|
this(types, world, null);
|
||||||
@ -230,8 +232,9 @@ public class VillagerController extends MobEntityController {
|
|||||||
@Override
|
@Override
|
||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (this.behaviorMap == null) {
|
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||||
|
this.previousBehaviorController = this.getBehaviorController();
|
||||||
}
|
}
|
||||||
if (this.behaviorMap.size() > 0) {
|
if (this.behaviorMap.size() > 0) {
|
||||||
this.behaviorMap.clear();
|
this.behaviorMap.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user