From b372f891aaa92bdbf0d844651f9b057414e5bc98 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 6 May 2019 13:45:02 -0700 Subject: [PATCH] Fix some runtime issues --- .../Add-exception-reporting-event.patch | 2 +- .../Allow-Saving-of-Oversized-Chunks.patch | 15 ++++++++++++++- .../Don-t-save-Proto-Chunks.patch | 2 +- ...e-region-files-more-reliable-to-write-to.patch | 2 +- ...ize-more-aggressive-in-the-chunk-unload-.patch | 2 +- .../PlayerNaturallySpawnCreaturesEvent.patch | 2 +- ...e-position-the-first-time-an-entity-is-s.patch | 2 +- Spigot-Server-Patches/Timings-v2.patch | 14 +++++++++++--- 8 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Spigot-Server-Patches/Add-exception-reporting-event.patch b/Spigot-Server-Patches/Add-exception-reporting-event.patch index 3091d72377..45bd5bb1f9 100644 --- a/Spigot-Server-Patches/Add-exception-reporting-event.patch +++ b/Spigot-Server-Patches/Add-exception-reporting-event.patch @@ -121,7 +121,7 @@ index 1dd793d2fb..61ea2818b1 100644 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 0a64432384..5ecf446e11 100644 +index 4bbf9244f2..5dc8e62021 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Allow-Saving-of-Oversized-Chunks.patch b/Spigot-Server-Patches/Allow-Saving-of-Oversized-Chunks.patch index 3c4513eb13..16f5f076b0 100644 --- a/Spigot-Server-Patches/Allow-Saving-of-Oversized-Chunks.patch +++ b/Spigot-Server-Patches/Allow-Saving-of-Oversized-Chunks.patch @@ -64,7 +64,7 @@ index b7c94fe238..80eea5dfbd 100644 public NBTTagList() {} diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index e68f901943..995a893774 100644 +index e68f901943..ed2ccebb23 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { @@ -77,6 +77,14 @@ index e68f901943..995a893774 100644 private static final byte[] a = new byte[4096]; private final RandomAccessFile b; private RandomAccessFile getDataFile() { return this.b; } // Paper - OBFHELPER @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { + + public RegionFile(File file) throws IOException { + this.b = new RandomAccessFile(file, "rw"); ++ this.file = file; // Spigot // Paper - We need this earlier + if (this.b.length() < 8192L) { // Paper - headers should be 8192 + this.b.write(RegionFile.a); + this.b.write(RegionFile.a); +@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { } header.clear(); java.nio.IntBuffer headerAsInts = header.asIntBuffer(); @@ -94,6 +102,11 @@ index e68f901943..995a893774 100644 // Spigot end this.e.set((k >> 8) + l, false); @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { + if (offsets[j] != 0) this.timestamps[j] = k; // Paper - don't set timestamp if it got 0'd above due to corruption + } + +- this.file = file; // Spigot ++ // Paper - we need this earlier } @Nullable diff --git a/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch b/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch index 8e7c41c730..c71abbdfec 100644 --- a/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch +++ b/Spigot-Server-Patches/Don-t-save-Proto-Chunks.patch @@ -8,7 +8,7 @@ the loadChunk method refuses to acknoledge they exists, and will restart a new chunk generation process to begin with, so saving them serves no benefit. diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 99beb30093..bfcd57aa5f 100644 +index 34f97ce222..804824bfe2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Make-region-files-more-reliable-to-write-to.patch b/Spigot-Server-Patches/Make-region-files-more-reliable-to-write-to.patch index f7dde12bf1..76865ad6e6 100644 --- a/Spigot-Server-Patches/Make-region-files-more-reliable-to-write-to.patch +++ b/Spigot-Server-Patches/Make-region-files-more-reliable-to-write-to.patch @@ -37,7 +37,7 @@ affect save performance if the startup flag is used (especially on HDDs). diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java -index 995a893774..66d87d64b5 100644 +index ed2ccebb23..2e14d84657 100644 --- a/src/main/java/net/minecraft/server/RegionFile.java +++ b/src/main/java/net/minecraft/server/RegionFile.java @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { diff --git a/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch b/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch index 5eb335c93d..b577c479bd 100644 --- a/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch +++ b/Spigot-Server-Patches/Make-targetSize-more-aggressive-in-the-chunk-unload-.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 5ecf446e11..26dafe0d29 100644 +index 5dc8e62021..4be53f89bb 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch b/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch index 03da09e6c9..8fffda5cce 100644 --- a/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch +++ b/Spigot-Server-Patches/PlayerNaturallySpawnCreaturesEvent.patch @@ -9,7 +9,7 @@ from triggering monster spawns on a server. Also a highly more effecient way to blanket block spawns in a world diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 26dafe0d29..99beb30093 100644 +index 4be53f89bb..34f97ce222 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch b/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch index 68f37fd900..5ea9efc352 100644 --- a/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch +++ b/Spigot-Server-Patches/Send-absolute-position-the-first-time-an-entity-is-s.patch @@ -77,7 +77,7 @@ index 315c3d9165..aaf3a54b08 100644 this.c(); diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index ee65b01f43..0a64432384 100644 +index 5816c7bcc7..4bbf9244f2 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { diff --git a/Spigot-Server-Patches/Timings-v2.patch b/Spigot-Server-Patches/Timings-v2.patch index 998ebe9359..b1cd22a70f 100644 --- a/Spigot-Server-Patches/Timings-v2.patch +++ b/Spigot-Server-Patches/Timings-v2.patch @@ -792,7 +792,7 @@ index 4de927416b..4c1c914132 100644 this.methodProfiler.exit(); } diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java -index 755c0406e1..ee65b01f43 100644 +index 755c0406e1..5816c7bcc7 100644 --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java @@ -0,0 +0,0 @@ @@ -820,8 +820,11 @@ index 755c0406e1..ee65b01f43 100644 + PlayerChunk neighborPlayer = getUpdatingChunk(ChunkCoordIntPair.pair(currentChunkPair.x + x, currentChunkPair.z + z)); + if (neighborPlayer != null) { + Chunk neighbor = neighborPlayer.getChunk(); -+ neighbor.setNeighborLoaded(-x, -z); -+ playerchunk.getChunk().setNeighborLoaded(x, z); ++ Chunk player = playerchunk.getChunk(); ++ if (neighbor != null && player != null) { ++ neighbor.setNeighborLoaded(-x, -z); ++ player.setNeighborLoaded(x, z); ++ } + } + } + } @@ -882,6 +885,11 @@ index 755c0406e1..ee65b01f43 100644 while (objectiterator.hasNext()) { playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next(); playerchunkmap_entitytracker.track(list); + } ++ world.timings.tracker2.stopTiming(); // Paper + + } + diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java index 78a090ac75..e07f4a9680 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java