diff --git a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java index 398cb4d89..6ec80c0fc 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java @@ -56,6 +56,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { private final CitizensNPC npc; private final Location packetLocationCache = new Location(null, 0, 0, 0); private int packetUpdateCount; + private int sensesUpdateCount = 0; private int useListName = -1; public EntityHumanNPC(MinecraftServer minecraftServer, World world, String string, @@ -136,8 +137,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { // swallow } - Y = 1F; // stepHeight - must not stay as the default 0 (breaks steps). - // Check the EntityPlayer constructor for the new name. + NMS.setStepHeight(this, 1);// stepHeight - must not stay as the default + // 0 (breaks steps). try { socket.close(); @@ -234,7 +235,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { } public void updateAI() { - entitySenses.a(); + if (++sensesUpdateCount == 5) { + sensesUpdateCount = 0; + entitySenses.a(); + } controllerMove.c(); controllerLook.a(); controllerJump.b(); @@ -320,6 +324,5 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { } private static final float EPSILON = 0.005F; - private static final Location LOADED_LOCATION = new Location(null, 0, 0, 0); } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/npc/entity/HorseController.java b/src/main/java/net/citizensnpcs/npc/entity/HorseController.java index bbe98eb94..48eb808ac 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/HorseController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/HorseController.java @@ -70,6 +70,7 @@ public class HorseController extends MobEntityController { if (npc == null) { super.c(); } else { + NMS.setStepHeight(this, 1); updateAIWithMovement(); npc.update(); } diff --git a/src/main/java/net/citizensnpcs/util/NMS.java b/src/main/java/net/citizensnpcs/util/NMS.java index d895b24af..53f714801 100644 --- a/src/main/java/net/citizensnpcs/util/NMS.java +++ b/src/main/java/net/citizensnpcs/util/NMS.java @@ -319,6 +319,10 @@ public class NMS { } } + public static void setStepHeight(EntityLiving entity, float height) { + entity.Y = height; + } + public static boolean shouldJump(net.minecraft.server.v1_6_R2.Entity entity) { if (JUMP_FIELD == null || !(entity instanceof EntityLiving)) return false; @@ -432,15 +436,13 @@ public class NMS { } private static final float DEFAULT_SPEED = 1F; - private static Map, Integer> ENTITY_CLASS_TO_INT; - private static final Map, Constructor> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap, Constructor>(); private static Map> ENTITY_INT_TO_CLASS; - private static Map, Integer> MC_ENTITY_CLASS_TO_INT = null; - private static Map> MC_ENTITY_INT_TO_CLASS = null; private static Field GOAL_FIELD = getField(PathfinderGoalSelector.class, "a"); private static final Field JUMP_FIELD = getField(EntityLiving.class, "bd"); + private static Map, Integer> MC_ENTITY_CLASS_TO_INT = null; + private static Map> MC_ENTITY_INT_TO_CLASS = null; private static Field NAVIGATION_WORLD_FIELD = getField(Navigation.class, "b"); private static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0); private static Field PATHFINDING_RANGE = getField(Navigation.class, "e"); diff --git a/src/main/java/net/citizensnpcs/util/nms/PlayerEntitySenses.java b/src/main/java/net/citizensnpcs/util/nms/PlayerEntitySenses.java index 54f3ab198..b094e10d3 100644 --- a/src/main/java/net/citizensnpcs/util/nms/PlayerEntitySenses.java +++ b/src/main/java/net/citizensnpcs/util/nms/PlayerEntitySenses.java @@ -1,15 +1,15 @@ package net.citizensnpcs.util.nms; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import net.minecraft.server.v1_6_R2.Entity; import net.minecraft.server.v1_6_R2.EntityLiving; public class PlayerEntitySenses { - EntityLiving entity; - List seenEntities = new ArrayList(); - List unseenEntities = new ArrayList(); + private final EntityLiving entity; + private final Set seenEntities = new HashSet(); + private final Set unseenEntities = new HashSet(); public PlayerEntitySenses(EntityLiving entityinsentient) { this.entity = entityinsentient;