Readd Petal and Suki Patches
This commit is contained in:
1062
patches/server/0006-Suki-Patches.patch
Normal file
1062
patches/server/0006-Suki-Patches.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@ index bc9403d002ef24e71be67a962d099f5d73db9540..5582c15a37fbbf74d2039ba15d67684f
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index ca0ddafe66dd5d02b1e96b1fc1c574490b68e6d4..383045ae681d5366761c807a0032156203cdf9c9 100644
|
||||
index 9227cff62d675703785ad2eaebf6dcbb5adfbaa7..3e7dd41555263e8361db08d1380c767fe0ba8886 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -185,7 +185,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -42,7 +42,7 @@ index ca0ddafe66dd5d02b1e96b1fc1c574490b68e6d4..383045ae681d5366761c807a00321562
|
||||
DedicatedServer.LOGGER.warn("****************************");
|
||||
DedicatedServer.LOGGER.warn("YOU ARE RUNNING THIS SERVER AS AN ADMINISTRATIVE OR ROOT USER. THIS IS NOT ADVISED.");
|
||||
DedicatedServer.LOGGER.warn("YOU ARE OPENING YOURSELF UP TO POTENTIAL RISKS WHEN DOING THIS.");
|
||||
@@ -326,10 +326,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -330,10 +330,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
// CraftBukkit end
|
||||
|
||||
if (!this.usesAuthentication()) {
|
||||
@@ -61,7 +61,7 @@ index ca0ddafe66dd5d02b1e96b1fc1c574490b68e6d4..383045ae681d5366761c807a00321562
|
||||
DedicatedServer.LOGGER.warn("Whilst this makes it possible to use BungeeCord or Velocity, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose."); // Purpur
|
||||
DedicatedServer.LOGGER.warn("Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.");
|
||||
} else {
|
||||
@@ -337,7 +342,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -341,7 +346,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
DedicatedServer.LOGGER.warn("You will not be offered any support as long as the server allows offline-mode players to join."); // Purpur
|
||||
}
|
||||
// Spigot end
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Revert purpur spark profiler
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4f029b96bf8deee597dbb56974e4519a1422f96d..a1f37a75d94cffbb412e48cdffec836eaad8300a 100644
|
||||
index 9e47bbefdb373a75a9903b19c23e9191b9c84846..d6099877d68c795ef980f82389c46baf239bacfd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -435,38 +435,7 @@ public final class CraftServer implements Server {
|
||||
@@ -436,38 +436,7 @@ public final class CraftServer implements Server {
|
||||
if (!pluginFolder.exists()) {
|
||||
pluginFolder.mkdirs();
|
||||
}
|
||||
@@ -89,10 +89,10 @@ index e8efbbeece7e866c6c4d7489677d2d9e15fea4d0..8bc0cb9ad5bb4e76d962ff54305e2c08
|
||||
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679db0a68c1 100644
|
||||
index ede16b015b9dde07a7346e0bffde53082145798b..705fe5e4a8b25fb061263ac60e491aeff83bd930 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -328,13 +328,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -331,13 +331,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public MinecraftServer(OptionSet options, DataPackConfig datapackconfiguration, DynamicOps<Tag> registryreadops, Thread thread, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, ChunkProgressListenerFactory worldloadlistenerfactory) {
|
||||
super("Server");
|
||||
SERVER = this; // Paper - better singleton
|
||||
@@ -112,7 +112,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
this.status = new ServerStatus();
|
||||
this.random = RandomSource.create();
|
||||
this.port = -1;
|
||||
@@ -936,9 +936,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -940,9 +940,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
// Paper end
|
||||
// CraftBukkit end
|
||||
@@ -124,7 +124,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
|
||||
MinecraftServer.LOGGER.info("Stopping server");
|
||||
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Shutdown and don't bother finishing
|
||||
@@ -1181,18 +1181,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1185,18 +1185,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
// Spigot end
|
||||
|
||||
@@ -148,7 +148,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
this.mayHaveDelayedTasks = true;
|
||||
// Purpur start - tps catchup
|
||||
if (org.purpurmc.purpur.PurpurConfig.tpsCatchup) {
|
||||
@@ -1202,8 +1202,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1206,8 +1206,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
// Purpur end - tps catchup
|
||||
this.waitUntilNextTick();
|
||||
@@ -159,7 +159,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
this.isReady = true;
|
||||
JvmProfiler.INSTANCE.onServerTick(this.averageTickTime);
|
||||
}
|
||||
@@ -1364,7 +1364,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1368,7 +1368,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public void doRunTask(TickTask ticktask) { // CraftBukkit - decompile error
|
||||
@@ -168,7 +168,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
|
||||
@@ -1408,15 +1408,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1412,15 +1412,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public void onServerExit() {}
|
||||
|
||||
public void tickServer(BooleanSupplier shouldKeepTicking) {
|
||||
@@ -187,7 +187,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
// Paper end
|
||||
new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper
|
||||
|
||||
@@ -1449,7 +1449,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1453,7 +1453,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
if (playerSaveInterval < 0) {
|
||||
playerSaveInterval = autosavePeriod;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
final boolean fullSave = autosavePeriod > 0 && this.tickCount % autosavePeriod == 0;
|
||||
try {
|
||||
this.isSaving = true;
|
||||
@@ -1464,20 +1464,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1468,20 +1468,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
long l = this.tickTimes[this.tickCount % 100] = Util.getNanos() - i;
|
||||
|
||||
this.averageTickTime = this.averageTickTime * 0.8F + (float) l / 1000000.0F * 0.19999999F;
|
||||
@@ -1490,31 +1490,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1494,31 +1494,31 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper end
|
||||
|
||||
this.frameTimer.logFrameDuration(i1 - i);
|
||||
@@ -264,7 +264,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
// Paper start - optimize time updates
|
||||
for (final ServerLevel world : this.getAllLevels()) {
|
||||
@@ -1534,10 +1534,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1538,10 +1538,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
@@ -276,7 +276,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
Iterator iterator = this.getAllLevels().iterator(); // Paper - move down
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
@@ -1546,28 +1545,28 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1550,28 +1549,28 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
worldserver.hasRidableMoveEvent = org.purpurmc.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur
|
||||
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
|
||||
|
||||
@@ -312,7 +312,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
} catch (Throwable throwable) {
|
||||
// Spigot Start
|
||||
CrashReport crashreport;
|
||||
@@ -1583,33 +1582,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1587,33 +1586,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
}
|
||||
|
||||
public boolean isNetherEnabled() {
|
||||
@@ -2257,7 +2256,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2261,7 +2260,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public ProfilerFiller getProfiler() {
|
||||
@@ -367,7 +367,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
return this.profiler;
|
||||
}
|
||||
|
||||
@@ -2497,7 +2496,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2501,7 +2500,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// CraftBukkit end
|
||||
|
||||
private void startMetricsRecordingTick() {
|
||||
@@ -376,7 +376,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
this.executeBlocking(() -> {
|
||||
this.saveDebugReport(path.resolve("server"));
|
||||
@@ -2507,40 +2506,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2511,40 +2510,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.willStartRecordingMetrics = false;
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
}
|
||||
|
||||
public Path getWorldPath(LevelResource worldSavePath) {
|
||||
@@ -2585,15 +2584,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2589,15 +2588,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public boolean isTimeProfilerRunning() {
|
||||
@@ -448,7 +448,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
return EmptyProfileResults.EMPTY;
|
||||
} else {
|
||||
ProfileResults methodprofilerresults = this.debugCommandProfiler.stop(Util.getNanos(), this.tickCount);
|
||||
@@ -2766,7 +2765,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2770,7 +2769,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ index a444c8c57a2ab16eba45b0379841a69ff60a5586..bc80783d36d46fb138bfa6f2e5e84679
|
||||
try {
|
||||
for (;;) {
|
||||
boolean moreTasks = this.tickMidTickTasks();
|
||||
@@ -2786,14 +2785,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2790,14 +2789,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
double overuseCount = (double)overuse/(double)MAX_CHUNK_EXEC_TIME;
|
||||
@@ -488,10 +488,10 @@ index 2986f110348b376bcdc64fa39b68885551663d4d..d1fa6b1edf733e15dfe9ecbf7ed63923
|
||||
i = this.context.runTopCommand(function, source);
|
||||
} finally {
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 383045ae681d5366761c807a0032156203cdf9c9..443aa5012152cb7969147dbbeba259e121def254 100644
|
||||
index 3e7dd41555263e8361db08d1380c767fe0ba8886..d6c3db7234fa9b52e945cb004d8ae843aabf1302 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -538,7 +538,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -542,7 +542,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
}
|
||||
|
||||
public void handleConsoleInputs() {
|
||||
@@ -500,7 +500,7 @@ index 383045ae681d5366761c807a0032156203cdf9c9..443aa5012152cb7969147dbbeba259e1
|
||||
// Paper start - use proper queue
|
||||
ConsoleInput servercommand;
|
||||
while ((servercommand = this.serverCommandQueue.poll()) != null) {
|
||||
@@ -555,7 +555,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
@@ -559,7 +559,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ index cd5533c3c53215c9cc4be0b9097d76efbf5bd0c1..7266e6703d5cd0fea90ec88c74a7d456
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index df014d5b1b2d3b1d0e7a0b9eedb3c19ee693b836..55fe8b0f21f00b02e78257a64fd8d63980d50995 100644
|
||||
index 2461aadffa36e1e193fa32ddb5955c9946ad1450..3ffa7b3440b65ba3a4af4488f6ca9506e5a2128b 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -227,13 +227,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@@ -1222,7 +1222,7 @@ index 7094701d213c73ba47ace806962244c10fdf4dda..fcdb9bde8e1605e30dde3e580491522d
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56422843c5 100644
|
||||
index dc3f2b26e19619adf80827d26b95209ded973c2a..9b082716ebfe84e9a2dd5265b2ede86f42008cc2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -117,9 +117,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -1237,7 +1237,7 @@ index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56
|
||||
private boolean tickingBlockEntities;
|
||||
public final Thread thread;
|
||||
private final boolean isDebug;
|
||||
@@ -712,9 +712,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -720,9 +720,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
BlockState iblockdata2 = this.getBlockState(pos);
|
||||
|
||||
if ((flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
|
||||
@@ -1249,7 +1249,7 @@ index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -991,18 +991,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -999,18 +999,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
}
|
||||
|
||||
protected void tickBlockEntities() {
|
||||
@@ -1273,7 +1273,7 @@ index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56
|
||||
// Spigot start
|
||||
// Iterator iterator = this.blockEntityTickers.iterator();
|
||||
int tilesThisCycle = 0;
|
||||
@@ -1035,10 +1035,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -1043,10 +1043,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
}
|
||||
this.blockEntityTickers.removeAll(toRemove);
|
||||
|
||||
@@ -1286,7 +1286,7 @@ index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56
|
||||
spigotConfig.currentPrimedTnt = 0; // Spigot
|
||||
}
|
||||
|
||||
@@ -1199,7 +1199,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -1207,7 +1207,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
|
||||
@Override
|
||||
public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) {
|
||||
@@ -1295,7 +1295,7 @@ index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56
|
||||
List<Entity> list = Lists.newArrayList();
|
||||
((ServerLevel)this).getEntityLookup().getEntities(except, box, list, predicate); // Paper - optimise this call
|
||||
return list;
|
||||
@@ -1207,7 +1207,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -1215,7 +1215,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
|
||||
@Override
|
||||
public <T extends Entity> List<T> getEntities(EntityTypeTest<Entity, T> filter, AABB box, Predicate<? super T> predicate) {
|
||||
@@ -1304,7 +1304,7 @@ index 9f0126aedb94f74d01dc47112496160cc4e1f02c..0c9f7f9ed3e24ddc6b963063723feb56
|
||||
List<T> list = Lists.newArrayList();
|
||||
|
||||
// Paper start - optimise this call
|
||||
@@ -1538,7 +1538,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -1546,7 +1546,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
}
|
||||
|
||||
public ProfilerFiller getProfiler() {
|
||||
1081
patches/server/0027-Async-path-processing.patch
Normal file
1081
patches/server/0027-Async-path-processing.patch
Normal file
File diff suppressed because it is too large
Load Diff
363
patches/server/0028-Multithreaded-tracker.patch
Normal file
363
patches/server/0028-Multithreaded-tracker.patch
Normal file
@@ -0,0 +1,363 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: peaches94 <peachescu94@gmail.com>
|
||||
Date: Sat, 2 Jul 2022 00:35:56 -0500
|
||||
Subject: [PATCH] Multithreaded tracker
|
||||
|
||||
Original code by Bloom-host, licensed under GNU General Public License v3.0
|
||||
You can find the original code on https://github.com/Bloom-host/Petal
|
||||
|
||||
Co-authored-by: Paul Sauve <paul@technove.co>
|
||||
Co-authored-by: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
|
||||
based off the airplane multithreaded tracker this patch properly handles
|
||||
concurrent accesses everywhere, as well as being much simpler to maintain
|
||||
|
||||
some things are too unsafe to run off the main thread so we don't attempt to do
|
||||
that. this multithreaded tracker remains accurate, non-breaking and fast
|
||||
|
||||
we also learned from pufferfish core that changes have to be sent ordered
|
||||
now we do that in an optimized way
|
||||
|
||||
diff --git a/src/main/java/host/bloom/tracker/MultithreadedTracker.java b/src/main/java/host/bloom/tracker/MultithreadedTracker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d27b7224ed2bcc63386dc46c33bfb8b272d91f92
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/host/bloom/tracker/MultithreadedTracker.java
|
||||
@@ -0,0 +1,154 @@
|
||||
+package host.bloom.tracker;
|
||||
+
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet;
|
||||
+import io.papermc.paper.world.ChunkEntitySlices;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ChunkMap;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.level.chunk.LevelChunk;
|
||||
+
|
||||
+import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
+import java.util.concurrent.Executor;
|
||||
+import java.util.concurrent.Executors;
|
||||
+import java.util.concurrent.atomic.AtomicInteger;
|
||||
+
|
||||
+public class MultithreadedTracker {
|
||||
+
|
||||
+ private enum TrackerStage {
|
||||
+ UPDATE_PLAYERS,
|
||||
+ SEND_CHANGES
|
||||
+ }
|
||||
+
|
||||
+ private static final int parallelism = Math.max(4, Runtime.getRuntime().availableProcessors());
|
||||
+ private static final Executor trackerExecutor = Executors.newFixedThreadPool(parallelism, new ThreadFactoryBuilder()
|
||||
+ .setNameFormat("petal-tracker-%d")
|
||||
+ .setPriority(Thread.NORM_PRIORITY - 2)
|
||||
+ .build());
|
||||
+
|
||||
+ private final IteratorSafeOrderedReferenceSet<LevelChunk> entityTickingChunks;
|
||||
+ private final AtomicInteger taskIndex = new AtomicInteger();
|
||||
+
|
||||
+ private final ConcurrentLinkedQueue<Runnable> mainThreadTasks;
|
||||
+ private final AtomicInteger finishedTasks = new AtomicInteger();
|
||||
+
|
||||
+ public MultithreadedTracker(IteratorSafeOrderedReferenceSet<LevelChunk> entityTickingChunks, ConcurrentLinkedQueue<Runnable> mainThreadTasks) {
|
||||
+ this.entityTickingChunks = entityTickingChunks;
|
||||
+ this.mainThreadTasks = mainThreadTasks;
|
||||
+ }
|
||||
+
|
||||
+ public void tick() {
|
||||
+ int iterator = this.entityTickingChunks.createRawIterator();
|
||||
+
|
||||
+ if (iterator == -1) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // start with updating players
|
||||
+ try {
|
||||
+ this.taskIndex.set(iterator);
|
||||
+ this.finishedTasks.set(0);
|
||||
+
|
||||
+ for (int i = 0; i < parallelism; i++) {
|
||||
+ trackerExecutor.execute(this::runUpdatePlayers);
|
||||
+ }
|
||||
+
|
||||
+ while (this.taskIndex.get() < this.entityTickingChunks.getListSize()) {
|
||||
+ this.runMainThreadTasks();
|
||||
+ this.handleChunkUpdates(5); // assist
|
||||
+ }
|
||||
+
|
||||
+ while (this.finishedTasks.get() != parallelism) {
|
||||
+ this.runMainThreadTasks();
|
||||
+ }
|
||||
+
|
||||
+ this.runMainThreadTasks(); // finish any remaining tasks
|
||||
+ } finally {
|
||||
+ this.entityTickingChunks.finishRawIterator();
|
||||
+ }
|
||||
+
|
||||
+ // then send changes
|
||||
+ iterator = this.entityTickingChunks.createRawIterator();
|
||||
+
|
||||
+ if (iterator == -1) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ do {
|
||||
+ LevelChunk chunk = this.entityTickingChunks.rawGet(iterator);
|
||||
+
|
||||
+ if (chunk != null) {
|
||||
+ this.updateChunkEntities(chunk, TrackerStage.SEND_CHANGES);
|
||||
+ }
|
||||
+ } while (++iterator < this.entityTickingChunks.getListSize());
|
||||
+ } finally {
|
||||
+ this.entityTickingChunks.finishRawIterator();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void runMainThreadTasks() {
|
||||
+ try {
|
||||
+ Runnable task;
|
||||
+ while ((task = this.mainThreadTasks.poll()) != null) {
|
||||
+ task.run();
|
||||
+ }
|
||||
+ } catch (Throwable throwable) {
|
||||
+ MinecraftServer.LOGGER.warn("Tasks failed while ticking track queue", throwable);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void runUpdatePlayers() {
|
||||
+ try {
|
||||
+ while (handleChunkUpdates(10));
|
||||
+ } finally {
|
||||
+ this.finishedTasks.incrementAndGet();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private boolean handleChunkUpdates(int tasks) {
|
||||
+ int index;
|
||||
+ while ((index = this.taskIndex.getAndAdd(tasks)) < this.entityTickingChunks.getListSize()) {
|
||||
+ for (int i = index; i < index + tasks && i < this.entityTickingChunks.getListSize(); i++) {
|
||||
+ LevelChunk chunk = this.entityTickingChunks.rawGet(i);
|
||||
+ if (chunk != null) {
|
||||
+ try {
|
||||
+ this.updateChunkEntities(chunk, TrackerStage.UPDATE_PLAYERS);
|
||||
+ } catch (Throwable throwable) {
|
||||
+ MinecraftServer.LOGGER.warn("Ticking tracker failed", throwable);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private void updateChunkEntities(LevelChunk chunk, TrackerStage trackerStage) {
|
||||
+ final ChunkEntitySlices entitySlices = chunk.level.getEntityLookup().getChunk(chunk.locX, chunk.locZ);
|
||||
+ if (entitySlices == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final Entity[] rawEntities = entitySlices.entities.getRawData();
|
||||
+ final ChunkMap chunkMap = chunk.level.chunkSource.chunkMap;
|
||||
+
|
||||
+ for (int i = 0; i < rawEntities.length; i++) {
|
||||
+ Entity entity = rawEntities[i];
|
||||
+ if (entity != null) {
|
||||
+ ChunkMap.TrackedEntity entityTracker = chunkMap.entityMap.get(entity.getId());
|
||||
+ if (entityTracker != null) {
|
||||
+ if (trackerStage == TrackerStage.SEND_CHANGES) {
|
||||
+ entityTracker.serverEntity.sendChanges();
|
||||
+ } else if (trackerStage == TrackerStage.UPDATE_PLAYERS) {
|
||||
+ entityTracker.updatePlayers(entityTracker.entity.getPlayersInTrackRange());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java b/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java
|
||||
index 0fd814f1d65c111266a2b20f86561839a4cef755..169ac3ad1b1e8e3e1874ada2471e478233c6ada7 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java
|
||||
@@ -15,7 +15,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||
|
||||
/* list impl */
|
||||
protected E[] listElements;
|
||||
- protected int listSize;
|
||||
+ protected int listSize; public int getListSize() { return this.listSize; } // petal - expose listSize
|
||||
|
||||
protected final double maxFragFactor;
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
||||
index f597d65d56964297eeeed6c7e77703764178fee0..665c377e2d0d342f4dcc89c4cbdfcc9e4b96e95c 100644
|
||||
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
||||
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
||||
@@ -35,7 +35,7 @@ public final class ChunkEntitySlices {
|
||||
protected final EntityCollectionBySection allEntities;
|
||||
protected final EntityCollectionBySection hardCollidingEntities;
|
||||
protected final Reference2ObjectOpenHashMap<Class<? extends Entity>, EntityCollectionBySection> entitiesByClass;
|
||||
- protected final EntityList entities = new EntityList();
|
||||
+ public final EntityList entities = new EntityList();
|
||||
|
||||
public ChunkHolder.FullChunkStatus status;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index a2a4965aec45f3ff83703b636e46f5c545cfb48e..a693c4cbcaf9720ac9549edab32f02063607820a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1237,9 +1237,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
entity.tracker = null; // Paper - We're no longer tracked
|
||||
}
|
||||
|
||||
+ // petal start - multithreaded tracker
|
||||
+ private @Nullable host.bloom.tracker.MultithreadedTracker multithreadedTracker;
|
||||
+ private final java.util.concurrent.ConcurrentLinkedQueue<Runnable> trackerMainThreadTasks = new java.util.concurrent.ConcurrentLinkedQueue<>();
|
||||
+ private boolean tracking = false;
|
||||
+
|
||||
+ public void runOnTrackerMainThread(final Runnable runnable) {
|
||||
+ if (this.tracking) {
|
||||
+ this.trackerMainThreadTasks.add(runnable);
|
||||
+ } else {
|
||||
+ runnable.run();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// Paper start - optimised tracker
|
||||
private final void processTrackQueue() {
|
||||
+ if (true) {
|
||||
+ if (this.multithreadedTracker == null) {
|
||||
+ this.multithreadedTracker = new host.bloom.tracker.MultithreadedTracker(this.level.chunkSource.entityTickingChunks, this.trackerMainThreadTasks);
|
||||
+ }
|
||||
+
|
||||
+ this.tracking = true;
|
||||
+ try {
|
||||
+ this.multithreadedTracker.tick();
|
||||
+ } finally {
|
||||
+ this.tracking = false;
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ // petal end
|
||||
+
|
||||
this.level.timings.tracker1.startTiming();
|
||||
+ //this.level.timings.tracker1.startTiming(); // Purpur
|
||||
try {
|
||||
for (TrackedEntity tracker : this.entityMap.values()) {
|
||||
// update tracker entry
|
||||
@@ -1462,11 +1491,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
public class TrackedEntity {
|
||||
|
||||
- final ServerEntity serverEntity;
|
||||
- final Entity entity;
|
||||
+ public final ServerEntity serverEntity; // petal -> public
|
||||
+ public final Entity entity; // petal -> public
|
||||
private final int range;
|
||||
SectionPos lastSectionPos;
|
||||
- public final Set<ServerPlayerConnection> seenBy = new ReferenceOpenHashSet<>(); // Paper - optimise map impl
|
||||
+ public final Set<ServerPlayerConnection> seenBy = it.unimi.dsi.fastutil.objects.ReferenceSets.synchronize(new ReferenceOpenHashSet<>()); // Paper - optimise map impl // petal - sync
|
||||
|
||||
public TrackedEntity(Entity entity, int i, int j, boolean flag) {
|
||||
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit
|
||||
@@ -1478,7 +1507,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper start - use distance map to optimise tracker
|
||||
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> lastTrackerCandidates;
|
||||
|
||||
- final void updatePlayers(com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newTrackerCandidates) {
|
||||
+ public final void updatePlayers(com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newTrackerCandidates) { // petal -> public
|
||||
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> oldTrackerCandidates = this.lastTrackerCandidates;
|
||||
this.lastTrackerCandidates = newTrackerCandidates;
|
||||
|
||||
@@ -1550,7 +1579,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void removePlayer(ServerPlayer player) {
|
||||
- org.spigotmc.AsyncCatcher.catchOp("player tracker clear"); // Spigot
|
||||
+ //org.spigotmc.AsyncCatcher.catchOp("player tracker clear"); // Spigot // petal - we can remove async too
|
||||
if (this.seenBy.remove(player.connection)) {
|
||||
this.serverEntity.removePairing(player);
|
||||
}
|
||||
@@ -1558,7 +1587,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public void updatePlayer(ServerPlayer player) {
|
||||
- org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
|
||||
+ //org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot // petal - we can update async
|
||||
if (player != this.entity) {
|
||||
// Paper start - remove allocation of Vec3D here
|
||||
// Vec3 vec3d = player.position().subtract(this.entity.position());
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerBossEvent.java b/src/main/java/net/minecraft/server/level/ServerBossEvent.java
|
||||
index ca42c2642a729b90d22b968af7258f3aee72e14b..40261b80d947a6be43465013fae5532197cfe721 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerBossEvent.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerBossEvent.java
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.BossEvent;
|
||||
|
||||
public class ServerBossEvent extends BossEvent {
|
||||
- private final Set<ServerPlayer> players = Sets.newHashSet();
|
||||
+ private final Set<ServerPlayer> players = Sets.newConcurrentHashSet(); // petal - players can be removed in async tracking
|
||||
private final Set<ServerPlayer> unmodifiablePlayers = Collections.unmodifiableSet(this.players);
|
||||
public boolean visible = true;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 3441339e1ba5efb0e25c16fa13cb65d2fbdafc42..555336cf6700566e8a99e0f0cd6f0cc41b6c5ba0 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -249,14 +249,18 @@ public class ServerEntity {
|
||||
|
||||
public void removePairing(ServerPlayer player) {
|
||||
this.entity.stopSeenByPlayer(player);
|
||||
- player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()}));
|
||||
+ // petal start - ensure main thread
|
||||
+ ((ServerLevel) this.entity.level).chunkSource.chunkMap.runOnTrackerMainThread(() ->
|
||||
+ player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()}))
|
||||
+ );
|
||||
+ // petal end
|
||||
}
|
||||
|
||||
public void addPairing(ServerPlayer player) {
|
||||
ServerGamePacketListenerImpl playerconnection = player.connection;
|
||||
|
||||
Objects.requireNonNull(player.connection);
|
||||
- this.sendPairingData(playerconnection::send, player); // CraftBukkit - add player
|
||||
+ ((ServerLevel) this.entity.level).chunkSource.chunkMap.runOnTrackerMainThread(() -> this.sendPairingData(playerconnection::send, player)); // CraftBukkit - add player // petal - main thread
|
||||
this.entity.startSeenByPlayer(player);
|
||||
}
|
||||
|
||||
@@ -362,19 +366,30 @@ public class ServerEntity {
|
||||
SynchedEntityData datawatcher = this.entity.getEntityData();
|
||||
|
||||
if (datawatcher.isDirty()) {
|
||||
- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false));
|
||||
+ // Petal start - sync
|
||||
+ ((ServerLevel) this.entity.level).chunkSource.chunkMap.runOnTrackerMainThread(() ->
|
||||
+ this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false))
|
||||
+ );
|
||||
+ // Petal end
|
||||
}
|
||||
|
||||
if (this.entity instanceof LivingEntity) {
|
||||
Set<AttributeInstance> set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
+ // Petal start - sync
|
||||
+ final var copy = Lists.newArrayList(set);
|
||||
+ ((ServerLevel) this.entity.level).chunkSource.chunkMap.runOnTrackerMainThread(() -> {
|
||||
+
|
||||
// CraftBukkit start - Send scaled max health
|
||||
if (this.entity instanceof ServerPlayer) {
|
||||
- ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false);
|
||||
+ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(copy, false);
|
||||
}
|
||||
// CraftBukkit end
|
||||
- this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set));
|
||||
+ this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), copy));
|
||||
+
|
||||
+ });
|
||||
+ // Petal end
|
||||
}
|
||||
|
||||
set.clear();
|
||||
204
patches/server/0029-Reduce-work-done-by-game-event-system.patch
Normal file
204
patches/server/0029-Reduce-work-done-by-game-event-system.patch
Normal file
@@ -0,0 +1,204 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: peaches94 <peachescu94@gmail.com>
|
||||
Date: Sun, 10 Jul 2022 13:29:20 -0500
|
||||
Subject: [PATCH] Reduce work done by game event system
|
||||
|
||||
Original code by Bloom-host, licensed under GNU General Public License v3.0
|
||||
You can find the original code on https://github.com/Bloom-host/Petal
|
||||
|
||||
1. going into game event dispatching can be expensive so run the checks before dispatching
|
||||
|
||||
2. euclideangameeventdispatcher is not used concurrently so we ban that usage for improved performance with allays
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 3ffa7b3440b65ba3a4af4488f6ca9506e5a2128b..eb5f39b572c2a53c78aa0324ed194428e75a30a7 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1703,6 +1703,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (chunk != null) {
|
||||
for (int j2 = k; j2 <= j1; ++j2) {
|
||||
flag |= chunk.getEventDispatcher(j2).walkListeners(event, emitterPos, emitter, (gameeventlistener, vec3d1) -> {
|
||||
+ if (!gameeventlistener.listensToEvent(event, emitter)) return; // petal - if they don't listen, ignore
|
||||
(gameeventlistener.handleEventsImmediately() ? list : this.gameEventMessages).add(new GameEvent.Message(event, emitterPos, emitter, gameeventlistener, vec3d1));
|
||||
});
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
index 22c309343299e60ed8028229b7f134109001ff35..d5947d29295ddc93ba8ac1c0fc61f7badad582c4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
|
||||
@@ -85,6 +85,13 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi
|
||||
}
|
||||
}
|
||||
|
||||
+ // petal start
|
||||
+ @Override
|
||||
+ public boolean listensToEvent(GameEvent gameEvent, GameEvent.Context context) {
|
||||
+ return !this.isRemoved() && gameEvent == GameEvent.ENTITY_DIE && context.sourceEntity() instanceof LivingEntity;
|
||||
+ }
|
||||
+ // petal end
|
||||
+
|
||||
public static void serverTick(Level world, BlockPos pos, BlockState state, SculkCatalystBlockEntity blockEntity) {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.sourceBlockOverride = blockEntity.getBlockPos(); // CraftBukkit - SPIGOT-7068: Add source block override, not the most elegant way but better than passing down a BlockPosition up to five methods deep.
|
||||
blockEntity.sculkSpreader.updateCursors(world, pos, world.getRandom(), true);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 636c98d04eb4e14eab1fa208d9cb097e2ab7eef7..2ea38464a92d626127aecc41c3fc58d1cfb37e29 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -84,7 +84,18 @@ public class LevelChunk extends ChunkAccess {
|
||||
private Supplier<ChunkHolder.FullChunkStatus> fullStatus;
|
||||
@Nullable
|
||||
private LevelChunk.PostLoadProcessor postLoad;
|
||||
- private final Int2ObjectMap<GameEventDispatcher> gameEventDispatcherSections;
|
||||
+ // petal start
|
||||
+ private final GameEventDispatcher[] gameEventDispatcherSections;
|
||||
+ private static final int GAME_EVENT_DISPATCHER_RADIUS = 2;
|
||||
+
|
||||
+ private static int getGameEventSectionIndex(int sectionIndex) {
|
||||
+ return sectionIndex + GAME_EVENT_DISPATCHER_RADIUS;
|
||||
+ }
|
||||
+
|
||||
+ private static int getGameEventSectionLength(int sectionCount) {
|
||||
+ return sectionCount + (GAME_EVENT_DISPATCHER_RADIUS * 2);
|
||||
+ }
|
||||
+ // petal end
|
||||
private final LevelChunkTicks<Block> blockTicks;
|
||||
private final LevelChunkTicks<Fluid> fluidTicks;
|
||||
|
||||
@@ -113,7 +124,7 @@ public class LevelChunk extends ChunkAccess {
|
||||
this.tickersInLevel = Maps.newHashMap();
|
||||
this.clientLightReady = false;
|
||||
this.level = (ServerLevel) world; // CraftBukkit - type
|
||||
- this.gameEventDispatcherSections = new Int2ObjectOpenHashMap();
|
||||
+ this.gameEventDispatcherSections = new GameEventDispatcher[getGameEventSectionLength(this.getSectionsCount())]; // petal
|
||||
Heightmap.Types[] aheightmap_type = Heightmap.Types.values();
|
||||
int j = aheightmap_type.length;
|
||||
|
||||
@@ -446,9 +457,23 @@ public class LevelChunk extends ChunkAccess {
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
- return (GameEventDispatcher) this.gameEventDispatcherSections.computeIfAbsent(ySectionCoord, (j) -> {
|
||||
- return new EuclideanGameEventDispatcher(worldserver);
|
||||
- });
|
||||
+ // petal start
|
||||
+ int sectionIndex = getGameEventSectionIndex(this.getSectionIndexFromSectionY(ySectionCoord));
|
||||
+
|
||||
+ // drop game events that are too far away (32 blocks) from loaded sections
|
||||
+ // this matches the highest radius of game events in the game
|
||||
+ if (sectionIndex < 0 || sectionIndex >= this.gameEventDispatcherSections.length) {
|
||||
+ return GameEventDispatcher.NOOP;
|
||||
+ }
|
||||
+
|
||||
+ var dispatcher = this.gameEventDispatcherSections[sectionIndex];
|
||||
+
|
||||
+ if (dispatcher == null) {
|
||||
+ dispatcher = this.gameEventDispatcherSections[sectionIndex] = new EuclideanGameEventDispatcher(worldserver);
|
||||
+ }
|
||||
+
|
||||
+ return dispatcher;
|
||||
+ // petal end
|
||||
} else {
|
||||
return super.getEventDispatcher(ySectionCoord);
|
||||
}
|
||||
@@ -812,7 +837,7 @@ public class LevelChunk extends ChunkAccess {
|
||||
|
||||
gameeventdispatcher.unregister(gameeventlistener);
|
||||
if (gameeventdispatcher.isEmpty()) {
|
||||
- this.gameEventDispatcherSections.remove(i);
|
||||
+ this.gameEventDispatcherSections[getGameEventSectionIndex(this.getSectionIndexFromSectionY(i))] = null; // petal
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventDispatcher.java
|
||||
index 0dd708ebe81f73710de51215529c05ec61837dd3..f5b402efa86f824c460db8cac20c1c2b090f82d0 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventDispatcher.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/EuclideanGameEventDispatcher.java
|
||||
@@ -13,8 +13,8 @@ import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class EuclideanGameEventDispatcher implements GameEventDispatcher {
|
||||
private final List<GameEventListener> listeners = Lists.newArrayList();
|
||||
- private final Set<GameEventListener> listenersToRemove = Sets.newHashSet();
|
||||
- private final List<GameEventListener> listenersToAdd = Lists.newArrayList();
|
||||
+ //private final Set<GameEventListener> listenersToRemove = Sets.newHashSet(); // petal - not necessary
|
||||
+ //private final List<GameEventListener> listenersToAdd = Lists.newArrayList(); // petal
|
||||
private boolean processing;
|
||||
private final ServerLevel level;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class EuclideanGameEventDispatcher implements GameEventDispatcher {
|
||||
@Override
|
||||
public void register(GameEventListener listener) {
|
||||
if (this.processing) {
|
||||
- this.listenersToAdd.add(listener);
|
||||
+ throw new java.util.ConcurrentModificationException(); // petal - disallow concurrent modification
|
||||
} else {
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class EuclideanGameEventDispatcher implements GameEventDispatcher {
|
||||
@Override
|
||||
public void unregister(GameEventListener listener) {
|
||||
if (this.processing) {
|
||||
- this.listenersToRemove.add(listener);
|
||||
+ throw new java.util.ConcurrentModificationException(); // petal - disallow concurrent modification
|
||||
} else {
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class EuclideanGameEventDispatcher implements GameEventDispatcher {
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
GameEventListener gameEventListener = iterator.next();
|
||||
- if (this.listenersToRemove.remove(gameEventListener)) {
|
||||
+ if (false) { // petal - disallow concurrent modification
|
||||
iterator.remove();
|
||||
} else {
|
||||
Optional<Vec3> optional = getPostableListenerPosition(this.level, pos, gameEventListener);
|
||||
@@ -72,6 +72,8 @@ public class EuclideanGameEventDispatcher implements GameEventDispatcher {
|
||||
this.processing = false;
|
||||
}
|
||||
|
||||
+ // petal start
|
||||
+ /*
|
||||
if (!this.listenersToAdd.isEmpty()) {
|
||||
this.listeners.addAll(this.listenersToAdd);
|
||||
this.listenersToAdd.clear();
|
||||
@@ -81,6 +83,8 @@ public class EuclideanGameEventDispatcher implements GameEventDispatcher {
|
||||
this.listeners.removeAll(this.listenersToRemove);
|
||||
this.listenersToRemove.clear();
|
||||
}
|
||||
+ */
|
||||
+ // petal end
|
||||
|
||||
return bl;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
index e5601afe8b739da518f36ae306f5e0cb252238f0..bc8f04424c5e8c416d6988f0e06d8cadbb400ca7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventListener.java
|
||||
@@ -12,4 +12,10 @@ public interface GameEventListener {
|
||||
int getListenerRadius();
|
||||
|
||||
boolean handleGameEvent(ServerLevel world, GameEvent.Message event);
|
||||
+
|
||||
+ // petal start - add check for seeing if this listener cares about an event
|
||||
+ default boolean listensToEvent(net.minecraft.world.level.gameevent.GameEvent gameEvent, net.minecraft.world.level.gameevent.GameEvent.Context context) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // petal end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java b/src/main/java/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
|
||||
index e45f54534bbf054eaf0008546ff459d4c11ddd50..e49d0d1c2a539fcd7e75262c4010475193964287 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/vibrations/VibrationListener.java
|
||||
@@ -162,6 +162,13 @@ public class VibrationListener implements GameEventListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // petal start
|
||||
+ @Override
|
||||
+ public boolean listensToEvent(GameEvent gameEvent, GameEvent.Context context) {
|
||||
+ return this.receivingEvent == null && gameEvent.is(this.config.getListenableEvents());
|
||||
+ }
|
||||
+ // petal end
|
||||
+
|
||||
public interface VibrationListenerConfig {
|
||||
|
||||
default TagKey<GameEvent> getListenableEvents() {
|
||||
59
patches/server/0030-Reduce-sensor-work.patch
Normal file
59
patches/server/0030-Reduce-sensor-work.patch
Normal file
@@ -0,0 +1,59 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: peaches94 <peachescu94@gmail.com>
|
||||
Date: Sun, 10 Jul 2022 15:44:38 -0500
|
||||
Subject: [PATCH] Reduce sensor work
|
||||
|
||||
Original code by Bloom-host, licensed under GNU General Public License v3.0
|
||||
You can find the original code on https://github.com/Bloom-host/Petal
|
||||
|
||||
this patch is focused around the sensors used for ai
|
||||
delete the line of sight cache less often and use a faster nearby comparison
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index b163ad5fb6fea59982e26fdbd4dd5b5dcb4350a5..4f3cce05807715b978792ffa28f2d63315818f54 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1012,20 +1012,22 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||
+ // petal start - only do itemstack lookup if we need to
|
||||
+ //ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||
EntityType<?> entitytypes = entity.getType();
|
||||
|
||||
// Purpur start
|
||||
- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL)) {
|
||||
+ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL)) {
|
||||
d0 *= entity.level.purpurConfig.skeletonHeadVisibilityPercent;
|
||||
}
|
||||
- else if (entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD)) {
|
||||
+ else if (entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD)) {
|
||||
d0 *= entity.level.purpurConfig.zombieHeadVisibilityPercent;
|
||||
}
|
||||
- else if (entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) {
|
||||
+ else if (entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) {
|
||||
d0 *= entity.level.purpurConfig.creeperHeadVisibilityPercent;
|
||||
}
|
||||
// Purpur end
|
||||
+ // petal end
|
||||
|
||||
// Purpur start
|
||||
if (entity instanceof LivingEntity entityliving) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index d5e3bd662da349fc2ee58c7800d79c60300f33b3..0981873ee37fc839035b8398bac03d15adecb301 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -884,10 +884,10 @@ public abstract class Mob extends LivingEntity {
|
||||
return;
|
||||
}
|
||||
// Paper end
|
||||
+ int i = this.level.getServer().getTickCount() + this.getId(); // petal - move up
|
||||
//this.level.getProfiler().push("sensing"); // Purpur
|
||||
- this.sensing.tick();
|
||||
+ if (i % 10 == 0) this.sensing.tick(); // petal - only refresh line of sight cache every half second
|
||||
//this.level.getProfiler().pop(); // Purpur
|
||||
- int i = this.level.getServer().getTickCount() + this.getId();
|
||||
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
//this.level.getProfiler().push("targetSelector"); // Purpur
|
||||
Reference in New Issue
Block a user