mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 19:16:34 +01:00
Possible fix and optimisation for PlayerEntitySenses
This commit is contained in:
parent
0ce5eaeafe
commit
ef503120fa
@ -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);
|
||||
}
|
@ -70,6 +70,7 @@ public class HorseController extends MobEntityController {
|
||||
if (npc == null) {
|
||||
super.c();
|
||||
} else {
|
||||
NMS.setStepHeight(this, 1);
|
||||
updateAIWithMovement();
|
||||
npc.update();
|
||||
}
|
||||
|
@ -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<Class<?>, Integer> ENTITY_CLASS_TO_INT;
|
||||
|
||||
private static final Map<Class<?>, Constructor<?>> ENTITY_CONSTRUCTOR_CACHE = new WeakHashMap<Class<?>, Constructor<?>>();
|
||||
private static Map<Integer, Class<?>> ENTITY_INT_TO_CLASS;
|
||||
private static Map<Class<?>, Integer> MC_ENTITY_CLASS_TO_INT = null;
|
||||
private static Map<Integer, Class<?>> 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<Class<?>, Integer> MC_ENTITY_CLASS_TO_INT = null;
|
||||
private static Map<Integer, Class<?>> 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");
|
||||
|
@ -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<Entity> seenEntities = new ArrayList<Entity>();
|
||||
List<Entity> unseenEntities = new ArrayList<Entity>();
|
||||
private final EntityLiving entity;
|
||||
private final Set<Entity> seenEntities = new HashSet<Entity>();
|
||||
private final Set<Entity> unseenEntities = new HashSet<Entity>();
|
||||
|
||||
public PlayerEntitySenses(EntityLiving entityinsentient) {
|
||||
this.entity = entityinsentient;
|
||||
|
Loading…
Reference in New Issue
Block a user