2018-10-05 05:18:46 +02:00
|
|
|
From fe1b8ed7df7010ef1aa4dbac5e2c88df3962df29 Mon Sep 17 00:00:00 2001
|
2018-07-04 09:56:57 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Wed, 4 Jul 2018 03:39:51 -0400
|
|
|
|
Subject: [PATCH] Avoid Chunk Lookups for Entity/TileEntity Current Chunk
|
|
|
|
|
|
|
|
In many places where we simply want the current chunk the entity
|
|
|
|
is in, instead of doing a hashmap lookup for it, we now have access
|
|
|
|
to the object directly on the Entity/TileEntity object we can directly grab.
|
|
|
|
|
|
|
|
Use that local value instead to reduce lookups in many hot places.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2018-10-05 05:18:46 +02:00
|
|
|
index 1652d88298..982b3de65c 100644
|
2018-07-04 09:56:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
@@ -719,6 +719,7 @@ public class Chunk implements IChunkAccess {
|
2018-07-19 01:16:19 +02:00
|
|
|
((HeightMap) this.heightMap.get(heightmap_type)).a(along);
|
2018-07-04 09:56:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ public void removeEntity(Entity entity) { b(entity); } // Paper - OBFHELPER
|
|
|
|
public void b(Entity entity) {
|
2018-07-19 01:16:19 +02:00
|
|
|
this.a(entity, entity.af);
|
2018-07-04 09:56:57 +02:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2018-09-18 03:50:02 +02:00
|
|
|
index 7cf4a9c11e..ee2cdb897c 100644
|
2018-07-04 09:56:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-09-18 03:50:02 +02:00
|
|
|
@@ -1258,12 +1258,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-04 09:56:57 +02:00
|
|
|
int j;
|
|
|
|
// Paper start - Set based removal lists
|
2018-07-19 01:16:19 +02:00
|
|
|
for (Entity e : this.g) {
|
2018-07-04 09:56:57 +02:00
|
|
|
+ /*
|
|
|
|
j = e.getChunkZ();
|
|
|
|
int k = e.getChunkX();
|
|
|
|
|
2018-07-19 01:16:19 +02:00
|
|
|
if (e.inChunk && this.isChunkLoaded(k, j, true)) {
|
2018-07-04 09:56:57 +02:00
|
|
|
this.getChunkAt(k, j).b(e);
|
|
|
|
- }
|
|
|
|
+ }*/
|
2018-07-19 01:16:19 +02:00
|
|
|
+ Chunk chunk = e.inChunk ? e.getCurrentChunk() : null;
|
2018-07-04 09:56:57 +02:00
|
|
|
+ if (chunk != null) chunk.removeEntity(e);
|
|
|
|
}
|
|
|
|
|
2018-07-19 01:16:19 +02:00
|
|
|
for (Entity e : this.g) {
|
2018-09-18 03:50:02 +02:00
|
|
|
@@ -1324,12 +1327,17 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-19 01:16:19 +02:00
|
|
|
this.methodProfiler.e();
|
2018-07-04 09:56:57 +02:00
|
|
|
this.methodProfiler.a("remove");
|
|
|
|
if (entity.dead) {
|
|
|
|
+ // Paper start
|
|
|
|
+ /*
|
2018-07-19 01:16:19 +02:00
|
|
|
j = entity.ae;
|
|
|
|
int l = entity.ag;
|
2018-07-04 09:56:57 +02:00
|
|
|
|
2018-07-19 01:16:19 +02:00
|
|
|
if (entity.inChunk && this.isChunkLoaded(j, l, true)) {
|
2018-07-04 09:56:57 +02:00
|
|
|
this.getChunkAt(j, l).b(entity);
|
|
|
|
- }
|
|
|
|
+ }*/
|
2018-07-19 01:16:19 +02:00
|
|
|
+ Chunk chunk = entity.inChunk ? entity.getCurrentChunk() : null;
|
2018-07-04 09:56:57 +02:00
|
|
|
+ if (chunk != null) chunk.removeEntity(entity);
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
guardEntityList = false; // Spigot
|
|
|
|
this.entityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable
|
2018-09-18 03:50:02 +02:00
|
|
|
@@ -1374,7 +1382,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-04 09:56:57 +02:00
|
|
|
BlockPosition blockposition = tileentity.getPosition();
|
|
|
|
|
|
|
|
// Paper start - Skip ticking in chunks scheduled for unload
|
|
|
|
- net.minecraft.server.Chunk chunk = this.getChunkIfLoaded(blockposition);
|
|
|
|
+ net.minecraft.server.Chunk chunk = tileentity.getCurrentChunk();
|
|
|
|
boolean shouldTick = chunk != null;
|
|
|
|
if(this.paperConfig.skipEntityTickingInChunksScheduledForUnload)
|
2018-08-26 20:11:49 +02:00
|
|
|
shouldTick = shouldTick && chunk.scheduledForUnload == null;
|
2018-09-18 03:50:02 +02:00
|
|
|
@@ -1410,8 +1418,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-04 09:56:57 +02:00
|
|
|
tilesThisCycle--;
|
|
|
|
this.tileEntityListTick.remove(tileTickPosition--);
|
|
|
|
//this.tileEntityList.remove(tileentity); // Paper - remove unused list
|
|
|
|
- if (this.isLoaded(tileentity.getPosition())) {
|
2018-07-04 23:29:10 +02:00
|
|
|
- this.getChunkAtWorldCoords(tileentity.getPosition()).d(tileentity.getPosition());
|
2018-07-04 09:56:57 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ net.minecraft.server.Chunk chunk = tileentity.getCurrentChunk();
|
|
|
|
+ if (chunk != null) {
|
2018-07-04 23:29:10 +02:00
|
|
|
+ chunk.removeTileEntity(tileentity.getPosition());
|
2018-07-04 09:56:57 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
2018-07-04 23:29:10 +02:00
|
|
|
}
|
2018-07-04 09:56:57 +02:00
|
|
|
--
|
2018-09-15 18:10:26 +02:00
|
|
|
2.19.0
|
2018-07-04 09:56:57 +02:00
|
|
|
|