Reuse object

This commit is contained in:
fullwall 2013-02-20 22:59:10 +08:00
parent 69d7db688c
commit 8023034a8c
2 changed files with 4 additions and 2 deletions

View File

@ -186,7 +186,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
}
private void updatePackets(boolean navigating) {
if (++packetUpdateCount >= 20) {
if (++packetUpdateCount >= 30) {
Location current = getBukkitEntity().getLocation(packetLocationCache);
Packet[] packets = new Packet[navigating ? 5 : 6];
if (!navigating) {

View File

@ -62,11 +62,13 @@ public class NMS {
private static Field LAND_SPEED_MODIFIER_FIELD;
private static final Map<EntityType, Float> MOVEMENT_SPEEDS = Maps.newEnumMap(EntityType.class);
private static Field NAVIGATION_WORLD_FIELD;
private static final Location packetCacheLocation = new Location(null, 0, 0, 0);
private static Field PATHFINDING_RANGE;
private static final Random RANDOM = Util.getFastRandom();
private static Set<Integer> SLAB_MATERIALS = Sets.newHashSet();
private static Field SPEED_FIELD;
private static Set<Integer> STAIR_MATERIALS = Sets.newHashSet();
private static Field THREAD_STOPPER;
public static void addOrRemoveFromPlayerList(LivingEntity bukkitEntity, boolean remove) {
@ -232,7 +234,7 @@ public class NMS {
if (ply == null || world != ply.getWorld()) {
continue;
}
if (location.distanceSquared(ply.getLocation()) > radius) {
if (location.distanceSquared(ply.getLocation(packetCacheLocation)) > radius) {
continue;
}
for (Packet packet : packets) {