diff --git a/gradle.properties b/gradle.properties index 2f38a5c1..dd8f75ee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group = patina.patina version = 1.20.4-R0.1-SNAPSHOT mcVersion = 1.20.4 -paperRef = 61768e08e7cbfd40f9d909d7032df8796536c99c +paperRef = b3c81089ae26cc3ad2e7388c7b64457f3f83c98a org.gradle.parallel = true org.gradle.caching = true diff --git a/patches/api/0001-pufferfish-API-Changes-commit-cf00db8b947df008391625.patch b/patches/api/0001-pufferfish-API-Changes-commit-f5fa99a04ddcc3424bb0fb.patch similarity index 98% rename from patches/api/0001-pufferfish-API-Changes-commit-cf00db8b947df008391625.patch rename to patches/api/0001-pufferfish-API-Changes-commit-f5fa99a04ddcc3424bb0fb.patch index eac31384..f032787f 100644 --- a/patches/api/0001-pufferfish-API-Changes-commit-cf00db8b947df008391625.patch +++ b/patches/api/0001-pufferfish-API-Changes-commit-f5fa99a04ddcc3424bb0fb.patch @@ -1,8 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> -Date: Wed, 27 Dec 2023 00:32:40 +0800 +Date: Tue, 6 Feb 2024 15:43:40 +1100 Subject: [PATCH] pufferfish API Changes commit - cf00db8b947df008391625a2fb559d8077afde6d + f5fa99a04ddcc3424bb0fbeea74033f0e5e651a2 Add Sentry @@ -22,7 +22,7 @@ This patch does not add any API that should be used by plugins. Any classes and methods added by this patch should NOT be used in plugins. diff --git a/build.gradle.kts b/build.gradle.kts -index bf01892c248b988531d21d9fb0f74d0adf2205ac..80833c13a2d19e31d6f648e7ef5b3456025e767e 100644 +index 50dd795c67557c7d2668068af0bba87a1ec8dc43..28a3ee2f2df6f93a894793abc03d357a9010a399 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,6 +51,7 @@ dependencies { @@ -482,7 +482,7 @@ index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..301e82369603f3dd6e6c1bd380da4bac if (cloader instanceof PluginClassLoader) { diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java -index f9b57b872780aa6b9b959494874b57c7a8ff0c53..90953bfc81168068a281be4d2d3942d5e7dd69ff 100644 +index 7e4f7cb2afbc145e532285c793573ad107bc3033..12449e18180d604e9cbbc744da74a8b222a18e1f 100644 --- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -50,6 +50,8 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm diff --git a/patches/server/0001-pufferfish-Server-Changes-commit-cf00db8b947df008391.patch b/patches/server/0001-pufferfish-Server-Changes-commit-f5fa99a04ddcc3424bb.patch similarity index 94% rename from patches/server/0001-pufferfish-Server-Changes-commit-cf00db8b947df008391.patch rename to patches/server/0001-pufferfish-Server-Changes-commit-f5fa99a04ddcc3424bb.patch index fbdb062e..a49433ef 100644 --- a/patches/server/0001-pufferfish-Server-Changes-commit-cf00db8b947df008391.patch +++ b/patches/server/0001-pufferfish-Server-Changes-commit-f5fa99a04ddcc3424bb.patch @@ -1,8 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: foss-mc <69294560+foss-mc@users.noreply.github.com> -Date: Wed, 27 Dec 2023 00:32:39 +0800 +Date: Tue, 6 Feb 2024 15:43:40 +1100 Subject: [PATCH] pufferfish Server Changes commit - cf00db8b947df008391625a2fb559d8077afde6d + f5fa99a04ddcc3424bb0fbeea74033f0e5e651a2 Pufferfish Utils @@ -282,11 +282,13 @@ disabling this will prevent the server from performing an expensive search to attempt respawning the ender dragon whenever a player places an end crystal. +TPS catchup + diff --git a/build.gradle.kts b/build.gradle.kts -index 58da26ad2f128ba0b66f86820f60853f4be352f0..d06e2ac3eb0d218f9982ab3ecc02e35528ea38f9 100644 +index 376e8983fdfdbb6c3e5fd8ad0f6a05e655b622bf..368eddbcf2fbda9c2060e1a8d17f7d8474b16c73 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -51,6 +51,14 @@ dependencies { +@@ -50,6 +50,14 @@ dependencies { runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18") runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18") @@ -301,7 +303,7 @@ index 58da26ad2f128ba0b66f86820f60853f4be352f0..d06e2ac3eb0d218f9982ab3ecc02e355 testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test testImplementation("org.junit.jupiter:junit-jupiter:5.10.0") testImplementation("org.hamcrest:hamcrest:2.2") -@@ -58,6 +66,14 @@ dependencies { +@@ -57,6 +65,14 @@ dependencies { } val craftbukkitPackageVersion = "1_20_R3" // Paper @@ -317,10 +319,10 @@ index 58da26ad2f128ba0b66f86820f60853f4be352f0..d06e2ac3eb0d218f9982ab3ecc02e355 archiveClassifier.set("dev") diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java -index a2f71a6d1a9e98133dff6cd0f625da9435a8af14..ff940e43ca35094bbcae6c7d471d3c4aeb7c1727 100644 +index 7620c72a4c243cbeea245203ce03a97cbfa7d922..b35a9f4c5f8960864c402ede8a51fb5ab9c4fcc0 100644 --- a/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java -@@ -242,7 +242,8 @@ public class TimingsExport extends Thread { +@@ -240,7 +240,8 @@ public class TimingsExport extends Thread { parent.put("config", createObject( pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)), pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), @@ -829,10 +831,10 @@ index 0000000000000000000000000000000000000000..020368da69b9a492155f6de6297f7473 +} diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..6755008dc43bf96c1507ce2ae6a066a1b75df760 +index 0000000000000000000000000000000000000000..1ca25529245ed369b8705075a8c2e32fa4d9b1d1 --- /dev/null +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -@@ -0,0 +1,326 @@ +@@ -0,0 +1,334 @@ +package gg.pufferfish.pufferfish; + +import gg.pufferfish.pufferfish.simd.SIMDDetection; @@ -1023,6 +1025,14 @@ index 0000000000000000000000000000000000000000..6755008dc43bf96c1507ce2ae6a066a1 + "disabling this option.", + "This can be overridden per-player with the permission pufferfish.usebooks"); + } ++ ++ public static boolean tpsCatchup; ++ private static void tpsCatchup() { ++ tpsCatchup = getBoolean("tps-catchup", true, ++ "If this setting is true, the server will run faster after a lag spike in", ++ "an attempt to maintain 20 TPS. This option (defaults to true per", ++ "spigot/paper) can cause mobs to move fast after a lag spike."); ++ } + + public static boolean enableSuffocationOptimization; + private static void suffocationOptimization() { @@ -2293,7 +2303,7 @@ index a6f58b3457b7477015c5c6d969e7d83017dd3fa1..a27ee205d13dda890646ebf451076f38 } } diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index 200ed770b57e1a9240abf0473968d4b85cbefe3c..0acc7cfc0fb0264dd76a58f7582e79d83fa040eb 100644 +index 1ccf71be865af4d3c5ab8f4323a228a947e0bf3f..3f3f8443563e4ca6c7fb236e7a98eaae3be3b43e 100644 --- a/src/main/java/io/papermc/paper/util/MCUtil.java +++ b/src/main/java/io/papermc/paper/util/MCUtil.java @@ -212,7 +212,7 @@ public final class MCUtil { @@ -2306,32 +2316,44 @@ index 200ed770b57e1a9240abf0473968d4b85cbefe3c..0acc7cfc0fb0264dd76a58f7582e79d8 public static long getCoordinateKey(final ChunkPos pair) { diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java -index 85a8a687b1568a56e3e646b37ef78b562c1b8a82..69971b2c59e541ac4100b84c84e2972de1b44ca9 100644 +index ba12919c3f9aec34a9e64993b143ae92be5eb172..9efeab9078e2d08903e482718b840797e22ab1c2 100644 --- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java +++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java @@ -38,7 +38,7 @@ public class SignedMessageChain { throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false); // Paper - diff on change (if disconnects, need a new kick event cause) } else if (playerPublicKey.data().hasExpired()) { - throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey", org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY), false); // Paper - kick event causes + throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey"), false, org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY); // Paper - kick event causes - } else if (body.timeStamp().isBefore(this.lastTimeStamp)) { + } else if (!gg.pufferfish.pufferfish.PufferfishConfig.disableOutOfOrderChat && body.timeStamp().isBefore(this.lastTimeStamp)) { // Pufferfish - throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.out_of_order_chat", org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT), true); // Paper - kick event causes + throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.out_of_order_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event causes } else { this.lastTimeStamp = body.timeStamp(); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 34f19ac897a30c0c4e3ab406013fcca1c8b7db93..dc8f1de69bb056935d25ee2a050f260aa1ad913a 100644 +index 90ae7e8c81f6a9ede8aeaeec3bf784023522cefc..cefc05ddb198bff00924f038b39195a5b9ccb05d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -314,6 +314,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); -@@ -2453,6 +2455,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop needsChangeBroadcasting = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); @@ -2373,7 +2395,7 @@ index caa73632aee15583c6b6ed12a668c8f49b794708..3abec84383a445d3ad0d3b5f613246b6 // Paper end - optimise chunk tick iteration public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory, int viewDistance, boolean dsync) { -@@ -1464,8 +1464,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1448,8 +1448,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance); } @@ -2402,7 +2424,7 @@ index caa73632aee15583c6b6ed12a668c8f49b794708..3abec84383a445d3ad0d3b5f613246b6 Iterator iterator = this.entity.getIndirectPassengers().iterator(); while (iterator.hasNext()) { -@@ -1477,6 +1497,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1461,6 +1481,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider i = j; } } @@ -2413,20 +2435,20 @@ index caa73632aee15583c6b6ed12a668c8f49b794708..3abec84383a445d3ad0d3b5f613246b6 return this.scaledRange(i); } diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a95894e0f 100644 +index 366c0c9b45a819f7f94ebe3e49b8ab7f9edf9ce7..1cf8c819c0d7776c3b33d6594ca81abe3c2a719d 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -73,6 +73,9 @@ public class ServerChunkCache extends ChunkSource { - final it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap loadedChunkMap = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(8192, 0.5f); - +@@ -77,6 +77,9 @@ public class ServerChunkCache extends ChunkSource { private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4]; -+ + // Paper end + + public boolean firstRunSpawnCounts = true; // Pufferfish + public final java.util.concurrent.atomic.AtomicBoolean _pufferfish_spawnCountsReady = new java.util.concurrent.atomic.AtomicBoolean(false); // Pufferfish - optimize countmobs - - private static int getChunkCacheKey(int x, int z) { - return x & 3 | ((z & 3) << 2); -@@ -521,6 +524,7 @@ public class ServerChunkCache extends ChunkSource { ++ + public ServerChunkCache(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier persistentStateManagerFactory) { + this.level = world; + this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(world); +@@ -513,6 +516,7 @@ public class ServerChunkCache extends ChunkSource { // Paper - optimise chunk tick iteration @@ -2434,7 +2456,7 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a if (this.level.getServer().tickRateManager().runsNormally()) { gameprofilerfiller.popPush("naturalSpawnCount"); this.level.timings.countNaturalMobs.startTiming(); // Paper - timings -@@ -529,6 +533,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -521,6 +525,7 @@ public class ServerChunkCache extends ChunkSource { int naturalSpawnChunkCount = k; NaturalSpawner.SpawnState spawnercreature_d; // moved down if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled @@ -2442,7 +2464,7 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a // re-set mob counts for (ServerPlayer player : this.level.players) { // Paper start - per player mob spawning backoff -@@ -543,14 +548,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -535,14 +540,18 @@ public class ServerChunkCache extends ChunkSource { } // Paper end - per player mob spawning backoff } @@ -2456,7 +2478,7 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a + _pufferfish_spawnCountsReady.set(true); + // Pufferfish end } - // Paper end + // Paper end - Optional per player mob spawns this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings - this.lastSpawnState = spawnercreature_d; @@ -2464,7 +2486,7 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a gameprofilerfiller.popPush("spawnAndTick"); boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit -@@ -640,8 +649,8 @@ public class ServerChunkCache extends ChunkSource { +@@ -632,8 +641,8 @@ public class ServerChunkCache extends ChunkSource { if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) { // Paper end - optimise chunk tick iteration chunk1.incrementInhabitedTime(j); @@ -2475,7 +2497,7 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a } if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration -@@ -688,6 +697,40 @@ public class ServerChunkCache extends ChunkSource { +@@ -680,6 +689,40 @@ public class ServerChunkCache extends ChunkSource { gameprofilerfiller.pop(); gameprofilerfiller.pop(); } @@ -2517,10 +2539,10 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5cf74fe0214191d42e74fc104eba150a private void getFullChunk(long pos, Consumer chunkConsumer) { diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 35674f92a67f93382103c2766df4b678ba5c862f..d46e61640b241d32df05240dedd2c23f138725e6 100644 +index 529ab44baaf573b97cf7e89560c548642733188f..db55ad9aaabfa1ea998754f3ac352d1698936696 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -177,7 +177,8 @@ public class ServerEntity { +@@ -183,7 +183,8 @@ public class ServerEntity { long i1 = this.positionCodec.encodeZ(vec3d); boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; @@ -2530,7 +2552,7 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..d46e61640b241d32df05240dedd2c23f if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) { if (flag2) { packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.onGround()); -@@ -191,6 +192,7 @@ public class ServerEntity { +@@ -197,6 +198,7 @@ public class ServerEntity { flag4 = true; flag5 = true; } @@ -2539,10 +2561,10 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..d46e61640b241d32df05240dedd2c23f this.wasOnGround = this.entity.onGround(); this.teleportDelay = 0; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index b78a9628a88f2a495ef6de74446a02a14d41a1f6..66cbea2fd146bdabf1241dae72bd76dc256afe45 100644 +index 6934e9dac0d69c043b73b7c46d59f2d39b37c67f..dbe612427b894df9da1335b94163ba9b89b090c0 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -895,6 +895,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -894,6 +894,7 @@ public class ServerLevel extends Level implements WorldGenLevel { org.spigotmc.ActivationRange.activateEntities(this); // Spigot this.timings.entityTick.startTiming(); // Spigot this.entityTickList.forEach((entity) -> { @@ -2550,7 +2572,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..66cbea2fd146bdabf1241dae72bd76dc if (!entity.isRemoved()) { if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed entity.discard(); -@@ -914,7 +915,20 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -913,7 +914,20 @@ public class ServerLevel extends Level implements WorldGenLevel { } gameprofilerfiller.push("tick"); @@ -2572,7 +2594,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..66cbea2fd146bdabf1241dae72bd76dc gameprofilerfiller.pop(); } } -@@ -979,9 +993,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -978,9 +992,11 @@ public class ServerLevel extends Level implements WorldGenLevel { } // Paper start - optimise random block ticking private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos(); @@ -2585,25 +2607,25 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..66cbea2fd146bdabf1241dae72bd76dc public void tickChunk(LevelChunk chunk, int randomTickSpeed) { ChunkPos chunkcoordintpair = chunk.getPos(); boolean flag = this.isRaining(); -@@ -992,7 +1008,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -991,7 +1007,7 @@ public class ServerLevel extends Level implements WorldGenLevel { gameprofilerfiller.push("thunder"); final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change -- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - disable thunder -+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - disable thunder // Pufferfish - replace random with shouldDoLightning +- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder ++ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - Option to disable thunder // Pufferfish - replace random with shouldDoLightning blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper if (this.isRainingAt(blockposition)) { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 30ccbab1586a656e0ae41d7406525fb02d9e025b..20cd751a602593740e87eb79d5059b5fc7856cb5 100644 +index 8ca5d7c1bfacb1b47aa680eee167af08d0396ae0..dbcf025c07abafee639d8b94bf963962b5e85478 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1124,6 +1124,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1121,6 +1121,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleEditBook(ServerboundEditBookPacket packet) { + if (!gg.pufferfish.pufferfish.PufferfishConfig.enableBooks && !this.player.getBukkitEntity().hasPermission("pufferfish.usebooks")) return; // Pufferfish - // Paper start + // Paper start - Book size limits if (!this.cserver.isPrimaryThread()) { List pageList = packet.getPages(); diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java @@ -2719,10 +2741,10 @@ index d6cbe98e67fdbf8db46338a88ab1356dd63b50a3..20dd3a63b2f955b05a75eb240e33ae4c int LARGE_MAX_STACK_SIZE = 64; int DEFAULT_DISTANCE_LIMIT = 8; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..b8810cce6f4995d78dca3691b0a1cbd133a05e06 100644 +index 2c06f3ebf7e1069727387bfc60db30c958c14b5a..1d9331fe9ce7308eda2e7da2ae726810d455f090 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -307,7 +307,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -308,7 +308,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public double yo; public double zo; private Vec3 position; @@ -2731,20 +2753,17 @@ index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..b8810cce6f4995d78dca3691b0a1cbd1 private ChunkPos chunkPosition; private Vec3 deltaMovement; private float yRot; -@@ -438,6 +438,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - return this.originWorld; - } - // Paper end -+ // Pufferfish start -+ public boolean activatedPriorityReset = false; // DAB -+ public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // golf score -+ public final BlockPos.MutableBlockPos cachedBlockPos = new BlockPos.MutableBlockPos(); // used where needed -+ // Pufferfish end -+ - public float getBukkitYaw() { - return this.yRot; - } -@@ -802,6 +808,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -423,6 +423,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + private UUID originWorld; + public boolean freezeLocked = false; // Paper - Freeze Tick Lock API + public boolean fixedPose = false; // Paper - Expand Pose API ++ public boolean activatedPriorityReset = false; // Pufferfish - DAB ++ public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // Pufferfish - DAB (golf score) ++ public final BlockPos.MutableBlockPos cachedBlockPos = new BlockPos.MutableBlockPos(); // Pufferfish - reduce entity allocations + + public void setOrigin(@javax.annotation.Nonnull Location location) { + this.origin = location.toVector(); +@@ -807,6 +810,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } public void tick() { @@ -2757,7 +2776,7 @@ index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..b8810cce6f4995d78dca3691b0a1cbd1 this.baseTick(); } -@@ -4399,16 +4411,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4402,16 +4411,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { @@ -2783,7 +2802,7 @@ index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..b8810cce6f4995d78dca3691b0a1cbd1 double d1 = 0.0D; boolean flag = this.isPushedByFluid(); boolean flag1 = false; -@@ -4416,14 +4430,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4419,14 +4430,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); @@ -2851,7 +2870,7 @@ index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..b8810cce6f4995d78dca3691b0a1cbd1 if (d2 >= axisalignedbb.minY) { flag1 = true; -@@ -4445,9 +4506,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4448,9 +4506,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S // CraftBukkit end } } @@ -2865,7 +2884,7 @@ index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..b8810cce6f4995d78dca3691b0a1cbd1 if (vec3d.length() > 0.0D) { if (k1 > 0) { diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 940b8d0b89d7e55c938aefbe80ee71b0db3dacb8..a63399eedb896c06e96c7fba5cac7102e1c40ba6 100644 +index edc723ea5ca3a325106e7af38c60dbf9f0f5fb77..ab6cd363231a668c9b16df825a72d3205746ee49 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java @@ -305,6 +305,8 @@ public class EntityType implements FeatureElement, EntityTypeT @@ -2878,7 +2897,7 @@ index 940b8d0b89d7e55c938aefbe80ee71b0db3dacb8..a63399eedb896c06e96c7fba5cac7102 private String descriptionId; @Nullable diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 45b1a182acf6b2aef40b714d31ca125d8f74619a..e24e20a63b74e82afb7f911d286b9bdf72d87afb 100644 +index 6071451339080bbdd98fb634791a56988984c8bc..5641bc7f50cef7819ddaeb76a4a4f9c80f473d31 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -142,7 +142,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; @@ -2898,7 +2917,7 @@ index 45b1a182acf6b2aef40b714d31ca125d8f74619a..e24e20a63b74e82afb7f911d286b9bdf this.hurt(this.damageSources().inWall(), 1.0F); } else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) { double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone(); -@@ -1408,6 +1407,19 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1409,6 +1408,19 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.getHealth() <= 0.0F; } @@ -2918,7 +2937,7 @@ index 45b1a182acf6b2aef40b714d31ca125d8f74619a..e24e20a63b74e82afb7f911d286b9bdf @Override public boolean hurt(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { -@@ -2001,6 +2013,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2002,6 +2014,20 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.lastClimbablePos; } @@ -2940,7 +2959,7 @@ index 45b1a182acf6b2aef40b714d31ca125d8f74619a..e24e20a63b74e82afb7f911d286b9bdf if (this.isSpectator()) { return false; diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 5af48151159135b869ec4753bbcf79dd257c1570..1d65d8b3e21373b0f0d2c633742da52d6b208942 100644 +index 24629412d2b4acaa81788ce70412b03387cc777c..a181a298334212847166409a2121476ba5871cb2 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -221,14 +221,16 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -2984,7 +3003,7 @@ index 5af48151159135b869ec4753bbcf79dd257c1570..1d65d8b3e21373b0f0d2c633742da52d this.level().getProfiler().pop(); } diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index 7204b973c3ad9239e82355513f6d538107102e48..3087f8359b098682a345399c85395de8a15b6eed 100644 +index 897d7632ecfea40890433474870dd7a5e534d8ab..683c9693754d1a87b7e8fccc757a0d0963351f60 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -23,9 +23,11 @@ public class AttributeMap { @@ -3031,7 +3050,7 @@ index 646d9a121d908a2fc3e4e302484dd5cd1bfc6804..e546ecdccde352502e26a8668eaaafe0 } diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -index b738ee2d3801fadfd09313f05ae24593e56b0ec6..1635818fc4b1788c0d397085239df6dd75b210ab 100644 +index 676f5485a4ca9252e911213dcda8d51776b637b6..2d63ee8fef87264d4b61290effa6ba86a787aa61 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -53,9 +53,12 @@ public class GoalSelector { @@ -3050,19 +3069,19 @@ index b738ee2d3801fadfd09313f05ae24593e56b0ec6..1635818fc4b1788c0d397085239df6dd public boolean hasTasks() { for (WrappedGoal task : this.availableGoals) { diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -index 4bbc36404b396500df0d9db380cf223b5897662e..382e9d18b81bcbeb20cb3b828b66260f07a845e6 100644 +index 07519c817cc6de04a98198c43a0c2b02ba3141eb..ee66be6e5aa45ec8448b6d30785a6e71200b09e3 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -@@ -119,6 +119,7 @@ public abstract class MoveToBlockGoal extends Goal { +@@ -120,6 +120,7 @@ public abstract class MoveToBlockGoal extends Goal { for(int m = 0; m <= l; m = m > 0 ? -m : 1 - m) { for(int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) { mutableBlockPos.setWithOffset(blockPos, m, k - 1, n); + if (!this.mob.level().hasChunkAt(mutableBlockPos)) continue; // Pufferfish - if this block isn't loaded, continue if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) { this.blockPos = mutableBlockPos; - setTargetPosition(mutableBlockPos.immutable()); // Paper + this.mob.movingTarget = mutableBlockPos == BlockPos.ZERO ? null : mutableBlockPos.immutable(); // Paper diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152cac963b8 100644 +index c8a80c1b2fedff22e8a877d466062375ffb2f0d7..931cbbe41905d7ed3fd46c53d3ddd06a6b9a7c8a 100644 --- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java @@ -75,9 +75,18 @@ public class TargetingConditions { @@ -3070,7 +3089,7 @@ index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152 if (this.range > 0.0D) { - double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D; -- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper +- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656 + // Pufferfish start - check range before getting visibility + // d = invisibility percent, e = follow range adjusted for invisibility, f = distance double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); @@ -3081,13 +3100,13 @@ index c157309ac78e7af084d3acb6e8b2bcd469a39d5e..ac5e5676b194a2a99e5cf53eb89c1152 + } + + double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D; -+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper ++ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper - Fix MC-145656 + // Pufferfish end if (f > e * e) { return false; } diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -index 6b614818b14ecfc8fc82b523eeb7e21fdf9bf1ba..8820905ac733a8915cc1697259b2bef14d97e471 100644 +index 44fa2d4f90389f5526746bd94a2450c03340bd0b..4fba7c2f6ec363846a772ef2a63e9b3fc1037de5 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java @@ -241,13 +241,22 @@ public class Bat extends AmbientCreature { @@ -3131,7 +3150,7 @@ index 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cf this.level().getProfiler().pop(); this.level().getProfiler().push("allayActivityUpdate"); diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index 387006271c246362b0df1bfcadca7b7096660003..9158c5a507904c46a8fe2fdad9a0b6ba3a9b2460 100644 +index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e7487913437c9f9db4 100644 --- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java @@ -275,9 +275,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder getTypeKey(); - ++ + protected final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(java.util.concurrent.ThreadLocalRandom.current().nextLong()); public net.minecraft.util.RandomSource getThreadUnsafeRandom() { return this.randomTickRandom; } // Pufferfish - move thread unsafe random initialization // Pufferfish - getter -+ - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor + + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper -@@ -1319,13 +1321,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1313,14 +1315,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { try { tickConsumer.accept(entity); MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick - } catch (Throwable throwable) { + } catch (Throwable throwable) { // Pufferfish - diff on change ServerLevel.tick if (throwable instanceof ThreadDeath) throw throwable; // Paper - // Paper start - Prevent tile entity and entity crashes + // Paper start - Prevent block entity and entity crashes final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level().getWorld().getName(), entity.getX(), entity.getY(), entity.getZ()); MinecraftServer.LOGGER.error(msg, throwable); - getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); + getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); // Paper - ServerExceptionEvent - entity.discard(); +- // Paper end - Prevent block entity and entity crashes + entity.discard(); // Pufferfish - diff on change ServerLevel.tick - // Paper end ++ // Paper end } } -@@ -1799,6 +1801,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + // Paper start - Option to prevent armor stands from doing entity lookups +@@ -1793,6 +1795,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } public ProfilerFiller getProfiler() { @@ -3538,7 +3559,7 @@ index 0b56e5f7f18fc4286992af22d402205b771165a3..527ece810f0bd16ba7d94c4576764902 } diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 3cdddda9c0618e95288b81b975d499c8dd30c05f..9c2d62feff1816f5729060c6192269a5b2d34153 100644 +index 17e9f3a30e287faf210e08dc7eb177a70f049f43..96fc603c2fccc1d9610248b2116d35696bc65e4e 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -429,12 +429,12 @@ public final class NaturalSpawner { @@ -3608,7 +3629,7 @@ index 4f9187d9d640618c40a2fa528f36b845017b4777..efca73d4de33028cf9df944f36e51b7b } } diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java -index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f3040b26a 100644 +index 9b1243d96e0694c62fc9e82e9be540bce0d2b3ad..3514022d898a24052c917ebf55dcef3e757d6836 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java @@ -31,7 +31,10 @@ import org.bukkit.entity.HumanEntity; @@ -3686,7 +3707,7 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..d66806565770cb03a21794f99e5c4b0f @Override diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index d4dcf7fe26474ae07374e7761d823bc5c8b54f97..1d13fabb3f34023b4fbb1be9ad02ebc606645531 100644 +index a61d7cd2b078fe511ff00344197b6ea11feebfb2..7041394d366e6145369d032a0a14f0478af4679f 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -3745,23 +3766,22 @@ index d4dcf7fe26474ae07374e7761d823bc5c8b54f97..1d13fabb3f34023b4fbb1be9ad02ebc6 private static boolean isFullContainer(Container inventory, Direction direction) { + if (true) return inventory.isCompletelyFull(direction); // Pufferfish - use bitsets - // Paper start - optimize hoppers + // Paper start - Perf: Optimize Hoppers if (inventory instanceof WorldlyContainer worldlyContainer) { for (final int slot : worldlyContainer.getSlotsForFace(direction)) { -@@ -513,7 +540,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -513,7 +540,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } private static boolean isEmptyContainer(Container inv, Direction facing) { -- return allMatch(inv, facing, IS_EMPTY_TEST); -+ // Paper start +- return allMatch(inv, facing, IS_EMPTY_TEST); // Paper - Perf: Optimize Hoppers + // Pufferfish start - use bitsets -+ //return allMatch(inv, facing, IS_EMPTY_TEST); ++ //return allMatch(inv, facing, IS_EMPTY_TEST); // Paper - Perf: Optimize Hoppers + return inv.isCompletelyEmpty(facing); + // Pufferfish end } public static boolean suckInItems(Level world, Hopper hopper) { -@@ -713,7 +744,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -713,7 +743,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) { boolean flag = false; @@ -3770,7 +3790,7 @@ index d4dcf7fe26474ae07374e7761d823bc5c8b54f97..1d13fabb3f34023b4fbb1be9ad02ebc6 if (itemstack1.isEmpty()) { // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem -@@ -908,7 +939,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -908,7 +938,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Override protected void setItems(NonNullList list) { @@ -3783,13 +3803,13 @@ index d4dcf7fe26474ae07374e7761d823bc5c8b54f97..1d13fabb3f34023b4fbb1be9ad02ebc6 public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 64875525df244db838560f5fefb7b1b07b0f1f51..1436fdbe31c8cdf05ac56f20224fe91de4b1c0c3 100644 +index a94300a457b25f0e33a8eeabba6dd5720ca9ab1e..b41635dd0569ff7df909df492d3e850aef7214be 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java @@ -94,12 +94,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc public boolean isEmpty() { this.unpackLootTable((Player)null); - // Paper start + // Paper start - Perf: Optimize Hoppers - for (final ItemStack itemStack : this.getItems()) { - if (!itemStack.isEmpty()) { - return false; @@ -3797,11 +3817,11 @@ index 64875525df244db838560f5fefb7b1b07b0f1f51..1436fdbe31c8cdf05ac56f20224fe91d - } - return true; + return this.isCompletelyEmpty(null); // Pufferfish - use super - // Paper end + // Paper end - Perf: Optimize Hoppers } 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 fa170cc1ce7011d201295b89718292d696c7fc24..7fd68d4aba72b15b2e21e5c88b44e677b794fe57 100644 +index 6ec3fc801453fd54c25b642e6fa71c19b463311d..922191159fadf8e89646d7299aadee4aa851f71a 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -86,6 +86,18 @@ public class LevelChunk extends ChunkAccess { @@ -3833,7 +3853,7 @@ index fa170cc1ce7011d201295b89718292d696c7fc24..7fd68d4aba72b15b2e21e5c88b44e677 // CraftBukkit start diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb522646b5ee1c2 100644 +index 796bbef3544e06b8e7aac7e8ac5f740a2613f4bd..2422ca3ffc6ab7178cacf933b8013f85e7de4bd9 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -25,6 +25,7 @@ public class LevelChunkSection { @@ -3860,14 +3880,14 @@ index f0de72afad4bb571153436399386a6a8a70582a6..45b7527341fcb6d24f35318cedb52264 } this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions -@@ -161,6 +164,7 @@ public class LevelChunkSection { - if (fluid.isRandomlyTicking()) { - this.tickingFluidCount = (short) (this.tickingFluidCount + 1); - } +@@ -162,6 +165,7 @@ public class LevelChunkSection { + if (fluid.isRandomlyTicking()) { + this.tickingFluidCount = (short) (this.tickingFluidCount + 1); + } + this.fluidStateCount++; // Pufferfish - } + } - // Paper start - optimise collisions + // Paper start - optimise collisions diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java index 4cdfc433df67afcd455422e9baf56f167dd712ae..57fcf3910f45ce371ac2e237b277b1034caaac4e 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java @@ -3882,7 +3902,7 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..57fcf3910f45ce371ac2e237b277b103 private void ensureActiveIsNotIterated() { // Paper - replace with better logic, do not delay removals diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af5f81d742 100644 +index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7eedb969c03 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java @@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid { @@ -3909,7 +3929,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af private final Map shapes = Maps.newIdentityHashMap(); public FlowingFluid() {} -@@ -252,6 +262,8 @@ public abstract class FlowingFluid extends Fluid { +@@ -251,6 +261,8 @@ public abstract class FlowingFluid extends Fluid { return false; } // Paper end - optimise collisions @@ -3918,7 +3938,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap; if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { -@@ -259,9 +271,16 @@ public abstract class FlowingFluid extends Fluid { +@@ -258,9 +270,16 @@ public abstract class FlowingFluid extends Fluid { } else { object2bytelinkedopenhashmap = null; } @@ -3935,7 +3955,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af if (object2bytelinkedopenhashmap != null) { block_a = new Block.BlockStatePairKey(state, fromState, face); byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a); -@@ -272,11 +291,22 @@ public abstract class FlowingFluid extends Fluid { +@@ -271,11 +290,22 @@ public abstract class FlowingFluid extends Fluid { } else { block_a = null; } @@ -3958,7 +3978,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..c55f51e6db55f9fa66f53eef0e7a56af if (object2bytelinkedopenhashmap != null) { if (object2bytelinkedopenhashmap.size() == 200) { object2bytelinkedopenhashmap.removeLastByte(); -@@ -284,6 +314,11 @@ public abstract class FlowingFluid extends Fluid { +@@ -283,6 +313,11 @@ public abstract class FlowingFluid extends Fluid { object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0)); } @@ -4074,7 +4094,7 @@ index ebe65474a4a05ff1637d7f37ebcfe690af59def5..42142c512b12e5b269c19f1e821c50e7 @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index e011cfcdda2e0a609d4158b0454bdf046b04c9d9..cfd5d98195cb07302c2f4d56c27b81e06448604a 100644 +index 34cd96dba5f11e64d7c90f4246b513b0ea943aa6..970b25f6064da694b076a08a8bbcc01e03d354d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1120,6 +1120,11 @@ public final class CraftServer implements Server { @@ -4088,7 +4108,7 @@ index e011cfcdda2e0a609d4158b0454bdf046b04c9d9..cfd5d98195cb07302c2f4d56c27b81e0 + } } } - // Paper end + // Paper end - Wait for Async Tasks during shutdown diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index 96d772eb02f79f8c478f5e6f065e387aa7665b18..c5ce412f321b8b4f31cc042893659e213b081f29 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -4151,7 +4171,7 @@ index e8e93538dfd71de86515d9405f728db1631e949a..3dff02fd97f001508e2f81192817bf1b // Paper start - try to shutdown on main server.safeShutdown(false, false); diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 59103744ac6beeb12719fdefcda54eeff498229e..c0333ba8e57cd284bb8ab15181da6b39d55872f9 100644 +index c39894e824334f1dc52e0466cf9d84f7e219be70..41cddf7e42f0e8f80973e482a95e55d3bd19f659 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings; @@ -4165,9 +4185,9 @@ index 59103744ac6beeb12719fdefcda54eeff498229e..c0333ba8e57cd284bb8ab15181da6b39 public class ActivationRange { -@@ -222,6 +226,25 @@ public class ActivationRange +@@ -221,6 +225,25 @@ public class ActivationRange } - // Paper end - configurable marker ticking + // Paper end - Configurable marker ticking ActivationRange.activateEntity(entity); + + // Pufferfish start @@ -4191,7 +4211,7 @@ index 59103744ac6beeb12719fdefcda54eeff498229e..c0333ba8e57cd284bb8ab15181da6b39 } // Paper end } -@@ -238,12 +261,12 @@ public class ActivationRange +@@ -237,12 +260,12 @@ public class ActivationRange if ( MinecraftServer.currentTick > entity.activatedTick ) { if ( entity.defaultActivationState ) @@ -4206,12 +4226,12 @@ index 59103744ac6beeb12719fdefcda54eeff498229e..c0333ba8e57cd284bb8ab15181da6b39 entity.activatedTick = MinecraftServer.currentTick; } } -@@ -297,7 +320,7 @@ public class ActivationRange +@@ -296,7 +319,7 @@ public class ActivationRange if ( entity instanceof LivingEntity ) { LivingEntity living = (LivingEntity) entity; -- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper -+ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper // Pufferfish - use cached +- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing()) // Paper ++ if ( living.onClimableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 || living.isFreezing() ) // Paper // Pufferfish - use cached { return 1; // Paper } diff --git a/patches/server/0002-purpur-Server-Changes-commit-fa3166a24d0dd49f41eb025.patch b/patches/server/0002-purpur-Server-Changes-commit-fa3166a24d0dd49f41eb025.patch index 50ca6457..c6dcc5cf 100644 --- a/patches/server/0002-purpur-Server-Changes-commit-fa3166a24d0dd49f41eb025.patch +++ b/patches/server/0002-purpur-Server-Changes-commit-fa3166a24d0dd49f41eb025.patch @@ -27,10 +27,10 @@ Squid EAR immunity Signs allow color codes diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index 14f4c0a93372a58cf36dc95265b5e210ea1605e5..ff27787313a3337e29eac6f623b08f1f333f293c 100644 +index f341813e9713e39bfe142ca34b751de3d8efd25b..b0d96ae08959cdca9177eb875faa99f4a8e92632 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java -@@ -322,6 +322,30 @@ public class CommandSourceStack implements ExecutionCommandSource bukkit, RootCommandNode rootcommandnode) { - // Paper end - Async command map building - new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper + // Paper end - Perf: Async command map building + new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API + if (PlayerCommandSendEvent.getHandlerList().getRegisteredListeners().length > 0) { // Purpur - skip all this crap if there's nothing listening PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); -@@ -526,6 +527,7 @@ public class Commands { +@@ -516,6 +517,7 @@ public class Commands { } } // CraftBukkit end @@ -82,42 +82,27 @@ index 55f3f5396dac2b0bb0cc37b537547e9245042100..471270f302cbfaf81500976fcc5a02ea } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index dc8f1de69bb056935d25ee2a050f260aa1ad913a..94e95672c3e725b186257b9efb79f5024c4f735f 100644 +index cefc05ddb198bff00924f038b39195a5b9ccb05d..e8b77389e8766baabbe6c4ccb1befd95c388fc03 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -307,6 +307,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor +@@ -217,6 +218,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.purpurConfig = new org.purpurmc.purpur.PurpurWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), env); // Purpur this.generator = gen; this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -index a3ec2f522be2d02b9e37810799cecc2ba14f58f3..2c914ffaa6a9c5edc8e0e6d68a4abf8ea8066ae1 100644 +index 979a8f472f866130a3abb10f535df757eaa50c20..b4af974854ba9dfd52f3d0c2eca984c01a9ab892 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java @@ -206,11 +206,18 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C @@ -330,7 +315,7 @@ index a3ec2f522be2d02b9e37810799cecc2ba14f58f3..2c914ffaa6a9c5edc8e0e6d68a4abf8e public CompoundTag getUpdateTag() { return this.saveWithoutMetadata(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index cfd5d98195cb07302c2f4d56c27b81e06448604a..d0bc077db961ff7b01b25742dbd83aa282cb3897 100644 +index 970b25f6064da694b076a08a8bbcc01e03d354d8..e4d07599c2301bdaecd0e42b4a99081c74f23d37 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1037,6 +1037,7 @@ public final class CraftServer implements Server { @@ -357,7 +342,7 @@ index cfd5d98195cb07302c2f4d56c27b81e06448604a..d0bc077db961ff7b01b25742dbd83aa2 this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -3016,6 +3019,18 @@ public final class CraftServer implements Server { +@@ -3001,6 +3004,18 @@ public final class CraftServer implements Server { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } @@ -376,7 +361,7 @@ index cfd5d98195cb07302c2f4d56c27b81e06448604a..d0bc077db961ff7b01b25742dbd83aa2 @Override public void restart() { org.spigotmc.RestartCommand.restart(); -@@ -3234,4 +3249,11 @@ public final class CraftServer implements Server { +@@ -3232,4 +3247,11 @@ public final class CraftServer implements Server { } // Paper end @@ -389,7 +374,7 @@ index cfd5d98195cb07302c2f4d56c27b81e06448604a..d0bc077db961ff7b01b25742dbd83aa2 + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index a74a8a027c99eef199c1a6a54232ac2c8ffb9d08..cce747b8a2d87d81429dfaf1e0073b1ea4b1a5d2 100644 +index ce341f42b3a5e17fb6d1f7de8057e73137ae2a6e..0c3be815e4f81b0d51273413e9d0fb1a7db3f03f 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -174,6 +174,14 @@ public class Main { @@ -417,7 +402,7 @@ index a74a8a027c99eef199c1a6a54232ac2c8ffb9d08..cce747b8a2d87d81429dfaf1e0073b1e Calendar deadline = Calendar.getInstance(); diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java -index 2677e21d8239bf0361a3bc5c9a50c328e54d70f6..544a79d5da661aff19e2019f7b83a3a49350bb68 100644 +index fde9aadd6c688b9797a6755f9d214918047598a0..ffaa80b645da3ddf2da828071090e01aa667504d 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -256,6 +256,7 @@ public final class CraftLegacy { @@ -425,15 +410,15 @@ index 2677e21d8239bf0361a3bc5c9a50c328e54d70f6..544a79d5da661aff19e2019f7b83a3a4 static { + if (!org.purpurmc.purpur.PurpurConfig.loggerSuppressInitLegacyMaterialError) // Purpur - LOGGER.warn("Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!"); // Paper - doesn't need to be an error + LOGGER.warn("Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!"); // Paper - Improve logging and errors; doesn't need to be an error if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) { new Exception().printStackTrace(); diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..3e992515348a6d5e1d86381dd3b72aa2a5e16313 +index 0000000000000000000000000000000000000000..98cc0b4bfe661879fd9b8f2eb7623e926ca82472 --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java -@@ -0,0 +1,201 @@ +@@ -0,0 +1,196 @@ +package org.purpurmc.purpur; + +import com.google.common.base.Throwables; @@ -629,11 +614,6 @@ index 0000000000000000000000000000000000000000..3e992515348a6d5e1d86381dd3b72aa2 + loggerSuppressUnrecognizedRecipeErrors = getBoolean("settings.logger.suppress-unrecognized-recipe-errors", loggerSuppressUnrecognizedRecipeErrors); + loggerSuppressSetBlockFarChunk = getBoolean("settings.logger.suppress-setblock-in-far-chunk-errors", loggerSuppressSetBlockFarChunk); + } -+ -+ public static boolean tpsCatchup = true; -+ private static void tpsCatchup() { -+ tpsCatchup = getBoolean("settings.tps-catchup", tpsCatchup); -+ } +} diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java new file mode 100644 @@ -818,7 +798,7 @@ index 0000000000000000000000000000000000000000..afdf04f8b22ad0b7c0b41675e44687b4 + } +} diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index c0333ba8e57cd284bb8ab15181da6b39d55872f9..c70b70f8d9ac7d4a0ce3e843bbfde945d5eb96fe 100644 +index 41cddf7e42f0e8f80973e482a95e55d3bd19f659..e32cf1babe969da9c6863312a1f69d5f2bb0c456 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -15,6 +15,7 @@ import net.minecraft.world.entity.ambient.AmbientCreature; @@ -829,7 +809,7 @@ index c0333ba8e57cd284bb8ab15181da6b39d55872f9..c70b70f8d9ac7d4a0ce3e843bbfde945 import net.minecraft.world.entity.animal.WaterAnimal; import net.minecraft.world.entity.animal.horse.Llama; import net.minecraft.world.entity.boss.EnderDragonPart; -@@ -401,6 +402,7 @@ public class ActivationRange +@@ -400,6 +401,7 @@ public class ActivationRange */ public static boolean checkIfActive(Entity entity) { diff --git a/patches/server/0003-EmpireCraft-Server-Changes-commit-e15007e4385c5852bf.patch b/patches/server/0003-EmpireCraft-Server-Changes-commit-e15007e4385c5852bf.patch index bbec4015..0aab177e 100644 --- a/patches/server/0003-EmpireCraft-Server-Changes-commit-e15007e4385c5852bf.patch +++ b/patches/server/0003-EmpireCraft-Server-Changes-commit-e15007e4385c5852bf.patch @@ -20,7 +20,7 @@ Don't trigger Lootable Refresh for non player interaction Do not process chat/commands before player has joined diff --git a/src/main/java/net/minecraft/server/commands/GiveCommand.java b/src/main/java/net/minecraft/server/commands/GiveCommand.java -index d601d287e94a59ff93b8a83a44dac02544d211df..ffa40e12d6750b982828cee38ccaeb14c7ab0ff5 100644 +index 1b459a8ee8a6bc039e742d65796bc76660a1c765..f459da26b77e8c10337730738ee878cba77501df 100644 --- a/src/main/java/net/minecraft/server/commands/GiveCommand.java +++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java @@ -59,6 +59,7 @@ public class GiveCommand { @@ -30,7 +30,7 @@ index d601d287e94a59ff93b8a83a44dac02544d211df..ffa40e12d6750b982828cee38ccaeb14 + if (true) { continue; } // EMC - never drop items if (flag && itemstack1.isEmpty()) { itemstack1.setCount(1); - entityitem = entityplayer.drop(itemstack1, false, false, false); // SPIGOT-2942: Add boolean to call event + entityitem = entityplayer.drop(itemstack1, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java index b2f08889139dc447f7071f1c81456035bf8de31e..4317aee5a31627e48e1f759e653b9db4b8f9b7e8 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java @@ -47,7 +47,7 @@ index b2f08889139dc447f7071f1c81456035bf8de31e..4317aee5a31627e48e1f759e653b9db4 + // EMC end } diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 1436fdbe31c8cdf05ac56f20224fe91de4b1c0c3..909bc540bfb7b8f638613c070ac97d1eb4faa882 100644 +index b41635dd0569ff7df909df492d3e850aef7214be..cac943ffca45def34ac4d88e3bb975cdf2c471b7 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java @@ -68,6 +68,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @@ -59,10 +59,10 @@ index 1436fdbe31c8cdf05ac56f20224fe91de4b1c0c3..909bc540bfb7b8f638613c070ac97d1e net.minecraft.world.level.Level level = this.getLevel(); BlockPos blockPos = this.getBlockPos(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index e1fad381b861471a17529c246bb8a4a9c7646420..1fad4e8ccd73946fa5b17caba644354df37e7459 100644 +index a139601888b88e8580bdb9c2469386a94abae975..9977403dcc823bd8e637a47e1d01fdb474e787e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -416,7 +416,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -415,7 +415,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean unloadChunk(int x, int z) { diff --git a/patches/server/0004-Build-changes.patch b/patches/server/0004-Build-changes.patch index 1c6e4b28..e895e32a 100644 --- a/patches/server/0004-Build-changes.patch +++ b/patches/server/0004-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/build.gradle.kts b/build.gradle.kts -index d06e2ac3eb0d218f9982ab3ecc02e35528ea38f9..07894e375b73f03526e0676486cc76b7a58ccd07 100644 +index 368eddbcf2fbda9c2060e1a8d17f7d8474b16c73..a27a2134d5b361f5408dc402cb5265267711f46f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,8 +13,8 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { @@ -20,20 +20,20 @@ index d06e2ac3eb0d218f9982ab3ecc02e35528ea38f9..07894e375b73f03526e0676486cc76b7 implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 94e95672c3e725b186257b9efb79f5024c4f735f..a54df2303847ffd34c68af7fded34412f52268a6 100644 +index e8b77389e8766baabbe6c4ccb1befd95c388fc03..08d94ef45a9663f032551ac1781947203000fcd9 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1876,7 +1876,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop // Spigot - Spigot > // CraftBukkit - cb > vanilla! -+ return "Patina"; // Patina - Patina > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! +- return "Paper"; // Paper ++ return "Patina"; // Patina } public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index d0bc077db961ff7b01b25742dbd83aa282cb3897..297e8779a0743662a86869f66c64db266473d97b 100644 +index e4d07599c2301bdaecd0e42b4a99081c74f23d37..1d3605d429134afd98ea623ac89b6d4c4b14892a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper diff --git a/patches/server/0005-Akarin-Swaps-the-predicate-order-of-collision.patch b/patches/server/0005-Akarin-Swaps-the-predicate-order-of-collision.patch index 5d783166..38963e1d 100644 --- a/patches/server/0005-Akarin-Swaps-the-predicate-order-of-collision.patch +++ b/patches/server/0005-Akarin-Swaps-the-predicate-order-of-collision.patch @@ -5,20 +5,20 @@ Subject: [PATCH] (Akarin) Swaps the predicate order of collision diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index b8810cce6f4995d78dca3691b0a1cbd133a05e06..de1605c99e68bf82ab6e6dc1338d785571d7d9c9 100644 +index 1d9331fe9ce7308eda2e7da2ae726810d455f090..103dad253aa96665aeb22073bdaefa74332d7cd5 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2118,8 +2118,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2121,8 +2121,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public void playerTouch(Player player) {} public void push(Entity entity) { - if (!this.isPassengerOfSameVehicle(entity)) { - if (!entity.noPhysics && !this.noPhysics) { + if (!entity.noPhysics && !this.noPhysics && !this.isPassengerOfSameVehicle(entity)) { // Patina - (Akarin) Swaps the predicate order of collision - if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper + if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - Collision option for requiring a player participant double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); -@@ -2147,8 +2146,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2150,8 +2149,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S entity.push(d0, 0.0D, d1); } } diff --git a/patches/server/0006-add-Purpur-to-timings-report.patch b/patches/server/0006-add-Purpur-to-timings-report.patch index 8d6e6a83..2eae7327 100644 --- a/patches/server/0006-add-Purpur-to-timings-report.patch +++ b/patches/server/0006-add-Purpur-to-timings-report.patch @@ -5,10 +5,10 @@ Subject: [PATCH] add Purpur to timings report diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java -index 5af15c85fab72034b97ac210ff775e0a8fa0be78..a4e4e72d873830a41afe589dede7fa155a4f2f1d 100644 +index b35a9f4c5f8960864c402ede8a51fb5ab9c4fcc0..7d3100afd7b24e91fdac4452168c3fec52fd022d 100644 --- a/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java -@@ -244,6 +244,7 @@ public class TimingsExport extends Thread { +@@ -242,6 +242,7 @@ public class TimingsExport extends Thread { pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), // Pufferfish pair("pufferfish", mapAsJSON(gg.pufferfish.pufferfish.PufferfishConfig.getConfigCopy(), null)) // Pufferfish diff --git a/patches/server/0010-relocate.patch b/patches/server/0010-relocate.patch index 31c2ad96..850d0aab 100644 --- a/patches/server/0010-relocate.patch +++ b/patches/server/0010-relocate.patch @@ -5,10 +5,10 @@ Subject: [PATCH] relocate diff --git a/build.gradle.kts b/build.gradle.kts -index 5ecd6cf4d6f177781b1be5bf046c4a78b82efc43..8b80a5a54922b1b2c110cd66aef4105469e20d2b 100644 +index a27a2134d5b361f5408dc402cb5265267711f46f..4cb116c3b2b353fe580cec29fb69b476c18d96f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -123,6 +123,8 @@ relocation { +@@ -122,6 +122,8 @@ relocation { relocate("org.bukkit.craftbukkit" to "org.bukkit.craftbukkit.v$craftbukkitPackageVersion") { exclude("org.bukkit.craftbukkit.Main*") } diff --git a/patches/server/0012-fix-building-issue.patch b/patches/server/0012-fix-building-issue.patch index 4551b14a..0c82a85b 100644 --- a/patches/server/0012-fix-building-issue.patch +++ b/patches/server/0012-fix-building-issue.patch @@ -5,10 +5,10 @@ Subject: [PATCH] fix building issue diff --git a/build.gradle.kts b/build.gradle.kts -index 381e1d611a663329cc7c7f446826f6a106d471e5..76804d663d7f42c6affe03c0c6cd9b0f66bd9b0c 100644 +index 4cb116c3b2b353fe580cec29fb69b476c18d96f1..71477aee902a90765d2417667c70d17d985304f2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -53,7 +53,7 @@ dependencies { +@@ -52,7 +52,7 @@ dependencies { // Pufferfish start implementation("org.yaml:snakeyaml:1.32") diff --git a/patches/server/0014-lithium-HashedList.patch b/patches/server/0014-lithium-HashedList.patch index 274ce1b6..092e6b55 100644 --- a/patches/server/0014-lithium-HashedList.patch +++ b/patches/server/0014-lithium-HashedList.patch @@ -293,15 +293,15 @@ index 0000000000000000000000000000000000000000..2d79932dbd1fc386a94b8d6ea3526934 + } +} diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index b2b804e1763c1af6c6384364c205ff9fa440a014..0110a7fcaa2802dba5f0d11047adc4d86b60050e 100644 +index b34ec447a95e852fcc2cc3e8e2a890ddc8e5ff47..888913eff1a62b7f3b689ba64ce5630a20737897 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -120,9 +120,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public static final int TICKS_PER_DAY = 24000; public static final int MAX_ENTITY_SPAWN_Y = 20000000; public static final int MIN_ENTITY_SPAWN_Y = -20000000; -- protected final List blockEntityTickers = Lists.newArrayList(); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper -+ protected final List blockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper // Jettpack - lithium: hashed_list +- public final List blockEntityTickers = Lists.newArrayList(); // Paper - public ++ public final List blockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Paper - public // Jettpack - lithium: hashed_list protected final NeighborUpdater neighborUpdater; - private final List pendingBlockEntityTickers = Lists.newArrayList(); + private final List pendingBlockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Jettpack - lithium: hashed_list diff --git a/patches/server/0015-lithium-cached_hashcode.patch b/patches/server/0015-lithium-cached_hashcode.patch index 562bfc06..54add35c 100644 --- a/patches/server/0015-lithium-cached_hashcode.patch +++ b/patches/server/0015-lithium-cached_hashcode.patch @@ -6,10 +6,10 @@ Subject: [PATCH] lithium: cached_hashcode Original code licensed under GNU Lesser General Public License v3.0 and created for the lithium project: https://github.com/CaffeineMC/lithium-fabric/ diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 4d50dd92a7f3187ee1d8edb926e7c273c8156549..e0bdb86602465061792cdc11b6b5c3808afd6c00 100644 +index 73d6f881a7d4d8ff96040d34ac502e5b0937d577..2653798bc5454dccf97e73c39514394eb2c3f1c8 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -606,11 +606,18 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -614,11 +614,18 @@ public class Block extends BlockBehaviour implements ItemLike { private final BlockState first; private final BlockState second; private final Direction direction; @@ -28,7 +28,7 @@ index 4d50dd92a7f3187ee1d8edb926e7c273c8156549..e0bdb86602465061792cdc11b6b5c380 } public boolean equals(Object object) { -@@ -626,11 +633,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -634,11 +641,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public int hashCode() { diff --git a/patches/server/0017-rebrand-implementation-version.patch b/patches/server/0017-rebrand-implementation-version.patch index f5e45c6c..ed23b2e5 100644 --- a/patches/server/0017-rebrand-implementation-version.patch +++ b/patches/server/0017-rebrand-implementation-version.patch @@ -5,10 +5,10 @@ Subject: [PATCH] rebrand implementation version diff --git a/build.gradle.kts b/build.gradle.kts -index 1ce25e619450bfd192a5136da740231acfc500ae..dfd8ea5314e7819b5f198034a1550266d0a8a081 100644 +index 71477aee902a90765d2417667c70d17d985304f2..57beb8a1c12e4935c37363bf62bd7ed6f45e829a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -86,7 +86,7 @@ tasks.jar { +@@ -85,7 +85,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", diff --git a/patches/server/0018-Akarin-Save-Json-list-asynchronously.patch b/patches/server/0018-Akarin-Save-Json-list-asynchronously.patch index 1d4b3ee0..1dda3910 100644 --- a/patches/server/0018-Akarin-Save-Json-list-asynchronously.patch +++ b/patches/server/0018-Akarin-Save-Json-list-asynchronously.patch @@ -9,7 +9,7 @@ Original project: https://github.com/Akarin-project/Akarin Original project: https://github.com/Winds-Studio/Leaf diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index 665120a62525f56912263a3e1b6f12f6c3e15dec..96f43abadbfb96834945166a25a286564f6273b8 100644 +index 35f973cc2c0989256fa21abaf0327c2f36dbe4c9..e9fd7ef5365c051686896a2f986b02dfd110f2b3 100644 --- a/src/main/java/net/minecraft/server/players/StoredUserList.java +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java @@ -23,6 +23,7 @@ import java.util.Objects; @@ -20,7 +20,7 @@ index 665120a62525f56912263a3e1b6f12f6c3e15dec..96f43abadbfb96834945166a25a28656 import net.minecraft.util.GsonHelper; import org.slf4j.Logger; -@@ -126,37 +127,43 @@ public abstract class StoredUserList> { +@@ -103,37 +104,43 @@ public abstract class StoredUserList> { } public void save() throws IOException { diff --git a/patches/server/0019-lithium-entity.fast_hand_swing.patch b/patches/server/0019-lithium-entity.fast_hand_swing.patch index 4860e1d2..bda2a96a0 100644 --- a/patches/server/0019-lithium-entity.fast_hand_swing.patch +++ b/patches/server/0019-lithium-entity.fast_hand_swing.patch @@ -6,10 +6,10 @@ Subject: [PATCH] lithium: entity.fast_hand_swing Original code licensed under GNU Lesser General Public License v3.0 and created for the lithium project: https://github.com/CaffeineMC/lithium-fabric/ diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index e24e20a63b74e82afb7f911d286b9bdf72d87afb..f257b875549714f5361d92c26a1fd194b8d0eb06 100644 +index 5641bc7f50cef7819ddaeb76a4a4f9c80f473d31..b649cc058d345162127735d291902f9015d5242a 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2537,6 +2537,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2538,6 +2538,7 @@ public abstract class LivingEntity extends Entity implements Attackable { } protected void updateSwingTime() { diff --git a/patches/server/0020-fix-rebuild-issue-temporarily.patch b/patches/server/0020-fix-rebuild-issue-temporarily.patch index 06999ae2..e59c0f5c 100644 --- a/patches/server/0020-fix-rebuild-issue-temporarily.patch +++ b/patches/server/0020-fix-rebuild-issue-temporarily.patch @@ -5,10 +5,10 @@ Subject: [PATCH] fix rebuild issue (temporarily) diff --git a/build.gradle.kts b/build.gradle.kts -index dfd8ea5314e7819b5f198034a1550266d0a8a081..2621ee359c6cbe0db10abcd6c14d0e910c87304f 100644 +index 57beb8a1c12e4935c37363bf62bd7ed6f45e829a..d87904ebc02dbc817d61224ead776b8cfedf2829 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -228,7 +228,5 @@ val runtimeClasspathForRunDev = sourceSets.main.flatMap { src -> +@@ -227,7 +227,5 @@ val runtimeClasspathForRunDev = sourceSets.main.flatMap { src -> } tasks.registerRunTask("runDev") { description = "Spin up a non-relocated Mojang-mapped test server"