Skip to content

Commit

Permalink
Updated Upstream (Paper & Tuinity)
Browse files Browse the repository at this point in the history
Upstream has released updates that appears to apply and compile correctly

Paper Changes:
6f66fa571 Fix Light Thread causing world memory leak - Fixes #4045
674230907 Improve EntityTargetLivingEntityEvent for 1.16 mobs

Tuinity Changes:
30dc21f Notify poi changes in setTypeAndDataRaw
  • Loading branch information
BillyGalbreath committed Aug 7, 2020
1 parent 60ce52a commit d6d9539
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion current-paper
@@ -1 +1 @@
1.16.1--57ffa5163aff13683299c03bda1dc3e019c523f4
1.16.1--e2ec806ca4dcf4854e569776c890609c89ca46c1
58 changes: 35 additions & 23 deletions patches/server/0001-Tuinity-Server-Changes.patch
Expand Up @@ -4017,7 +4017,7 @@ index c14cdb6024..8ec21eb955 100644
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 5c5ee28f23..46d8beae87 100644
index 03a79ff992..d59ef07e1c 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -119,31 +119,28 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
Expand Down Expand Up @@ -4087,10 +4087,11 @@ index 5c5ee28f23..46d8beae87 100644
int chunkX = MCUtil.getChunkCoordinate(player.locX());
int chunkZ = MCUtil.getChunkCoordinate(player.locZ());
// Note: players need to be explicitly added to distance maps before they can be updated
@@ -275,6 +275,29 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
@@ -276,6 +276,30 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper end

private final java.util.concurrent.ExecutorService lightThread;
+
+ // Tuinity start
+ public static enum RegionData implements com.tuinity.tuinity.chunk.SingleThreadChunkRegionManager.RegionDataCreator<RegionData> {
+ // Tuinity start - optimise notify()
Expand All @@ -4117,7 +4118,7 @@ index 5c5ee28f23..46d8beae87 100644
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag);
//this.visibleChunks = this.updatingChunks.clone(); // Paper - no more cloning
@@ -441,6 +464,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -442,6 +466,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
PlayerChunkMap.this.sendChunk(player, new ChunkCoordIntPair(rangeX, rangeZ), null, true, false); // unloaded, loaded
});
// Paper end - no-tick view distance
Expand All @@ -4127,23 +4128,23 @@ index 5c5ee28f23..46d8beae87 100644
}
// Paper start - Chunk Prioritization
public void queueHolderUpdate(PlayerChunk playerchunk) {
@@ -753,6 +779,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -754,6 +781,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {

@Nullable
private PlayerChunk a(long i, int j, @Nullable PlayerChunk playerchunk, int k) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Chunk holder update"); // Tuinity
if (k > PlayerChunkMap.GOLDEN_TICKET && j > PlayerChunkMap.GOLDEN_TICKET) {
return playerchunk;
} else {
@@ -775,6 +802,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -776,6 +804,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
playerchunk.a(j);
} else {
playerchunk = new PlayerChunk(new ChunkCoordIntPair(i), j, this.lightEngine, this.p, this);
+ this.dataRegionManager.addChunk(playerchunk.location.x, playerchunk.location.z); // Tuinity
}

this.updatingChunks.put(i, playerchunk);
@@ -966,7 +994,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -968,7 +997,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}

com.destroystokyo.paper.io.PaperFileIOThread.Holder.INSTANCE.scheduleSave(this.world, chunkPos.x, chunkPos.z,
Expand All @@ -4152,7 +4153,7 @@ index 5c5ee28f23..46d8beae87 100644

if (!chunk.isNeedsSaving()) {
return;
@@ -1000,7 +1028,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1002,7 +1031,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
asyncSaveData = ChunkRegionLoader.getAsyncSaveData(this.world, chunk);
}

Expand All @@ -4161,23 +4162,23 @@ index 5c5ee28f23..46d8beae87 100644
asyncSaveData, chunk);

chunk.setLastSaved(this.world.getTime());
@@ -1039,6 +1067,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1041,6 +1070,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.lightEngine.a(ichunkaccess.getPos());
this.lightEngine.queueUpdate();
this.worldLoadListener.a(ichunkaccess.getPos(), (ChunkStatus) null);
+ this.dataRegionManager.removeChunk(playerchunk.location.x, playerchunk.location.z); // Tuinity
}

}
@@ -1055,6 +1084,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1057,6 +1087,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}

protected boolean b() {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Cannot update visibleChunks off of the main thread"); // Tuinity
if (!this.updatingChunksModified) {
return false;
} else {
@@ -1242,7 +1272,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1244,7 +1275,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
// Paper end
this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable));
Expand All @@ -4189,23 +4190,23 @@ index 5c5ee28f23..46d8beae87 100644
}

protected void c(ChunkCoordIntPair chunkcoordintpair) {
@@ -1494,6 +1527,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1496,6 +1530,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}

public void setViewDistance(int i) { // Paper - public
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Cannot update view distance off of the main thread"); // Tuinity
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) {
@@ -1507,6 +1541,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1509,6 +1544,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {

// Paper start - no-tick view distance
public final void setNoTickViewDistance(int viewDistance) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Cannot update view distance off of the main thread"); // Tuinity
viewDistance = viewDistance == -1 ? -1 : MathHelper.clamp(viewDistance, 2, 32);

this.noTickViewDistance = viewDistance;
@@ -2033,23 +2068,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -2035,23 +2071,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private final void processTrackQueue() {
this.world.timings.tracker1.startTiming();
try {
Expand Down Expand Up @@ -6288,7 +6289,7 @@ index 1fa7061f7a..52aee91d2d 100644
return voxelshape != b() && voxelshape1 != b() ? (voxelshape.isEmpty() && voxelshape1.isEmpty() ? false : !c(b(), b(voxelshape, voxelshape1, OperatorBoolean.OR), OperatorBoolean.ONLY_FIRST)) : true;
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index a173d2562e..21f34b82f0 100644
index a173d2562e..8c47db51a0 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -94,6 +94,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
Expand All @@ -6308,20 +6309,23 @@ index a173d2562e..21f34b82f0 100644
this.generator = gen;
this.world = new CraftWorld((WorldServer) this, gen, env);
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
@@ -397,13 +400,38 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -397,13 +400,41 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
}
}

+ // Tuinity start
+ // Does not affect TE. This simply just a raw set type - runs no logic.
+ final void setTypeAndDataRaw(final BlockPosition pos, final IBlockData blockData, final TileEntity tileEntity) {
+ this.getChunkAt(pos.getX() >> 4, pos.getZ() >> 4).setTypeAndDataRaw(pos, blockData);
+ Chunk chunk = this.getChunkAt(pos.getX() >> 4, pos.getZ() >> 4);
+ IBlockData old = chunk.getType(pos);
+ chunk.setTypeAndDataRaw(pos, blockData);
+ if (tileEntity == null) {
+ this.removeTileEntity(pos);
+ } else {
+ this.setTileEntity(pos, tileEntity);
+ }
+ ((WorldServer)this).getChunkProvider().flagDirty(pos);
+ this.notifyPoiChange(pos, old, blockData);
+ }
+ // Tuinity end
+
Expand All @@ -6348,7 +6352,7 @@ index a173d2562e..21f34b82f0 100644
// CraftBukkit start - tree generation
if (this.captureTreeGeneration) {
// Paper start
@@ -436,7 +464,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -436,7 +467,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
}
// CraftBukkit end

Expand All @@ -6357,23 +6361,31 @@ index a173d2562e..21f34b82f0 100644
this.chunkPacketBlockController.onBlockChange(this, blockposition, iblockdata, iblockdata1, i); // Paper - Anti-Xray

if (iblockdata1 == null) {
@@ -504,6 +532,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -504,6 +535,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {

// CraftBukkit start - Split off from above in order to directly send client and physic updates
public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, IBlockData actualBlock, int i, int j) {
+ com.tuinity.tuinity.util.TickThread.softEnsureTickThread("Async notify and update"); // Tuinity
IBlockData iblockdata = newBlock;
IBlockData iblockdata1 = oldBlock;
IBlockData iblockdata2 = actualBlock;
@@ -936,6 +965,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -552,6 +584,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
}
// CraftBukkit end

+ public final void notifyPoiChange(BlockPosition blockposition, IBlockData old, IBlockData neww) { this.a(blockposition, old, neww); } // Tuinity - OBFHELPER
public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {}

public boolean setAir(BlockPosition blockposition) { return this.a(blockposition, false); } // Paper - OBFHELPER
@@ -936,6 +969,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
return;
// Paper end
}
+ MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick
}
// Paper start - Prevent armor stands from doing entity lookups
@Override
@@ -1031,7 +1061,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -1031,7 +1065,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
while (iterator.hasNext()) {
TileEntity tileentity1 = (TileEntity) iterator.next();

Expand All @@ -6382,7 +6394,7 @@ index a173d2562e..21f34b82f0 100644
tileentity1.an_();
iterator.remove();
}
@@ -1120,6 +1150,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -1120,6 +1154,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
public List<Entity> getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<Entity> predicate) {
// copied from below
List<Entity> list = Lists.newArrayList();
Expand All @@ -6394,7 +6406,7 @@ index a173d2562e..21f34b82f0 100644
int i = MathHelper.floor((axisalignedbb.minX - 2.0D) / 16.0D);
int j = MathHelper.floor((axisalignedbb.maxX + 2.0D) / 16.0D);
int k = MathHelper.floor((axisalignedbb.minZ - 2.0D) / 16.0D);
@@ -1143,8 +1178,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -1143,8 +1182,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {

@Override
public List<Entity> getEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, @Nullable Predicate<? super Entity> predicate) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0097-Add-phantom-spawning-options.patch
Expand Up @@ -233,10 +233,10 @@ index 0a25523f3c..e8637244ce 100644
return iblockdata.r(iblockaccess, blockposition) ? false : (iblockdata.isPowerSource() ? false : (!fluid.isEmpty() ? false : (iblockdata.a((Tag) TagsBlock.PREVENT_MOB_SPAWNING_INSIDE) ? false : !entitytypes.a(iblockdata))));
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index dd5a80c769..e6c03ffc2f 100644
index 54a6a37c81..a22b78a655 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1496,6 +1496,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -1500,6 +1500,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
return new DifficultyDamageScaler(this.getDifficulty(), this.getDayTime(), i, f);
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0101-Add-allow-water-in-end-world-option.patch
Expand Up @@ -49,10 +49,10 @@ index 120bf8436f..848a185c04 100644

return true;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 7bcc852100..4682de9f11 100644
index a5079ad349..657d005d29 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1568,4 +1568,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -1572,4 +1572,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
public final boolean isDebugWorld() {
return this.debugWorld;
}
Expand Down

0 comments on commit d6d9539

Please sign in to comment.