mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Fix some performance regression in last patch
This commit is contained in:
parent
c0ea8846b6
commit
7d5a5ed52f
1 changed files with 29 additions and 18 deletions
|
@ -7,7 +7,7 @@ Optimizes mob spawning by keeping a count of entities by type
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java b/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
|
||||
new file mode 100644
|
||||
index 0000000000..f7b65ccf73
|
||||
index 0000000000..35104542c5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldEntityList.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
@ -45,15 +45,13 @@ index 0000000000..f7b65ccf73
|
|||
+
|
||||
+ @Override
|
||||
+ public boolean removeAll(Collection<?> c) {
|
||||
+ // TODO: Optimize this
|
||||
+ boolean removed = false;
|
||||
+ for (Object e : c) {
|
||||
+ if (remove(e)) {
|
||||
+ removed = true;
|
||||
+ if (e instanceof Entity && ((Entity) e).getWorld() == world) {
|
||||
+ updateEntityCount((Entity) e, -1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return removed;
|
||||
+ return super.removeAll(c);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
@ -110,12 +108,21 @@ index 0000000000..f7b65ccf73
|
|||
+ if (entity instanceof EntityInsentient) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ if (amt > 0 && entityinsentient.isDespawnableByDefault() && entityinsentient.isPersistent()) {
|
||||
+ entityinsentient.countsAgainstSpawnLimit = false;
|
||||
+ return;
|
||||
+ } else if (amt < 0 && !entityinsentient.countsAgainstSpawnLimit) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ if (amt < 0) {
|
||||
+ if (!entity.hasBeenCounted) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Only remove once, we remove from if the entity list is guarded, but may be called later
|
||||
+ entity.hasBeenCounted = false;
|
||||
+ } else {
|
||||
+ if (entity.hasBeenCounted) {
|
||||
+ return;
|
||||
+ }
|
||||
+ entity.hasBeenCounted = true;
|
||||
+ }
|
||||
+
|
||||
+ for (EnumCreatureType type : EnumCreatureType.values()) {
|
||||
+ if (type.matches(entity)) {
|
||||
|
@ -125,18 +132,22 @@ index 0000000000..f7b65ccf73
|
|||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 41a951d580..03d54a7ef4 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
private boolean az;
|
||||
public boolean dead;
|
||||
public boolean shouldBeRemoved; // Paper
|
||||
+ public boolean hasBeenCounted = false; // Paper
|
||||
public float width;
|
||||
public float length;
|
||||
public float J;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
index 903434e5f4..0ad5e1ab47 100644
|
||||
index 903434e5f4..68765d2aad 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityInsentient extends EntityLiving {
|
||||
public float[] dropChanceArmor;
|
||||
// public boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving
|
||||
public boolean persistent;
|
||||
+ public boolean countsAgainstSpawnLimit = true; // Paper
|
||||
private final Map<PathType, Float> bH;
|
||||
public MinecraftKey bI; // CraftBukkit private -> public
|
||||
public long bJ; // CraftBukkit private -> public
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityInsentient extends EntityLiving {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue