Fix some runtime issues

This commit is contained in:
Spottedleaf 2019-05-06 13:45:02 -07:00
parent e9439e7655
commit a189bdc0fc
8 changed files with 67 additions and 46 deletions

View File

@ -1,4 +1,4 @@
From fffc5a98890008800dbabb96745e8aa27aee49c9 Mon Sep 17 00:00:00 2001
From 5649d05624dac0cd18bc362f5769c01606b59019 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 04:00:11 -0600
Subject: [PATCH] Timings v2
@ -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
@@ -1,6 +1,8 @@
@ -804,7 +804,7 @@ index 755c0406e1..ee65b01f43 100644
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.mojang.datafixers.DataFixer;
@@ -244,6 +246,24 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -244,6 +246,27 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
playerchunk = new PlayerChunk(new ChunkCoordIntPair(i), j, this.lightEngine, this.q, this);
}
@ -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);
+ }
+ }
+ }
+ }
@ -829,7 +832,7 @@ index 755c0406e1..ee65b01f43 100644
this.updatingChunks.put(i, playerchunk);
this.updatingChunksModified = true;
}
@@ -332,6 +352,23 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -332,6 +355,23 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk, chunk.isNeedsSaving());
this.world.getServer().getPluginManager().callEvent(event);
this.saveChunk(ichunkaccess, event.isSaveChunk());
@ -853,7 +856,7 @@ index 755c0406e1..ee65b01f43 100644
// CraftBukkit end
chunk.c(false);
@@ -402,7 +439,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -402,7 +442,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
});
return completablefuture.thenComposeAsync((either) -> {
@ -862,7 +865,7 @@ index 755c0406e1..ee65b01f43 100644
try {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture1 = chunkstatus.a(this.world, this.chunkGenerator, this.definedStructureManager, this.lightEngine, (ichunkaccess) -> {
return this.b(playerchunk);
@@ -879,6 +916,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -879,6 +919,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
PlayerChunkMap.EntityTracker playerchunkmap_entitytracker;
ObjectIterator objectiterator;
@ -870,7 +873,7 @@ index 755c0406e1..ee65b01f43 100644
for (objectiterator = this.trackedEntities.values().iterator(); objectiterator.hasNext(); playerchunkmap_entitytracker.trackerEntry.a()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
@@ -896,9 +934,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -896,13 +937,16 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
playerchunkmap_entitytracker.e = sectionposition1;
}
}
@ -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

View File

@ -1,4 +1,4 @@
From 349002e874920f5e828deeee07cfbcdd4b8d36a2 Mon Sep 17 00:00:00 2001
From c20c4977df4d9a8009cb08f54fcfc710883fa8c4 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Wed, 2 Mar 2016 23:13:07 -0600
Subject: [PATCH] Send absolute position the first time an entity is seen
@ -77,10 +77,10 @@ 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
@@ -1031,10 +1031,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1035,10 +1035,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private final Entity tracker;
private final int trackingDistance;
private SectionPosition e;
@ -97,7 +97,7 @@ index ee65b01f43..0a64432384 100644
this.tracker = entity;
this.trackingDistance = i;
this.e = SectionPosition.a(entity);
@@ -1116,7 +1120,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1120,7 +1124,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
// CraftBukkit end

View File

@ -1,4 +1,4 @@
From ab1921692e96b83434f730b535edeac94438578a Mon Sep 17 00:00:00 2001
From 55a0321f3f6c273aac277c629058f59702cda47e Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 03:15:41 -0600
Subject: [PATCH] Add exception reporting event
@ -121,10 +121,10 @@ 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
@@ -596,6 +596,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -599,6 +599,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.world.checkSession();
} catch (ExceptionWorldConflict exceptionworldconflict) {
PlayerChunkMap.LOGGER.error("Couldn't save chunk; already in use by another instance of Minecraft?", exceptionworldconflict);
@ -132,7 +132,7 @@ index 0a64432384..5ecf446e11 100644
return;
}
@@ -622,6 +623,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -625,6 +626,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.write(chunkcoordintpair, nbttagcompound);
} catch (Exception exception) {
PlayerChunkMap.LOGGER.error("Failed to save chunk {},{}", chunkcoordintpair.x, chunkcoordintpair.z, exception);

View File

@ -1,14 +1,14 @@
From 3b9e8f3661c32ede626e0cfe0c935584e7050e6e Mon Sep 17 00:00:00 2001
From a10267a106c969bb7c1a0e6e0f2c017ed9703baa Mon Sep 17 00:00:00 2001
From: Brokkonaut <hannos17@gmx.de>
Date: Tue, 7 Feb 2017 16:55:35 -0600
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
@@ -311,7 +311,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -314,7 +314,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Spigot start
org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
activityAccountant.startActivity(0.5);

View File

@ -1,4 +1,4 @@
From c75853cc4f8ae4188516daa9f9848e7761826f5e Mon Sep 17 00:00:00 2001
From 2b0dd101a780ba65566dadf37c91bef781ab7ea8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 14 Jan 2018 17:36:02 -0500
Subject: [PATCH] PlayerNaturallySpawnCreaturesEvent
@ -9,10 +9,10 @@ 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
@@ -710,11 +710,16 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -713,11 +713,16 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
int chunkRange = world.spigotConfig.mobSpawnRange;
chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange;
chunkRange = (chunkRange > 8) ? 8 : chunkRange;

View File

@ -1,4 +1,4 @@
From bc37d872d3da190754fdab1a191a303396ee50cc Mon Sep 17 00:00:00 2001
From 13aa59139e439b184472d721ea0adc84fc68b3dd Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 22 Jul 2018 21:21:41 -0400
Subject: [PATCH] Don't save Proto Chunks
@ -8,10 +8,10 @@ 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
@@ -589,6 +589,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -592,6 +592,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
public void saveChunk(IChunkAccess ichunkaccess, boolean save) {

View File

@ -1,4 +1,4 @@
From 46fb6cb816d0b057c8137c3e6795a4fb281fd52d Mon Sep 17 00:00:00 2001
From 474d222e2b8dde31dc97fb3a077f44a82b5f2b20 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 15 Feb 2019 01:08:19 -0500
Subject: [PATCH] Allow Saving of Oversized Chunks
@ -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
@@ -23,7 +23,7 @@ public class RegionFile implements AutoCloseable {
@ -76,7 +76,15 @@ index e68f901943..995a893774 100644
// Spigot end
private static final byte[] a = new byte[4096];
private final RandomAccessFile b; private RandomAccessFile getDataFile() { return this.b; } // Paper - OBFHELPER
@@ -66,6 +66,7 @@ public class RegionFile implements AutoCloseable {
@@ -33,6 +33,7 @@ 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);
@@ -66,6 +67,7 @@ public class RegionFile implements AutoCloseable {
}
header.clear();
java.nio.IntBuffer headerAsInts = header.asIntBuffer();
@ -84,7 +92,7 @@ index e68f901943..995a893774 100644
// Paper End
int k;
@@ -83,7 +84,7 @@ public class RegionFile implements AutoCloseable {
@@ -83,7 +85,7 @@ public class RegionFile implements AutoCloseable {
this.b.seek(j * 4 + 4); // Go back to where we were
}
}
@ -93,7 +101,12 @@ index e68f901943..995a893774 100644
for (int l = 0; l < (length); ++l) {
// Spigot end
this.e.set((k >> 8) + l, false);
@@ -106,7 +107,7 @@ public class RegionFile implements AutoCloseable {
@@ -102,11 +104,11 @@ 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
@ -102,7 +115,7 @@ index e68f901943..995a893774 100644
try {
int i = this.getOffset(chunkcoordintpair);
@@ -182,8 +183,8 @@ public class RegionFile implements AutoCloseable {
@@ -182,8 +184,8 @@ public class RegionFile implements AutoCloseable {
}
}
@ -113,7 +126,7 @@ index e68f901943..995a893774 100644
}
protected synchronized void a(ChunkCoordIntPair chunkcoordintpair, byte[] abyte, int i) {
@@ -201,8 +202,9 @@ public class RegionFile implements AutoCloseable {
@@ -201,8 +203,9 @@ public class RegionFile implements AutoCloseable {
if (i1 >= 256) {
// Spigot start
@ -124,7 +137,7 @@ index e68f901943..995a893774 100644
// Spigot end
}
@@ -352,6 +354,109 @@ public class RegionFile implements AutoCloseable {
@@ -352,6 +355,109 @@ public class RegionFile implements AutoCloseable {
logger.error("Error backing up corrupt file" + file.getAbsolutePath(), e);
}
}
@ -234,7 +247,7 @@ index e68f901943..995a893774 100644
// Paper end
class ChunkBuffer extends ByteArrayOutputStream {
@@ -363,8 +468,35 @@ public class RegionFile implements AutoCloseable {
@@ -363,8 +469,35 @@ public class RegionFile implements AutoCloseable {
this.b = chunkcoordintpair;
}

View File

@ -1,4 +1,4 @@
From ff681dbbc6c8b45b2a2589ce3df2bca78f2a2950 Mon Sep 17 00:00:00 2001
From 2be054a15c5fa8799a83dcdc6ae22305b6ea8421 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 1 Apr 2019 18:57:32 -0700
Subject: [PATCH] Make region files more reliable to write to
@ -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
@@ -29,7 +29,7 @@ public class RegionFile implements AutoCloseable {
@ -49,7 +49,7 @@ index 995a893774..66d87d64b5 100644
public RegionFile(File file) throws IOException {
this.b = new RandomAccessFile(file, "rw");
@@ -190,8 +190,8 @@ public class RegionFile implements AutoCloseable {
@@ -191,8 +191,8 @@ public class RegionFile implements AutoCloseable {
protected synchronized void a(ChunkCoordIntPair chunkcoordintpair, byte[] abyte, int i) {
try {
int j = this.getOffset(chunkcoordintpair);
@ -60,7 +60,7 @@ index 995a893774..66d87d64b5 100644
// Spigot start
if (l == 255) {
this.b.seek(k * 4096);
@@ -199,6 +199,7 @@ public class RegionFile implements AutoCloseable {
@@ -200,6 +200,7 @@ public class RegionFile implements AutoCloseable {
}
// Spigot end
int i1 = (i + 5) / 4096 + 1;
@ -68,7 +68,7 @@ index 995a893774..66d87d64b5 100644
if (i1 >= 256) {
// Spigot start
@@ -208,14 +209,12 @@ public class RegionFile implements AutoCloseable {
@@ -209,14 +210,12 @@ public class RegionFile implements AutoCloseable {
// Spigot end
}
@ -85,7 +85,7 @@ index 995a893774..66d87d64b5 100644
j1 = this.e.indexOf(true);
int k1 = 0;
@@ -242,13 +241,13 @@ public class RegionFile implements AutoCloseable {
@@ -243,13 +242,13 @@ public class RegionFile implements AutoCloseable {
if (k1 >= i1) {
k = j1;
@ -101,7 +101,7 @@ index 995a893774..66d87d64b5 100644
} else {
this.b.seek(this.b.length());
k = this.e.size();
@@ -258,9 +257,14 @@ public class RegionFile implements AutoCloseable {
@@ -259,9 +258,14 @@ public class RegionFile implements AutoCloseable {
this.e.add(false);
}
@ -118,7 +118,7 @@ index 995a893774..66d87d64b5 100644
}
this.b(chunkcoordintpair, (int) (SystemUtils.getTimeMillis() / 1000L));
@@ -270,10 +274,10 @@ public class RegionFile implements AutoCloseable {
@@ -271,10 +275,10 @@ public class RegionFile implements AutoCloseable {
}
@ -131,7 +131,7 @@ index 995a893774..66d87d64b5 100644
this.b.write(abyte, 0, j);
}
@@ -285,12 +289,13 @@ public class RegionFile implements AutoCloseable {
@@ -286,12 +290,13 @@ public class RegionFile implements AutoCloseable {
return this.getOffset(chunkcoordintpair) != 0;
}
@ -146,7 +146,7 @@ index 995a893774..66d87d64b5 100644
}
private int f(ChunkCoordIntPair chunkcoordintpair) {
@@ -302,7 +307,7 @@ public class RegionFile implements AutoCloseable {
@@ -303,7 +308,7 @@ public class RegionFile implements AutoCloseable {
this.d[j] = i;
this.b.seek((long) (4096 + j * 4));
@ -155,7 +155,7 @@ index 995a893774..66d87d64b5 100644
}
public void close() throws IOException {
@@ -310,6 +315,40 @@ public class RegionFile implements AutoCloseable {
@@ -311,6 +316,40 @@ public class RegionFile implements AutoCloseable {
}
// Paper start