mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-27 09:42:37 +01:00
Fix villagers still having AI
This commit is contained in:
parent
b02bcbe38b
commit
244e8dd343
@ -1,6 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
@ -42,10 +43,11 @@ public class VillagerController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private boolean blockingATrade;
|
||||
private boolean blockTrades = true;
|
||||
boolean calledNMSHeight = false;
|
||||
|
||||
boolean calledNMSHeight = false;
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World world) {
|
||||
@ -227,6 +229,14 @@ public class VillagerController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
@ -42,6 +43,7 @@ public class WanderingTraderController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityWanderingTraderNPC extends EntityVillagerTrader implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private boolean blockingATrade;
|
||||
private boolean blockTrades = true;
|
||||
boolean calledNMSHeight = false;
|
||||
@ -226,6 +228,14 @@ public class WanderingTraderController extends MobEntityController {
|
||||
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
}
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
|
@ -96,7 +96,7 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return (Set) wrapped.keySet();
|
||||
}
|
||||
|
||||
public void put(int entityId, MinecraftKey key, EntityTypes entityClass) {
|
||||
public void put(int entityId, MinecraftKey key, EntityTypes entityClass) {
|
||||
entities.put(key, entityClass);
|
||||
entityIds.put(entityClass, entityId);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -197,6 +198,7 @@ import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_14_R1.AdvancementDataPlayer;
|
||||
import net.minecraft.server.v1_14_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_14_R1.BehaviorController;
|
||||
import net.minecraft.server.v1_14_R1.Block;
|
||||
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_14_R1.BossBattleServer;
|
||||
@ -1428,6 +1430,15 @@ public class NMSImpl implements NMSBridge {
|
||||
entity.aG += entity.aF;
|
||||
}
|
||||
|
||||
public static TreeMap<?, ?> getBehaviorMap(EntityLiving entity) {
|
||||
try {
|
||||
return (TreeMap<?, ?>) BEHAVIOR_MAP.invoke(entity.getBehaviorController());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BlockPosition.PooledBlockPosition getBlockPositionBE(BlockPosition.PooledBlockPosition blockPos,
|
||||
double x, double y, double z) {
|
||||
try {
|
||||
@ -1642,6 +1653,7 @@ public class NMSImpl implements NMSBridge {
|
||||
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
|
||||
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
||||
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
|
||||
private static final MethodHandle BEHAVIOR_MAP = NMS.getGetter(BehaviorController.class, "c");
|
||||
private static final MethodHandle BLOCK_POSITION_B_D = NMS.getMethodHandle(BlockPosition.PooledBlockPosition.class,
|
||||
"c", false, double.class, double.class, double.class);
|
||||
private static final Map<Class<?>, EntityTypes<?>> CITIZENS_ENTITY_TYPES = Maps.newHashMap();
|
||||
|
Loading…
Reference in New Issue
Block a user