From 18ad44eabc65a8666788ef84400f6643a0a407a2 Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 23 Nov 2021 15:56:42 -0800 Subject: [PATCH] several more patches --- .../api/0163-Add-more-Witch-API.patch | 0 ...ther-worlds-for-shooter-of-projectil.patch | 2 +- ...-Add-Velocity-IP-Forwarding-Support.patch} | 12 ++++---- .../0280-Add-more-Witch-API.patch} | 6 ++-- ...wned-for-Villager-Aggression-Config.patch} | 2 +- ...vent-players-from-moving-into-unloa.patch} | 12 ++++---- ...3-Reset-players-airTicks-on-respawn.patch} | 4 +-- ...after-profile-lookups-if-not-needed.patch} | 0 ...r-Thread-Pool-and-Thread-Priorities.patch} | 29 +++++++------------ todo.txt | 1 + 10 files changed, 30 insertions(+), 38 deletions(-) rename patches/{unapplied => }/api/0163-Add-more-Witch-API.patch (100%) rename patches/{unapplied => }/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch (94%) rename patches/{unapplied/server/0280-Add-Velocity-IP-Forwarding-Support.patch => server/0279-Add-Velocity-IP-Forwarding-Support.patch} (96%) rename patches/{unapplied/server/0281-Add-more-Witch-API.patch => server/0280-Add-more-Witch-API.patch} (96%) rename patches/{unapplied/server/0282-Check-Drowned-for-Villager-Aggression-Config.patch => server/0281-Check-Drowned-for-Villager-Aggression-Config.patch} (94%) rename patches/{unapplied/server/0284-Add-option-to-prevent-players-from-moving-into-unloa.patch => server/0282-Add-option-to-prevent-players-from-moving-into-unloa.patch} (90%) rename patches/{unapplied/server/0285-Reset-players-airTicks-on-respawn.patch => server/0283-Reset-players-airTicks-on-respawn.patch} (83%) rename patches/{unapplied/server/0286-Don-t-sleep-after-profile-lookups-if-not-needed.patch => server/0284-Don-t-sleep-after-profile-lookups-if-not-needed.patch} (100%) rename patches/{unapplied/server/0287-Improve-Server-Thread-Pool-and-Thread-Priorities.patch => server/0285-Improve-Server-Thread-Pool-and-Thread-Priorities.patch} (81%) diff --git a/patches/unapplied/api/0163-Add-more-Witch-API.patch b/patches/api/0163-Add-more-Witch-API.patch similarity index 100% rename from patches/unapplied/api/0163-Add-more-Witch-API.patch rename to patches/api/0163-Add-more-Witch-API.patch diff --git a/patches/unapplied/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch b/patches/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch similarity index 94% rename from patches/unapplied/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch rename to patches/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch index a248ef80d1..3fad92473f 100644 --- a/patches/unapplied/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch +++ b/patches/server/0278-MC-50319-Check-other-worlds-for-shooter-of-projectil.patch @@ -11,7 +11,7 @@ If the projectile fails to find the shooter in the current world, check other worlds. diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index daa55eed9cf385c7e2cdd0a5dceaf0a719652213..458a70f6e76eba707b890c78cbfd4f967eaf8a1b 100644 +index 1382a16d21133b368158914509eb9ef3e0694ffd..47d27f95bdd4d556f1750e7ad8493248ba63888a 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java @@ -57,6 +57,18 @@ public abstract class Projectile extends Entity { diff --git a/patches/unapplied/server/0280-Add-Velocity-IP-Forwarding-Support.patch b/patches/server/0279-Add-Velocity-IP-Forwarding-Support.patch similarity index 96% rename from patches/unapplied/server/0280-Add-Velocity-IP-Forwarding-Support.patch rename to patches/server/0279-Add-Velocity-IP-Forwarding-Support.patch index ce581a9965..a968f665c5 100644 --- a/patches/unapplied/server/0280-Add-Velocity-IP-Forwarding-Support.patch +++ b/patches/server/0279-Add-Velocity-IP-Forwarding-Support.patch @@ -128,7 +128,7 @@ index 0000000000000000000000000000000000000000..41d73aa91fb401612e087aa1b7278ba6 + } +} diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 39bdda56aaa5503efc15207261634127b462c3e7..3fd913f3e963cf2da849a52364356e3b2da11eee 100644 +index 90ce56c5b7937e8fd28da6d68448679094308c6e..2bd6241243d2fb49c91daefdec72ac573300473f 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -18,6 +18,7 @@ import javax.crypto.Cipher; @@ -155,7 +155,7 @@ index 39bdda56aaa5503efc15207261634127b462c3e7..3fd913f3e963cf2da849a52364356e3b public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) { this.state = ServerLoginPacketListenerImpl.State.HELLO; -@@ -233,6 +236,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -234,6 +237,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener this.state = ServerLoginPacketListenerImpl.State.KEY; this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.nonce)); } else { @@ -170,7 +170,7 @@ index 39bdda56aaa5503efc15207261634127b462c3e7..3fd913f3e963cf2da849a52364356e3b // Spigot start // Paper start - Cache authenticator threads authenticatorPool.execute(new Runnable() { -@@ -334,6 +345,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -335,6 +346,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener public class LoginHandler { public void fireEvents() throws Exception { @@ -183,7 +183,7 @@ index 39bdda56aaa5503efc15207261634127b462c3e7..3fd913f3e963cf2da849a52364356e3b String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName(); java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(); java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId(); -@@ -381,6 +398,40 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener +@@ -382,6 +399,40 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener // Spigot end public void handleCustomQueryPacket(ServerboundCustomQueryPacket packet) { @@ -225,10 +225,10 @@ index 39bdda56aaa5503efc15207261634127b462c3e7..3fd913f3e963cf2da849a52364356e3b } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index d62c4092737b8dc3973a67377a56370f1f27e0cb..921128242ba133d73d2ac592a5f4b7515ef2e46c 100644 +index 26c7c5c51c60086957db57e9fdc256e3940e9c39..41de977650b5b6ebb8120d31f5106342189e4a59 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -703,7 +703,7 @@ public final class CraftServer implements Server { +@@ -712,7 +712,7 @@ public final class CraftServer implements Server { @Override public long getConnectionThrottle() { // Spigot Start - Automatically set connection throttle for bungee configurations diff --git a/patches/unapplied/server/0281-Add-more-Witch-API.patch b/patches/server/0280-Add-more-Witch-API.patch similarity index 96% rename from patches/unapplied/server/0281-Add-more-Witch-API.patch rename to patches/server/0280-Add-more-Witch-API.patch index ce30836286..5a1bc8178c 100644 --- a/patches/unapplied/server/0281-Add-more-Witch-API.patch +++ b/patches/server/0280-Add-more-Witch-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add more Witch API diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java -index 94bd20db7ffea00579225e6887b8c78a3da3ff1a..365354910047631b0a4402f29ad156e6447c2606 100644 +index 75c863c2cf365c321e401e05f564518be3a7b949..43e4562dcb0de8db42ff556134f649b5e0aa4284 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Witch.java +++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java @@ -1,5 +1,8 @@ @@ -17,7 +17,7 @@ index 94bd20db7ffea00579225e6887b8c78a3da3ff1a..365354910047631b0a4402f29ad156e6 import java.util.Iterator; import java.util.List; import java.util.UUID; -@@ -157,21 +160,24 @@ public class Witch extends Raider implements RangedAttackMob { +@@ -156,21 +159,24 @@ public class Witch extends Raider implements RangedAttackMob { } if (potionregistry != null) { @@ -54,7 +54,7 @@ index 94bd20db7ffea00579225e6887b8c78a3da3ff1a..365354910047631b0a4402f29ad156e6 } } -@@ -183,6 +189,24 @@ public class Witch extends Raider implements RangedAttackMob { +@@ -182,6 +188,24 @@ public class Witch extends Raider implements RangedAttackMob { super.aiStep(); } diff --git a/patches/unapplied/server/0282-Check-Drowned-for-Villager-Aggression-Config.patch b/patches/server/0281-Check-Drowned-for-Villager-Aggression-Config.patch similarity index 94% rename from patches/unapplied/server/0282-Check-Drowned-for-Villager-Aggression-Config.patch rename to patches/server/0281-Check-Drowned-for-Villager-Aggression-Config.patch index 10fd039a07..157a9d1e6c 100644 --- a/patches/unapplied/server/0282-Check-Drowned-for-Villager-Aggression-Config.patch +++ b/patches/server/0281-Check-Drowned-for-Villager-Aggression-Config.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Check Drowned for Villager Aggression Config diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java -index 58372e9dc3d9ed751feca0cebf2306587f418ebb..8a9a9bfa95db08d063a6409f2e4cf2aa26ec3b0b 100644 +index 0a458a88c21c8eece3b08cf7f5d7533efcd879f1..ccaa50d1ba9151bd94333b6b8fc0e77bc4324990 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java +++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java @@ -79,7 +79,7 @@ public class Drowned extends Zombie implements RangedAttackMob { diff --git a/patches/unapplied/server/0284-Add-option-to-prevent-players-from-moving-into-unloa.patch b/patches/server/0282-Add-option-to-prevent-players-from-moving-into-unloa.patch similarity index 90% rename from patches/unapplied/server/0284-Add-option-to-prevent-players-from-moving-into-unloa.patch rename to patches/server/0282-Add-option-to-prevent-players-from-moving-into-unloa.patch index 3b574fa165..78e2f47164 100644 --- a/patches/unapplied/server/0284-Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/patches/server/0282-Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add option to prevent players from moving into unloaded diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 29703f57969b80e25ff9a4971e640f34fb212edf..84b0304c538766949990f26f1e4a792a633f67f4 100644 +index 7c538eba5d7e0112aae4c1584172233a3217ae89..a5da82e0dea8a1ac5699179639fbd9ebe7b6e220 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -431,4 +431,9 @@ public class PaperWorldConfig { +@@ -426,4 +426,9 @@ public class PaperWorldConfig { waterOverLavaFlowSpeed = getInt("water-over-lava-flow-speed", 5); log("Water over lava flow speed: " + waterOverLavaFlowSpeed); } @@ -20,10 +20,10 @@ index 29703f57969b80e25ff9a4971e640f34fb212edf..84b0304c538766949990f26f1e4a792a + } } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index cec99a9e7ab4efef9e7eda723821e9d7bf854946..00a12243a2981903653825edb507b96eb646fd47 100644 +index 7ed73ea4a5f7383c953ee3e28ce8f234d8ff941e..26ca0db447a76c3028dacf96bf9afd3b735bda74 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -531,6 +531,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -530,6 +530,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } speed *= 2f; // TODO: Get the speed of the vehicle instead of the player @@ -37,7 +37,7 @@ index cec99a9e7ab4efef9e7eda723821e9d7bf854946..00a12243a2981903653825edb507b96e if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // CraftBukkit end ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8); -@@ -1155,9 +1162,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -1154,9 +1161,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser float prevYaw = this.player.getYRot(); float prevPitch = this.player.getXRot(); // CraftBukkit end @@ -49,7 +49,7 @@ index cec99a9e7ab4efef9e7eda723821e9d7bf854946..00a12243a2981903653825edb507b96e double d6 = this.player.getY(); double d7 = d0 - this.firstGoodX; double d8 = d1 - this.firstGoodY; -@@ -1195,6 +1202,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser +@@ -1194,6 +1201,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } else { speed = this.player.getAbilities().walkingSpeed * 10f; } diff --git a/patches/unapplied/server/0285-Reset-players-airTicks-on-respawn.patch b/patches/server/0283-Reset-players-airTicks-on-respawn.patch similarity index 83% rename from patches/unapplied/server/0285-Reset-players-airTicks-on-respawn.patch rename to patches/server/0283-Reset-players-airTicks-on-respawn.patch index 9e80e607c7..6ff1a31d17 100644 --- a/patches/unapplied/server/0285-Reset-players-airTicks-on-respawn.patch +++ b/patches/server/0283-Reset-players-airTicks-on-respawn.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Reset players airTicks on respawn diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index c4f433832dc439830fc1584d36a197066fdb3e75..d32e6feca6c39a28f80574e4b080ddd4cbb60fdc 100644 +index 4a8afc06f58bb608055a0fabc587bf06a7110232..db7f2715534ed71a2b285de095238586fe6a35b0 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -2222,6 +2222,7 @@ public class ServerPlayer extends Player { +@@ -2252,6 +2252,7 @@ public class ServerPlayer extends Player { this.setHealth(this.getMaxHealth()); this.stopUsingItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset diff --git a/patches/unapplied/server/0286-Don-t-sleep-after-profile-lookups-if-not-needed.patch b/patches/server/0284-Don-t-sleep-after-profile-lookups-if-not-needed.patch similarity index 100% rename from patches/unapplied/server/0286-Don-t-sleep-after-profile-lookups-if-not-needed.patch rename to patches/server/0284-Don-t-sleep-after-profile-lookups-if-not-needed.patch diff --git a/patches/unapplied/server/0287-Improve-Server-Thread-Pool-and-Thread-Priorities.patch b/patches/server/0285-Improve-Server-Thread-Pool-and-Thread-Priorities.patch similarity index 81% rename from patches/unapplied/server/0287-Improve-Server-Thread-Pool-and-Thread-Priorities.patch rename to patches/server/0285-Improve-Server-Thread-Pool-and-Thread-Priorities.patch index a21cc9744c..9159a0eb9a 100644 --- a/patches/unapplied/server/0287-Improve-Server-Thread-Pool-and-Thread-Priorities.patch +++ b/patches/server/0285-Improve-Server-Thread-Pool-and-Thread-Priorities.patch @@ -12,21 +12,12 @@ server threads Allow usage of a single thread executor by not using ForkJoin so single core CPU's. diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java -index 65e0ca442980f273d2fe5f131e174cd92f80da20..81f4f26a6b83079d36acd1fd86dede0eb1116c01 100644 +index 3ed0bf0485266c0a2b459f5cc1940f85f74e3624..b9775bc4e601fe1be8e514222e56ae782a897395 100644 --- a/src/main/java/net/minecraft/Util.java +++ b/src/main/java/net/minecraft/Util.java -@@ -56,7 +56,7 @@ import java.util.stream.Stream; - import javax.annotation.Nullable; - import net.minecraft.resources.ResourceLocation; - import net.minecraft.server.Bootstrap; --import net.minecraft.util.Mth; -+import net.minecraft.server.ServerWorkerThread; - import net.minecraft.util.datafix.DataFixers; - import net.minecraft.world.level.block.state.properties.Property; - import org.apache.commons.io.IOUtils; -@@ -65,8 +65,8 @@ import org.apache.logging.log4j.Logger; - - public class Util { +@@ -68,8 +68,8 @@ public class Util { + private static final int DEFAULT_MAX_THREADS = 255; + private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1); - private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap"); - private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main"); @@ -35,12 +26,12 @@ index 65e0ca442980f273d2fe5f131e174cd92f80da20..81f4f26a6b83079d36acd1fd86dede0e private static final ExecutorService IO_POOL = makeIoExecutor(); public static LongSupplier timeSource = System::nanoTime; public static final UUID NIL_UUID = new UUID(0L, 0L); -@@ -101,14 +101,18 @@ public class Util { +@@ -105,14 +105,18 @@ public class Util { return Instant.now().toEpochMilli(); } - private static ExecutorService makeExecutor(String name) { -- int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, 7); +- int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, getMaxThreads()); + private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority + // Paper start - use simpler thread pool that allows 1 thread + int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 1)); @@ -52,13 +43,13 @@ index 65e0ca442980f273d2fe5f131e174cd92f80da20..81f4f26a6b83079d36acd1fd86dede0e } else { - executorService = new ForkJoinPool(i, (forkJoinPool) -> { - ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(forkJoinPool) { -+ executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue(), target -> new ServerWorkerThread(target, s, priorityModifier)); ++ executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue(), target -> new net.minecraft.server.ServerWorkerThread(target, s, priorityModifier)); + } + /* @Override protected void onTermination(Throwable throwable) { if (throwable != null) { -@@ -124,6 +128,7 @@ public class Util { +@@ -128,6 +132,7 @@ public class Util { return forkJoinWorkerThread; }, Util::onThreadException, true); } @@ -67,10 +58,10 @@ index 65e0ca442980f273d2fe5f131e174cd92f80da20..81f4f26a6b83079d36acd1fd86dede0e return executorService; } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 00920e574ee1f104781d1f776d88ec9cd45eda93..a9f40f74cbd35533c6a334020c4f3ecd7ced3a43 100644 +index a9f54a691af0cd15cbc38af8b8df3831de244aa7..19e7488055447d3bc402150c6686f96dfd592ac2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -317,6 +317,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop