mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-17 13:24:17 -07:00
Performance update to remove several very high counts of temp object creation
This commit is contained in:
@@ -175,7 +175,9 @@ public abstract class EntityLiving extends Entity {
|
||||
|
||||
this.extinguish();
|
||||
} else {
|
||||
this.setAirTicks(maxAirTicks); // CraftBukkit - update maxAirTicks if no longer 300
|
||||
if (this.getAirTicks() != 300) {
|
||||
this.setAirTicks(maxAirTicks);
|
||||
}
|
||||
}
|
||||
|
||||
this.aw = this.ax;
|
||||
|
@@ -11,9 +11,9 @@ public class EntityTracker {
|
||||
private IntHashMap trackedEntities = new IntHashMap();
|
||||
private MinecraftServer c;
|
||||
private int d;
|
||||
private int e;
|
||||
private World e; // CraftBukkit - change type
|
||||
|
||||
public EntityTracker(MinecraftServer minecraftserver, int i) {
|
||||
public EntityTracker(MinecraftServer minecraftserver, World i) { // CraftBukkit - change method signature
|
||||
this.c = minecraftserver;
|
||||
this.e = i;
|
||||
this.d = minecraftserver.serverConfigurationManager.a();
|
||||
@@ -94,7 +94,7 @@ public class EntityTracker {
|
||||
|
||||
this.a.add(entitytrackerentry);
|
||||
this.trackedEntities.a(entity.id, entitytrackerentry);
|
||||
entitytrackerentry.scanPlayers(this.c.getWorldServer(this.e).players);
|
||||
entitytrackerentry.scanPlayers(this.e.players); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class EntityTracker {
|
||||
while (iterator.hasNext()) {
|
||||
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
|
||||
|
||||
entitytrackerentry.track(this.c.getWorldServer(this.e).players);
|
||||
entitytrackerentry.track(this.e.players); // CraftBukkit
|
||||
if (entitytrackerentry.m && entitytrackerentry.tracker instanceof EntityPlayer) {
|
||||
arraylist.add((EntityPlayer) entitytrackerentry.tracker);
|
||||
}
|
||||
|
@@ -267,7 +267,7 @@ public class MinecraftServer implements Runnable, ICommandListener, IMinecraftSe
|
||||
|
||||
this.server.getPluginManager().callEvent(new WorldInitEvent(world.getWorld()));
|
||||
|
||||
world.tracker = new EntityTracker(this, dimension);
|
||||
world.tracker = new EntityTracker(this, world); // CraftBukkit
|
||||
world.addIWorldAccess(new WorldManager(this, world));
|
||||
world.difficulty = this.propertyManager.getInt("difficulty", 1);
|
||||
world.setSpawnFlags(this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -7,11 +8,28 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
// CraftBukkit
|
||||
import org.bukkit.craftbukkit.util.LongAbstractHashtable;
|
||||
import org.bukkit.craftbukkit.util.EntryBase;
|
||||
import org.bukkit.craftbukkit.util.LongHash;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
|
||||
public final class SpawnerCreature {
|
||||
|
||||
private static HashMap b = new HashMap();
|
||||
// private static HashMap b = new HashMap(); // CraftBukkit -- moved local to spawnEntities
|
||||
static private class ChunkEntry extends EntryBase {
|
||||
public boolean spawn;
|
||||
public ChunkEntry (int x, int z, boolean spawn) {
|
||||
super(LongHash.toLong(x, z));
|
||||
this.spawn = spawn;
|
||||
}
|
||||
int getX() {
|
||||
return LongHash.msw(key);
|
||||
}
|
||||
int getZ() {
|
||||
return LongHash.lsw(key);
|
||||
}
|
||||
}
|
||||
|
||||
protected static final Class[] a = new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class};
|
||||
|
||||
public SpawnerCreature() {}
|
||||
@@ -28,7 +46,9 @@ public final class SpawnerCreature {
|
||||
if (!flag && !flag1) {
|
||||
return 0;
|
||||
} else {
|
||||
b.clear();
|
||||
// b.clear(); // CraftBukkit
|
||||
LongAbstractHashtable chunkCoords; // CraftBukkit
|
||||
chunkCoords = new LongAbstractHashtable() {};
|
||||
|
||||
int i;
|
||||
int j;
|
||||
@@ -43,19 +63,22 @@ public final class SpawnerCreature {
|
||||
for (int l = -b0; l <= b0; ++l) {
|
||||
for (int i1 = -b0; i1 <= b0; ++i1) {
|
||||
boolean flag2 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0;
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(l + k, i1 + j);
|
||||
// CraftBukkit start
|
||||
long chunkCoord = LongHash.toLong(l + k, i1 + j);
|
||||
|
||||
if (!flag2) {
|
||||
b.put(chunkcoordintpair, Boolean.valueOf(false));
|
||||
} else if (!b.containsKey(chunkcoordintpair)) {
|
||||
b.put(chunkcoordintpair, Boolean.valueOf(true));
|
||||
chunkCoords.put(new ChunkEntry(l + k, i1 + j, false));
|
||||
} else if (!chunkCoords.containsKey(chunkCoord)) {
|
||||
chunkCoords.put(new ChunkEntry(l + k, i1 + j, true));
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
||||
ArrayList<EntryBase> entries = chunkCoords.entries(); // CraftBukkit
|
||||
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
|
||||
|
||||
j = aenumcreaturetype.length;
|
||||
@@ -63,15 +86,14 @@ public final class SpawnerCreature {
|
||||
for (int j1 = 0; j1 < j; ++j1) {
|
||||
EnumCreatureType enumcreaturetype = aenumcreaturetype[j1];
|
||||
|
||||
if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * b.size() / 256) {
|
||||
Iterator iterator = b.keySet().iterator();
|
||||
|
||||
if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * entries.size() / 256) {
|
||||
|
||||
label108:
|
||||
while (iterator.hasNext()) {
|
||||
ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator.next();
|
||||
|
||||
if (!((Boolean) b.get(chunkcoordintpair1)).booleanValue()) {
|
||||
ChunkPosition chunkposition = a(world, chunkcoordintpair1.x * 16, chunkcoordintpair1.z * 16);
|
||||
for (EntryBase base : entries) {
|
||||
ChunkEntry entry = (SpawnerCreature.ChunkEntry) base;
|
||||
if (!entry.spawn) {
|
||||
ChunkPosition chunkposition = a(world, LongHash.msw(entry.getX()) * 16, entry.getZ() * 16);
|
||||
int k1 = chunkposition.x;
|
||||
int l1 = chunkposition.y;
|
||||
int i2 = chunkposition.z;
|
||||
|
@@ -14,6 +14,8 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.util.LongHash;
|
||||
import org.bukkit.craftbukkit.util.LongHashset;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
@@ -74,7 +76,7 @@ public class World implements IBlockAccess {
|
||||
private boolean S;
|
||||
public boolean allowMonsters; // CraftBukkit - private -> public
|
||||
public boolean allowAnimals; // CraftBukkit - private -> public
|
||||
private Set T;
|
||||
private LongHashset T; // CraftBukkit
|
||||
private int U;
|
||||
int[] H;
|
||||
private List V;
|
||||
@@ -145,7 +147,7 @@ public class World implements IBlockAccess {
|
||||
this.R = new ArrayList();
|
||||
this.allowMonsters = true;
|
||||
this.allowAnimals = true;
|
||||
this.T = new HashSet();
|
||||
this.T = new LongHashset(); // CraftBukkit
|
||||
this.U = this.random.nextInt(12000);
|
||||
this.H = new int['\u8000'];
|
||||
this.V = new ArrayList();
|
||||
@@ -1856,7 +1858,7 @@ public class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
protected void k() {
|
||||
this.T.clear();
|
||||
// this.T.clear(); // CraftBukkit -- removed
|
||||
// MethodProfiler.a("buildList"); // CraftBukkit -- not in production code
|
||||
|
||||
int i;
|
||||
@@ -1870,7 +1872,7 @@ public class World implements IBlockAccess {
|
||||
|
||||
for (j = -b0; j <= b0; ++j) {
|
||||
for (int i1 = -b0; i1 <= b0; ++i1) {
|
||||
this.T.add(new ChunkCoordIntPair(j + k, i1 + l));
|
||||
this.T.add(LongHash.toLong(j + k, i1 + l)); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1883,15 +1885,19 @@ public class World implements IBlockAccess {
|
||||
int j1 = 0;
|
||||
|
||||
// MethodProfiler.a(); // CraftBukkit -- not in production code
|
||||
Iterator iterator = this.T.iterator();
|
||||
// Iterator iterator = this.T.iterator(); CraftBukkit == removed
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next();
|
||||
int k1 = chunkcoordintpair.x * 16;
|
||||
// CraftBukkit start
|
||||
for (long chunkCoord : this.T.popAll()) {
|
||||
int chunkX = LongHash.msw(chunkCoord);
|
||||
int chunkZ = LongHash.lsw(chunkCoord);
|
||||
// ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next();
|
||||
int k1 = chunkX * 16;
|
||||
|
||||
j = chunkcoordintpair.z * 16;
|
||||
j = chunkZ * 16;
|
||||
// MethodProfiler.a("getChunk"); // CraftBukkit -- not in production code
|
||||
Chunk chunk = this.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
Chunk chunk = this.getChunkAt(chunkX, chunkZ);
|
||||
// CraftBukkit end
|
||||
|
||||
// MethodProfiler.b("tickChunk"); // CraftBukkit -- not in production code
|
||||
chunk.i();
|
||||
|
Reference in New Issue
Block a user