Updated Upstream (Paper & Tuinity)

Upstream has released updates that appear to apply and compile correctly

Paper Changes:
fc4c0bc42 Reset shield blocking on dimension change

Tuinity Changes:
06ce05bbd Fix broken chunk loading while under high block update stress
This commit is contained in:
BillyGalbreath
2021-01-26 17:49:07 -06:00
parent 7b0b3f74e1
commit d72b22863d
13 changed files with 64 additions and 68 deletions

View File

@@ -10474,7 +10474,7 @@ index 7636a51a7ef0aa05b5b2aaa9d17e7b551dedac96..480a02a8f6ec7110f9af8f2037fdc09a
double d0 = this.locX() + vec3d.x;
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 04d505c7a19775d0353c10424a84a1ce8885dc2c..9f5b7243ccbe0729a061345c25033d9145b91b3f 100644
index baa82134d1f56a4d370db3012207e0f2b2fcd9ed..2797941b53fa47316f90a86c8b2b4c2f059df223 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -527,6 +527,185 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -10760,7 +10760,7 @@ index c4a83448ed4513f6e4ab179d1d43e5bb0cb13641..5c3eb4fc7e5aec2ad8d0050673fc8f4d
Vec3D vec3d1 = raytrace1.a();
VoxelShape voxelshape = raytrace1.a(iblockdata, this, blockposition);
diff --git a/src/main/java/net/minecraft/server/IChunkAccess.java b/src/main/java/net/minecraft/server/IChunkAccess.java
index 180b6b58dc5663158db84b6f1257591439b48c31..564703d87c47eab34a23cb5d159cc66cdbfc00a3 100644
index 180b6b58dc5663158db84b6f1257591439b48c31..eb0d794b7275af7f860e7c7b85a9e3b2aa4a863f 100644
--- a/src/main/java/net/minecraft/server/IChunkAccess.java
+++ b/src/main/java/net/minecraft/server/IChunkAccess.java
@@ -24,6 +24,36 @@ public interface IChunkAccess extends IBlockAccess, IStructureAccess {
@@ -10808,14 +10808,16 @@ index 180b6b58dc5663158db84b6f1257591439b48c31..564703d87c47eab34a23cb5d159cc66c
Stream<BlockPosition> m();
TickList<Block> n();
@@ -142,6 +173,7 @@ public interface IChunkAccess extends IBlockAccess, IStructureAccess {
@@ -142,7 +173,9 @@ public interface IChunkAccess extends IBlockAccess, IStructureAccess {
return ashortlist[i];
}
+ default boolean isLit() { return this.r(); } // Tuinity - OBFHELPER
boolean r();
+ default void setLit(boolean lit) { this.b(lit); } // Tuinity - OBFHELPER
void b(boolean flag);
}
diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java
index 582a5695bac7d078e3022b8ee70c512c0680d992..5601088cd5024a40e8296bab979f43de924c2b62 100644
--- a/src/main/java/net/minecraft/server/IChunkLoader.java
@@ -10992,7 +10994,7 @@ index b98e60772bad7e06845b50fdc11e98c0ea775d3d..e0bbfe1422cbad811ecb43d7436380d8
while (objectiterator.hasNext()) {
entry = (Entry) objectiterator.next();
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..168fe23177dfaa401396c1e460f56273ee0a59e4 100644
index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..7833846ffa52353f5a67da16df030f6edf2d30ec 100644
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
@@ -2,6 +2,11 @@ package net.minecraft.server;
@@ -11108,8 +11110,8 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..168fe23177dfaa401396c1e460f56273
+ } else {
+ this.holdingChunks.put(coordinate, current + 1);
+ }
+ }
+
}
+ protected final void releaseLightWorkChunk(int chunkX, int chunkZ) {
+ final long coordinate = MCUtil.getCoordinateKey(chunkX, chunkZ);
+ final int current = this.holdingChunks.get(coordinate);
@@ -11174,8 +11176,8 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..168fe23177dfaa401396c1e460f56273
+ }
+
+ return CompletableFuture.completedFuture(playerChunk.getAvailableChunkNow());
}
+ }
+
+ // note: task is discarded if the chunk is not at light status or if the chunk is not lit
+ protected final void scheduleLightWorkTask(int chunkX, int chunkZ, LightEngineThreaded.Update type, Runnable task) {
+ if (!org.bukkit.Bukkit.isPrimaryThread()) {
@@ -11327,47 +11329,38 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..168fe23177dfaa401396c1e460f56273
this.a(chunkcoordintpair.x, chunkcoordintpair.z, () -> {
return 0;
}, LightEngineThreaded.Update.PRE_UPDATE, SystemUtils.a(() -> {
@@ -277,6 +526,7 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
return;
}
// Paper end
+ if (this.theLightEngine == null) { // Tuinity - replace light engine impl
ChunkSection[] achunksection = ichunkaccess.getSections();
@@ -264,6 +513,30 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
public CompletableFuture<IChunkAccess> a(IChunkAccess ichunkaccess, boolean flag) {
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
for (int i = 0; i < 16; ++i) {
@@ -293,16 +543,29 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
super.a(blockposition, ichunkaccess.g(blockposition));
});
}
+ } else { // Tuinity start - replace light engine impl
+ // Tuinity start - replace light engine
+ if (this.theLightEngine != null) {
+ // make the completion of this future only depend on pre-update execution
+ // post-update is used for block updates, so by using pre here we prioritise chunk lighting
+ return CompletableFuture.supplyAsync(() -> {
+ Boolean[] emptySections = com.tuinity.tuinity.chunk.light.StarLightEngine.getEmptySectionsForChunk(ichunkaccess);
+ if (!flag) {
+ ichunkaccess.setLit(false);
+ this.theLightEngine.lightChunk(ichunkaccess, emptySections);
+ ichunkaccess.setLit(true);
+ } else {
+ this.theLightEngine.forceLoadInChunk(ichunkaccess, emptySections);
+ // can't really force the chunk to be edged checked, as we need neighbouring chunks - but we don't have
+ // them, so if it's not loaded then i guess we can't do edge checks. later loads of the chunk should
+ // catch what we miss here.
+ this.theLightEngine.checkChunkEdges(chunkcoordintpair.x, chunkcoordintpair.z);
+ }
+
+ } // Tuinity end - replace light engine impl
// this.d.c(chunkcoordintpair); // Paper - move into post task below
}, () -> {
return "lightChunk " + chunkcoordintpair + " " + flag;
// Paper start - merge the 2 together
}), () -> {
- this.d.c(chunkcoordintpair); // Paper - release light tickets as post task to ensure they stay loaded until fully done
+ this.d.c(chunkcoordintpair); // Paper - release light tickets as post task to ensure they stay loaded until fully done // Tuinity - diff on change, copied to top of method for early return if the chunk is already lit
if (skippedPre[0]) return; // Paper - future's already complete
ichunkaccess.b(true);
- super.b(chunkcoordintpair, false);
+ if (this.theLightEngine == null) super.b(chunkcoordintpair, false); // Tuinity - replace light engine impl
// Paper start
future.complete(ichunkaccess);
});
@@ -311,7 +574,7 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
+ // safe to move the release light to here, as all the work required is done now
+ this.playerChunkMap.removeLightTicket(chunkcoordintpair); // copied from below
+ return ichunkaccess;
+ }, (runnable) -> {
+ this.scheduleTask(chunkcoordintpair.x, chunkcoordintpair.z, LightEngineThreaded.Update.PRE_UPDATE, runnable);
+ });
+ }
+ // Tuinity end - replace light engine
+
// Paper start
//ichunkaccess.b(false); // Don't need to disable this
long pair = chunkcoordintpair.pair();
@@ -311,7 +584,7 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
}
public void queueUpdate() {
@@ -11376,7 +11369,7 @@ index 2f9c97dd4e1d705a87772d18c7ab4883a876af08..168fe23177dfaa401396c1e460f56273
this.b.a((() -> { // Paper - decompile error
this.b();
this.g.set(false);
@@ -325,17 +588,36 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
@@ -325,17 +598,36 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
private final java.util.List<Runnable> pre = new java.util.ArrayList<>();
private final java.util.List<Runnable> post = new java.util.ArrayList<>();
private void b() {
@@ -12903,7 +12896,7 @@ index 42b12ad5ba68bdf8f76704ddd970715770183de0..ac82f1791ce07e9a23cf97ca34974ab2
if (chunk != null) {
playerchunkmap.callbackExecutor.execute(() -> {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092802fa932 100644
index 49008cdec739b19409fdaf1b0ed806a6c0e93200..a42571cfd2c9c80df27e59db832cb64c2a64e141 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -121,31 +121,28 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -13163,7 +13156,7 @@ index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092
// Paper end
if (chunkHolder.protoChunk != null) {try (Timing ignored2 = this.world.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings // Paper - chunk is created async
@@ -1246,7 +1321,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1246,9 +1321,13 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
// Paper end
this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable));
@@ -13174,8 +13167,11 @@ index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092
+ // Tuinity end - force competion on the main thread
}
+ protected final void removeLightTicket(ChunkCoordIntPair chunkcoordintpair) { this.c(chunkcoordintpair); } // Tuinity - OBFHELPER
protected void c(ChunkCoordIntPair chunkcoordintpair) {
@@ -1498,6 +1576,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.executor.a(SystemUtils.a(() -> {
this.chunkDistanceManager.b(TicketType.LIGHT, chunkcoordintpair, 33 + ChunkStatus.a(ChunkStatus.FEATURES), chunkcoordintpair);
@@ -1498,6 +1577,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
public void setViewDistance(int i) { // Paper - public
@@ -13183,7 +13179,7 @@ index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092
int j = MathHelper.clamp(i + 1, 3, 33); // Paper - diff on change, these make the lower view distance limit 2 and the upper 32
if (j != this.viewDistance) {
@@ -1511,6 +1590,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1511,6 +1591,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper start - no-tick view distance
public final void setNoTickViewDistance(int viewDistance) {
@@ -13191,7 +13187,7 @@ index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092
viewDistance = viewDistance == -1 ? -1 : MathHelper.clamp(viewDistance, 2, 32);
this.noTickViewDistance = viewDistance;
@@ -1626,7 +1706,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1626,7 +1707,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
if (Thread.currentThread() != com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE) {
com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE.scheduleSave(
this.world, chunkcoordintpair.x, chunkcoordintpair.z, null, nbttagcompound,
@@ -13200,7 +13196,7 @@ index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092
return;
}
super.write(chunkcoordintpair, nbttagcompound);
@@ -1710,6 +1790,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1710,6 +1791,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow();
}
// Paper end
@@ -13212,7 +13208,7 @@ index 49008cdec739b19409fdaf1b0ed806a6c0e93200..16779ffa00caf32752170700e1d88092
// Paper start - async io
@@ -2037,22 +2122,25 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -2037,22 +2123,25 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private final void processTrackQueue() {
this.world.timings.tracker1.startTiming();
try {