From 6ae5474b7eb132d8aa9c4f46920d89413668d9b0 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sat, 25 May 2024 20:02:06 +0800 Subject: [PATCH] Fix build --- patches/api/0009-KeYi-Player-Skull-API.patch | 4 +- ...006-Pufferfish-Optimize-mob-spawning.patch | 12 +- ...fferfish-Dynamic-Activation-of-Brain.patch | 18 +- ...tle-goal-selector-during-inactive-ti.patch | 4 +- .../server/0010-Purpur-Server-Changes.patch | 10 +- ...-Purpur-Configurable-server-mod-name.patch | 8 +- .../0012-Configurable-server-GUI-name.patch | 10 +- .../0015-Remove-Mojang-username-check.patch | 6 +- ...eck-for-Broken-BungeeCord-Configurat.patch | 4 +- ...Remove-UseItemOnPacket-Too-Far-Check.patch | 4 +- .../server/0019-KeYi-Player-Skull-API.patch | 6 +- ...on-for-spigot-item-merging-mechanism.patch | 4 +- .../server/0029-Leaves-Jade-Protocol.patch | 44 ++- .../0030-Leaves-Appleskin-Protocol.patch | 27 +- .../0031-Leaves-Xaero-Map-Protocol.patch | 30 +- ...aves-Disable-moved-wrongly-threshold.patch | 29 +- ...ndom-for-xaeroMapServerID-generation.patch | 319 ++---------------- .../server/0039-Petal-Async-Pathfinding.patch | 68 ++-- ...educe-work-done-by-game-event-system.patch | 8 +- .../0046-Configurable-fix-tripwire-dupe.patch | 11 +- .../0049-Configurable-bamboo-collision.patch | 59 ++-- 21 files changed, 229 insertions(+), 456 deletions(-) diff --git a/patches/api/0009-KeYi-Player-Skull-API.patch b/patches/api/0009-KeYi-Player-Skull-API.patch index 1780ff4d3..053415347 100644 --- a/patches/api/0009-KeYi-Player-Skull-API.patch +++ b/patches/api/0009-KeYi-Player-Skull-API.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 877ed7bea937e0be1c404d5ab5cef8fce5e6ac17..46d8d8e11448613de3caa0a54613c8d028673ad0 100644 +index 877ed7bea937e0be1c404d5ab5cef8fce5e6ac17..5c03666a54daaeac87332f0e075361b14fb575b9 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -3424,4 +3424,22 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @@ -30,6 +30,6 @@ index 877ed7bea937e0be1c404d5ab5cef8fce5e6ac17..46d8d8e11448613de3caa0a54613c8d0 + * + * @return A CompletableFuture of the skull ItemStack of the player + */ -+ CompletableFuture getSkullAsynchronously(); ++ java.util.concurrent.CompletableFuture getSkullAsynchronously(); + // Leaf end - KeYi } diff --git a/patches/server/0006-Pufferfish-Optimize-mob-spawning.patch b/patches/server/0006-Pufferfish-Optimize-mob-spawning.patch index d85b4a3db..7b57f3132 100644 --- a/patches/server/0006-Pufferfish-Optimize-mob-spawning.patch +++ b/patches/server/0006-Pufferfish-Optimize-mob-spawning.patch @@ -32,14 +32,14 @@ index 3bee751a36c1aaab9b9a738edac80b4d2853bdd7..31b1b1c6a55b04cf1952ddb8ea08da98 AtomicReference atomicreference = new AtomicReference(); Thread thread = new io.papermc.paper.util.TickThread(() -> { // Paper - rewrite chunk system diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 73a492e629677b045914cf41b826ee1acb4497b7..6fa06ba5140ab135a5cfe8d6bde9ef6514ca69fa 100644 +index 73a492e629677b045914cf41b826ee1acb4497b7..130406970b6c35f224ecbe03bd375d318780fb67 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -349,6 +349,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface DedicatedServer.LOGGER.info("JMX monitoring enabled"); } -+ if (org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning) mobSpawnExecutor.start(); // Pufferfish ++ if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) mobSpawnExecutor.start(); // Pufferfish return true; } } @@ -57,7 +57,7 @@ index 9feda080c522e3374024eabe4f9eebe9b16b701f..d9828fd85d39116867bdb7e4fbe899ba this.playerEntityTrackerTrackMaps = new com.destroystokyo.paper.util.misc.PlayerAreaMap[TRACKING_RANGE_TYPES.length]; this.entityTrackerTrackRanges = new int[TRACKING_RANGE_TYPES.length]; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 075c476cdf02ece97c5e0032726ae1b560825ce1..cb7f88e37b6bd3a0a78f80ef6062e65818ab180c 100644 +index 075c476cdf02ece97c5e0032726ae1b560825ce1..865be5b73846f680cfc4a06b676fefc4236c9e9a 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -75,6 +75,9 @@ public class ServerChunkCache extends ChunkSource { @@ -75,7 +75,7 @@ index 075c476cdf02ece97c5e0032726ae1b560825ce1..cb7f88e37b6bd3a0a78f80ef6062e658 // Paper start - per player mob spawning if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't count mobs when animals and monsters are disabled + // Pufferfish start - moved down when async processing -+ if (!org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning) { ++ if (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) { // re-set mob counts for (ServerPlayer player : this.level.players) { // Paper start - per player mob spawning backoff @@ -108,7 +108,7 @@ index 075c476cdf02ece97c5e0032726ae1b560825ce1..cb7f88e37b6bd3a0a78f80ef6062e658 chunk1.incrementInhabitedTime(j); - if (flag2AndHasNaturalSpawn && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration // Gale - MultiPaper - skip unnecessary mob spawning computations - NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); -+ if (flag2AndHasNaturalSpawn && (!org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning || _pufferfish_spawnCountsReady.get()) && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration // Gale - MultiPaper - skip unnecessary mob spawning computations ++ if (flag2AndHasNaturalSpawn && (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled || _pufferfish_spawnCountsReady.get()) && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration // Gale - MultiPaper - skip unnecessary mob spawning computations + NaturalSpawner.spawnForChunk(this.level, chunk1, lastSpawnState, this.spawnFriendlies, this.spawnEnemies, flag1); // Pufferfish } @@ -118,7 +118,7 @@ index 075c476cdf02ece97c5e0032726ae1b560825ce1..cb7f88e37b6bd3a0a78f80ef6062e658 // Paper end - controlled flush for entity tracker packets } + // Pufferfish start - optimize mob spawning -+ if (org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning) { ++ if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) { + for (ServerPlayer player : this.level.players) { + // Paper start - per player mob spawning backoff + for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) { diff --git a/patches/server/0007-Pufferfish-Dynamic-Activation-of-Brain.patch b/patches/server/0007-Pufferfish-Dynamic-Activation-of-Brain.patch index 3dfce47b8..ce9700624 100644 --- a/patches/server/0007-Pufferfish-Dynamic-Activation-of-Brain.patch +++ b/patches/server/0007-Pufferfish-Dynamic-Activation-of-Brain.patch @@ -42,7 +42,7 @@ index 1462f9d4f2cdf4071fb002d602783866a5a3d285..5d6c0f5d2d993ae3a044a1a02716a266 if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed entity.discard(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 5872824b58d65208f21379ebd4fca918da323c32..edfb51e5c54d443926d0c051a3732a97dcecbd00 100644 +index 5872824b58d65208f21379ebd4fca918da323c32..d7da045d1811247be6e89c438dff7ccad0299900 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -436,6 +436,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @@ -51,7 +51,7 @@ index 5872824b58d65208f21379ebd4fca918da323c32..edfb51e5c54d443926d0c051a3732a97 + // Pufferfish start + public boolean activatedPriorityReset = false; // DAB -+ public int activatedPriority = org.dreeam.leaf.LeafConfig.maximumActivationPrio; // golf score ++ public int activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio; // golf score + // Pufferfish end + public float getBukkitYaw() { @@ -119,7 +119,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 86fc528551c2c90c78783d4d46a4a2c52e4efe41..034dfd1a62f97ffa4ca2c466fea609cee18d4798 100644 +index 86fc528551c2c90c78783d4d46a4a2c52e4efe41..5cf651eec6665d06806ebc5ed1f893795e4c637d 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 @@ -51,9 +51,12 @@ public class GoalSelector { @@ -128,7 +128,7 @@ index 86fc528551c2c90c78783d4d46a4a2c52e4efe41..034dfd1a62f97ffa4ca2c466fea609ce // Paper start - public boolean inactiveTick() { + public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start -+ if (inactive && !org.dreeam.leaf.LeafConfig.dabEnabled) tickRate = 4; // reset to Paper's ++ if (inactive && !org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.enabled) tickRate = 4; // reset to Paper's + tickRate = Math.min(tickRate, this.newGoalRate); this.curRate++; - return this.curRate % this.newGoalRate == 0; @@ -361,7 +361,7 @@ index 0000000000000000000000000000000000000000..2769eba9841ec866265e814e16f930a5 + } +} diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index aa68ff1abced10ad03957c9c0ac24beaf112adcf..7d2b6657b0dbf5f899446d674dfc01b326fbc9c3 100644 +index aa68ff1abced10ad03957c9c0ac24beaf112adcf..6b97b741ed8ff39bbb8d6e2aa6bf8090685227a7 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -40,6 +40,9 @@ import net.minecraft.world.level.Level; @@ -380,17 +380,17 @@ index aa68ff1abced10ad03957c9c0ac24beaf112adcf..7d2b6657b0dbf5f899446d674dfc01b3 ActivationRange.activateEntity(entity); + + // Pufferfish start -+ if (org.dreeam.leaf.LeafConfig.dabEnabled && entity.getType().dabEnabled) { ++ if (org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.enabled && entity.getType().dabEnabled) { + if (!entity.activatedPriorityReset) { + entity.activatedPriorityReset = true; -+ entity.activatedPriority = org.dreeam.leaf.LeafConfig.maximumActivationPrio; ++ entity.activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio; + } + Vec3 playerVec = player.position(); + Vec3 entityVec = entity.position(); + double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z; + int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ); -+ entity.activatedPriority = squaredDistance > org.dreeam.leaf.LeafConfig.startDistanceSquared ? -+ Math.max(1, Math.min(squaredDistance >> org.dreeam.leaf.LeafConfig.activationDistanceMod, entity.activatedPriority)) : ++ entity.activatedPriority = squaredDistance > org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.startDistanceSquared ? ++ Math.max(1, Math.min(squaredDistance >> org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.activationDistanceMod, entity.activatedPriority)) : + 1; + } else { + entity.activatedPriority = 1; diff --git a/patches/server/0008-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch b/patches/server/0008-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch index 2432d5a4c..817ae9e23 100644 --- a/patches/server/0008-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch +++ b/patches/server/0008-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch @@ -7,7 +7,7 @@ Original license: GPL v3 Original project: https://github.com/pufferfish-gg/Pufferfish diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 8bd04d423a444c9b66a1ff787906eb7879721459..92a92c0f4a6bcecfecacd8e4a4ab8658124d9418 100644 +index 8bd04d423a444c9b66a1ff787906eb7879721459..065d0d8d535e3674ea090e1c0cb007892cbda698 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -220,11 +220,13 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -20,7 +20,7 @@ index 8bd04d423a444c9b66a1ff787906eb7879721459..92a92c0f4a6bcecfecacd8e4a4ab8658 public void inactiveTick() { super.inactiveTick(); - if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity -+ boolean isThrottled = org.dreeam.leaf.LeafConfig.throttleInactiveGoalSelectorTick && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking ++ boolean isThrottled = org.dreeam.leaf.config.modules.opt.ThrottleInactiveGoalSelectorTick.enabled && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking + if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking this.goalSelector.tick(); } diff --git a/patches/server/0010-Purpur-Server-Changes.patch b/patches/server/0010-Purpur-Server-Changes.patch index cf76734a0..01598c0b4 100644 --- a/patches/server/0010-Purpur-Server-Changes.patch +++ b/patches/server/0010-Purpur-Server-Changes.patch @@ -789,7 +789,7 @@ index d601d287e94a59ff93b8a83a44dac02544d211df..0ff3b06a98b2f4514b2d861b92dd70fe itemstack1.setCount(1); entityitem = entityplayer.drop(itemstack1, false, false, false); // SPIGOT-2942: Add boolean to call event diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 6fa06ba5140ab135a5cfe8d6bde9ef6514ca69fa..3dbbac8128e984baff14a41379f4665a585bf877 100644 +index 130406970b6c35f224ecbe03bd375d318780fb67..b195881c2a4ee7cfc27ed69ee88dee66c63ad093 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -98,6 +98,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -850,7 +850,7 @@ index 6fa06ba5140ab135a5cfe8d6bde9ef6514ca69fa..3dbbac8128e984baff14a41379f4665a @@ -350,6 +384,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } - if (org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning) mobSpawnExecutor.start(); // Pufferfish + if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) mobSpawnExecutor.start(); // Pufferfish + org.purpurmc.purpur.task.BossBarTask.startAll(); // Purpur + if (org.purpurmc.purpur.PurpurConfig.beeCountPayload) org.purpurmc.purpur.task.BeehiveTask.instance().register(); // Purpur return true; @@ -2341,7 +2341,7 @@ index 14fab63346d56c72cd7534a04760efd10eef4295..745e792482f61c571e2efbd4200dd1bd @Override diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 31d248b0a3ec735edff3aeb5e00fd009940013da..9038588608baec2e02c88a727662c903adcf5da6 100644 +index 31eb4fa683e473de2ad16746c23b625c5d9509e3..d785c7765e3d0e786f692524e994b49206557d6c 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -156,7 +156,7 @@ import org.bukkit.plugin.PluginManager; @@ -3160,7 +3160,7 @@ index 75a06dec69ee79af5b321388b104bf1cb6acf83c..bef1b8cb3664d499fe45e6d60fe131a0 }); } diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 92a92c0f4a6bcecfecacd8e4a4ab8658124d9418..455a0a96ac6aa6106e9011cd41be228b5a880fe5 100644 +index 065d0d8d535e3674ea090e1c0cb007892cbda698..79c67810af9a1ace6ac98f54188f15dc18883e9b 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -65,6 +65,7 @@ import net.minecraft.world.item.ProjectileWeaponItem; @@ -24839,7 +24839,7 @@ index 0000000000000000000000000000000000000000..b7586f494528f30eb0da82420d3bcf5b + } +} diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 7d2b6657b0dbf5f899446d674dfc01b326fbc9c3..c89a95801439bb0ab570bc33ded3f270451de9f2 100644 +index 6b97b741ed8ff39bbb8d6e2aa6bf8090685227a7..22481b9cc4fc124b41c9448a2985e28a8bfaa403 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; diff --git a/patches/server/0011-Purpur-Configurable-server-mod-name.patch b/patches/server/0011-Purpur-Configurable-server-mod-name.patch index 0c5f90b61..2ba121479 100644 --- a/patches/server/0011-Purpur-Configurable-server-mod-name.patch +++ b/patches/server/0011-Purpur-Configurable-server-mod-name.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Purpur: Configurable server mod name diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3328eb0715dab1786a677029bf6356d9118059b9..d9d92e74b101b2a4276b419ad9dcbdc361cb6860 100644 +index 3328eb0715dab1786a677029bf6356d9118059b9..c11419ab16105606ef13b573041b159e94d95ce6 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1683,7 +1683,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! -+ return org.dreeam.leaf.LeafConfig.serverModName; // Leaf - Leaf > // Purpur - Purpur > // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! ++ return org.dreeam.leaf.config.modules.misc.ServerBrand.serverModName; // Leaf - Leaf > // Purpur - Purpur > // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! } public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java b/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java new file mode 100644 -index 0000000000000000000000000000000000000000..7f7fe2930b2e26dd9ef4ceb0a22b005a8cc477b6 +index 0000000000000000000000000000000000000000..eb7b7b7d2d51173ce1297d618a586d4d686f8041 --- /dev/null +++ b/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java @@ -0,0 +1,21 @@ @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..7f7fe2930b2e26dd9ef4ceb0a22b005a + } + + @ConfigInfo(baseName = "server-mod-name") -+ public static String serverModName = io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); ++ public static String serverModName = "Leaf"; +} diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java index 8299aab5c29c8c6d996087537d9522b653b03ffa..d9591194268d44c73d081be574cd6060b16bad1f 100644 diff --git a/patches/server/0012-Configurable-server-GUI-name.patch b/patches/server/0012-Configurable-server-GUI-name.patch index 81837e4bf..9ae781f7b 100644 --- a/patches/server/0012-Configurable-server-GUI-name.patch +++ b/patches/server/0012-Configurable-server-GUI-name.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable server GUI name diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java -index be7b3fe2dc84493dcde9e185717b0b7c7c2e9822..a1dc1924039b7d51dc2915cefda02d0ba5d0e439 100644 +index be7b3fe2dc84493dcde9e185717b0b7c7c2e9822..bdaf77f68e1fa05b412c0412cdc81cdcf43d4891 100644 --- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java +++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java @@ -56,7 +56,7 @@ public class MinecraftServerGui extends JComponent { @@ -13,7 +13,7 @@ index be7b3fe2dc84493dcde9e185717b0b7c7c2e9822..a1dc1924039b7d51dc2915cefda02d0b } - final JFrame jframe = new JFrame("Purpur Minecraft server"); // Purpur -+ final JFrame jframe = new JFrame(org.dreeam.leaf.LeafConfig.serverGUIName); // Purpur // Leaf - Configurable server GUI name ++ final JFrame jframe = new JFrame(org.dreeam.leaf.config.modules.misc.ServerBrand.serverGUIName); // Purpur // Leaf - Configurable server GUI name final MinecraftServerGui servergui = new MinecraftServerGui(server); jframe.setDefaultCloseOperation(2); @@ -22,7 +22,7 @@ index be7b3fe2dc84493dcde9e185717b0b7c7c2e9822..a1dc1924039b7d51dc2915cefda02d0b jframe.setLocationRelativeTo((Component) null); jframe.setVisible(true); - jframe.setName("Purpur Minecraft server"); // Paper // Purpur -+ jframe.setName(org.dreeam.leaf.LeafConfig.serverGUIName); // Paper // Purpur // Leaf - Configurable server GUI name ++ jframe.setName(org.dreeam.leaf.config.modules.misc.ServerBrand.serverGUIName); // Paper // Purpur // Leaf - Configurable server GUI name // Paper start - Add logo as frame image try { @@ -36,13 +36,13 @@ index be7b3fe2dc84493dcde9e185717b0b7c7c2e9822..a1dc1924039b7d51dc2915cefda02d0b servergui.runFinalizers(); } diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java b/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java -index 7f7fe2930b2e26dd9ef4ceb0a22b005a8cc477b6..5c608079850c5483943669a98e2ba7e0d5a03b23 100644 +index eb7b7b7d2d51173ce1297d618a586d4d686f8041..1e2afef02409dbcb26171b2cbbe905b7e6e80698 100644 --- a/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java +++ b/src/main/java/org/dreeam/leaf/config/modules/misc/ServerBrand.java @@ -18,4 +18,7 @@ public class ServerBrand implements IConfigModule { @ConfigInfo(baseName = "server-mod-name") - public static String serverModName = io.papermc.paper.ServerBuildInfo.buildInfo().brandName(); + public static String serverModName = "Leaf"; + + @ConfigInfo(baseName = "server-gui-name") + public static String serverGUIName = "Leaf Console"; diff --git a/patches/server/0015-Remove-Mojang-username-check.patch b/patches/server/0015-Remove-Mojang-username-check.patch index 455223705..8d2997376 100644 --- a/patches/server/0015-Remove-Mojang-username-check.patch +++ b/patches/server/0015-Remove-Mojang-username-check.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove Mojang username check diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index badb262810effd22ca1ba021a1e746a777a19cbc..9baf55e9c3259aed431022a50c12d4f215c3ed80 100644 +index badb262810effd22ca1ba021a1e746a777a19cbc..7a79c9ffecda0fc1644d1dc85ea9c352aff67fdc 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -253,10 +253,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -13,11 +13,11 @@ index badb262810effd22ca1ba021a1e746a777a19cbc..9baf55e9c3259aed431022a50c12d4f2 // Gale start - JettPack - reduce array allocations Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", ArrayConstants.emptyObjectArray); - Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", ArrayConstants.emptyObjectArray); -+ if (!org.dreeam.leaf.LeafConfig.removeMojangUsernameCheck) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", ArrayConstants.emptyObjectArray); // Leaf - Remove Mojang's username check ++ if (!org.dreeam.leaf.config.modules.misc.RemoveVanillaUsernameCheck.enabled) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", ArrayConstants.emptyObjectArray); // Leaf - Remove Mojang's username check // Gale end - JettPack - reduce array allocations // Paper start - validate usernames - if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) { -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !org.dreeam.leaf.LeafConfig.removeMojangUsernameCheck) { // Leaf - Remove Mojang's username check ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation && !org.dreeam.leaf.config.modules.misc.RemoveVanillaUsernameCheck.enabled) { // Leaf - Remove Mojang's username check if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) { ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!"); return; diff --git a/patches/server/0016-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch b/patches/server/0016-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch index 42d13dde3..668e9203c 100644 --- a/patches/server/0016-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch +++ b/patches/server/0016-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove Spigot Check for Broken BungeeCord Configurations diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index 2821de09a36fc315897129f4691ba713386737db..5468b2fe5d0dd3e2b0ef774dff57e42e99baaece 100644 +index 2821de09a36fc315897129f4691ba713386737db..00e1792725e1737d93deef7468bede7d4eb06abc 100644 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -136,7 +136,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL @@ -13,7 +13,7 @@ index 2821de09a36fc315897129f4691ba713386737db..5468b2fe5d0dd3e2b0ef774dff57e42e connection.spoofedProfile = ServerHandshakePacketListenerImpl.gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class); } - } else if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { -+ } else if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) && !(org.dreeam.leaf.LeafConfig.removeSpigotCheckBungeeConfig)) { // Leaf - Remove Spigot check for broken BungeeCord configurations ++ } else if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) && !(org.dreeam.leaf.config.modules.misc.RemoveSpigotCheckBungee.enabled)) { // Leaf - Remove Spigot check for broken BungeeCord configurations Component chatmessage = Component.literal("Unknown data in login hostname, did you forget to enable BungeeCord in spigot.yml?"); this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); this.connection.disconnect(chatmessage); diff --git a/patches/server/0017-Remove-UseItemOnPacket-Too-Far-Check.patch b/patches/server/0017-Remove-UseItemOnPacket-Too-Far-Check.patch index 923d3c0a2..5914cfb09 100644 --- a/patches/server/0017-Remove-UseItemOnPacket-Too-Far-Check.patch +++ b/patches/server/0017-Remove-UseItemOnPacket-Too-Far-Check.patch @@ -7,7 +7,7 @@ This Check is added in 1.17.x -> 1.18.x update by Mojang. By removing this check, it enable hackers to use some modules of hack clients. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 89d40b2e1fbd0f0de03b90922c71e33db9efd3ae..c373f084d846e12faa42455c76f580b67b634717 100644 +index 89d40b2e1fbd0f0de03b90922c71e33db9efd3ae..29aeb034134adbe64551fb573c42a484bfbddf27 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2101,7 +2101,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @@ -15,7 +15,7 @@ index 89d40b2e1fbd0f0de03b90922c71e33db9efd3ae..c373f084d846e12faa42455c76f580b6 double d0 = 1.0000001D; - if (Math.abs(vec3d2.x()) < 1.0000001D && Math.abs(vec3d2.y()) < 1.0000001D && Math.abs(vec3d2.z()) < 1.0000001D) { -+ if ((Math.abs(vec3d2.x()) < org.dreeam.leaf.LeafConfig.maxUseItemDistance && Math.abs(vec3d2.y()) < org.dreeam.leaf.LeafConfig.maxUseItemDistance && Math.abs(vec3d2.z()) < org.dreeam.leaf.LeafConfig.maxUseItemDistance) || org.dreeam.leaf.LeafConfig.removeUseItemOnPacketTooFar) { // Leaf - Remove UseItemOnPacket Too Far Check and make it configurable ++ if ((Math.abs(vec3d2.x()) < org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance && Math.abs(vec3d2.y()) < org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance && Math.abs(vec3d2.z()) < org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.maxUseItemDistance) || org.dreeam.leaf.config.modules.gameplay.ConfigurableMaxUseItemDistance.removeUseItemOnPacketTooFarCheck) { // Leaf - Remove UseItemOnPacket Too Far Check and make it configurable Direction enumdirection = movingobjectpositionblock.getDirection(); this.player.resetLastActionTime(); diff --git a/patches/server/0019-KeYi-Player-Skull-API.patch b/patches/server/0019-KeYi-Player-Skull-API.patch index f8ef4c64a..8bde600af 100644 --- a/patches/server/0019-KeYi-Player-Skull-API.patch +++ b/patches/server/0019-KeYi-Player-Skull-API.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 720a81da72a8002ff02cc39e5fca42354519c742..c1ac66ca7354081a55b63ad43285cae4488c619c 100644 +index 720a81da72a8002ff02cc39e5fca42354519c742..5d1e93daf40d16de2162ae1c12c4f8da963d290c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -3384,4 +3384,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -28,10 +28,10 @@ index 720a81da72a8002ff02cc39e5fca42354519c742..c1ac66ca7354081a55b63ad43285cae4 + } + + @Override -+ public CompletableFuture getSkullAsynchronously() { ++ public java.util.concurrent.CompletableFuture getSkullAsynchronously() { + java.util.concurrent.ExecutorService executorService = java.util.concurrent.Executors.newCachedThreadPool(); + -+ CompletableFuture future = (CompletableFuture) executorService.submit(this::getSkull); ++ java.util.concurrent.CompletableFuture future = (java.util.concurrent.CompletableFuture) executorService.submit(this::getSkull); + executorService.shutdown(); + + return future; diff --git a/patches/server/0021-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch b/patches/server/0021-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch index 62f44d0ac..77160fe83 100644 --- a/patches/server/0021-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch +++ b/patches/server/0021-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 3ff5c2a4a2cca5c9a89ceafd9fddeb1012344433..90ab4610026b23ac84e6c941c6581d13fe3565a2 100644 +index 3ff5c2a4a2cca5c9a89ceafd9fddeb1012344433..01cd90d711f41598463aaaef78e752e916099871 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -331,7 +331,7 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -15,7 +15,7 @@ index 3ff5c2a4a2cca5c9a89ceafd9fddeb1012344433..90ab4610026b23ac84e6c941c6581d13 if (Objects.equals(this.target, other.target) && ItemEntity.areMergable(itemstack, itemstack1)) { - if (true || itemstack1.getCount() < itemstack.getCount()) { // Spigot -+ if (org.dreeam.leaf.LeafConfig.useSpigotItemMergingMechanism || itemstack1.getCount() < itemstack.getCount()) { // Spigot // KeYi ++ if (org.dreeam.leaf.config.modules.gameplay.UseSpigotItemMergingMech.enabled || itemstack1.getCount() < itemstack.getCount()) { // Spigot // KeYi ItemEntity.merge(this, itemstack, other, itemstack1); } else { ItemEntity.merge(other, itemstack1, this, itemstack); diff --git a/patches/server/0029-Leaves-Jade-Protocol.patch b/patches/server/0029-Leaves-Jade-Protocol.patch index 747d0528d..47ffb8703 100644 --- a/patches/server/0029-Leaves-Jade-Protocol.patch +++ b/patches/server/0029-Leaves-Jade-Protocol.patch @@ -9,7 +9,7 @@ Original project: https://github.com/LeavesMC/Leaves This patch is Powered by Jade(https://github.com/Snownee/Jade) diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c373f084d846e12faa42455c76f580b67b634717..019d504909d6492500cca77fae0a1e675aa53c88 100644 +index 29aeb034134adbe64551fb573c42a484bfbddf27..77b251f683eb7fcd32edad40ccd3ae9778672bc9 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -250,6 +250,7 @@ import org.bukkit.inventory.CraftingInventory; @@ -24,7 +24,7 @@ index c373f084d846e12faa42455c76f580b67b634717..019d504909d6492500cca77fae0a1e67 } // Paper end this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data); -+ if (org.dreeam.leaf.LeafConfig.jadeProtocol && ProtocolUtils.isNamespacePacket(packet, top.leavesmc.leaves.protocol.JadeProtocol.PROTOCOL_ID)) { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol && ProtocolUtils.isNamespacePacket(packet, top.leavesmc.leaves.protocol.JadeProtocol.PROTOCOL_ID)) { + top.leavesmc.leaves.protocol.JadeProtocol.handlePacket(server, player, packet); + } } catch (Exception ex) { @@ -57,7 +57,7 @@ index e91b4d63d42276f8a498cab7c439c785730f3f6f..a2d7c5008c6d6716d9530e00de0db027 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 62e4e6e840dd1d5dcbab14d2f5708839a08a8d4d..5c7264f1f1147d27b22164c905ebfaa1de438faf 100644 +index 62e4e6e840dd1d5dcbab14d2f5708839a08a8d4d..20d41bc342be19805ca1d50e160a4bb14428cd1f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -485,6 +485,7 @@ public final class CraftServer implements Server { @@ -73,16 +73,44 @@ index 62e4e6e840dd1d5dcbab14d2f5708839a08a8d4d..5c7264f1f1147d27b22164c905ebfaa1 this.console.galeConfigurations.reloadConfigs(this.console); // Gale - Gale configuration org.purpurmc.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur + // Leaves start - Jade -+ if (org.dreeam.leaf.LeafConfig.jadeProtocol) { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol) { + top.leavesmc.leaves.protocol.JadeProtocol.enableAllPlayer(); + } + // Leaves end - Jade for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) +diff --git a/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java b/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java +new file mode 100644 +index 0000000000000000000000000000000000000000..390f0c779cfe35f01311d7ad31e3f553148d7375 +--- /dev/null ++++ b/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java +@@ -0,0 +1,21 @@ ++package org.dreeam.leaf.config.modules.network; ++ ++import org.dreeam.leaf.config.ConfigInfo; ++import org.dreeam.leaf.config.EnumConfigCategory; ++import org.dreeam.leaf.config.IConfigModule; ++ ++public class ProtocolSupport implements IConfigModule { ++ ++ @Override ++ public EnumConfigCategory getCategory() { ++ return EnumConfigCategory.NETWORK; ++ } ++ ++ @Override ++ public String getBaseName() { ++ return "protocol_support"; ++ } ++ ++ @ConfigInfo(baseName = "jade-protocol") ++ public static boolean jadeProtocol = false; ++} +\ No newline at end of file diff --git a/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java new file mode 100644 -index 0000000000000000000000000000000000000000..b5c99fa4902628a06a153c164e8143ac8fe19a56 +index 0000000000000000000000000000000000000000..4fae4b2edd9f58a96538c50fb631f8c168970d8d --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/protocol/JadeProtocol.java @@ -0,0 +1,577 @@ @@ -188,7 +216,7 @@ index 0000000000000000000000000000000000000000..b5c99fa4902628a06a153c164e8143ac + } + + public static void onPlayerJoin(ServerPlayer player) { -+ if (org.dreeam.leaf.LeafConfig.jadeProtocol) { ++ if (org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol) { + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); + buf.writeUtf("{}"); + ProtocolUtils.sendPayloadPacket(player, PACKET_SERVER_PING, buf); @@ -403,7 +431,7 @@ index 0000000000000000000000000000000000000000..b5c99fa4902628a06a153c164e8143ac + } + + public static void requestEntityData(MinecraftServer server, ServerPlayer player, FriendlyByteBuf buf) { -+ if (!org.dreeam.leaf.LeafConfig.jadeProtocol) { ++ if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol) { + return; + } + @@ -437,7 +465,7 @@ index 0000000000000000000000000000000000000000..b5c99fa4902628a06a153c164e8143ac + } + + public static void requestTileData(MinecraftServer server, ServerPlayer player, FriendlyByteBuf buf) { -+ if (!org.dreeam.leaf.LeafConfig.jadeProtocol) { ++ if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol) { + return; + } + diff --git a/patches/server/0030-Leaves-Appleskin-Protocol.patch b/patches/server/0030-Leaves-Appleskin-Protocol.patch index 2044e3144..6d61d9494 100644 --- a/patches/server/0030-Leaves-Appleskin-Protocol.patch +++ b/patches/server/0030-Leaves-Appleskin-Protocol.patch @@ -7,7 +7,7 @@ Original license: GPLv3 Original project: https://github.com/LeavesMC/Leaves diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index bae93e3bbe3067250f08b4c8fad160f9bdf6f6d3..b007d9fb7beb350424c14d5b1ac05050e9d92cef 100644 +index 04d9f7c595ee6974173289848e6bc5b5a3ad061b..b3e294b65db22961fc428916a1fdfdd22f6bd593 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1567,6 +1567,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getStringList(String key, List defaultValue, String... comment) { -+ return getStringList(key, null, defaultValue, comment); -+ } -+ -+ private static List getStringList(String key, @Nullable String oldKey, List defaultValue, String... comment) { -+ ensureDefault(key, defaultValue, comment); -+ return config.getStringList(key); -+ } -+ -+ static Map getMap(String key, Map defaultValue) { -+ if (defaultValue != null && getConfigCopy().getConfigurationSection(key) == null) { -+ config.addDefault(key, defaultValue); -+ return defaultValue; -+ } -+ return toMap(getConfigCopy().getConfigurationSection(key)); -+ } -+ -+ private static Map toMap(ConfigurationSection section) { -+ ImmutableMap.Builder builder = ImmutableMap.builder(); -+ if (section != null) { -+ for (String key : section.getKeys(false)) { -+ Object obj = section.get(key); -+ if (obj != null) { -+ builder.put(key, obj instanceof ConfigurationSection val ? toMap(val) : obj); -+ } -+ } -+ } -+ return builder.build(); -+ } -+ -+ public static String serverModName = "Leaf"; -+ private static void serverModName() { -+ serverModName = getString("server-mod-name", serverModName); -+ } -+ -+ public static String serverGUIName = "Leaf Console"; -+ private static void serverGUIName() { -+ serverGUIName = getString("server-gui-name", serverGUIName); -+ } -+ -+ public static boolean removeMojangUsernameCheck = true; -+ public static boolean removeSpigotCheckBungeeConfig = true; -+ public static boolean removeUseItemOnPacketTooFar = false; -+ public static double maxUseItemDistance = 1.0000001D; -+ private static void removal() { -+ removeMojangUsernameCheck = getBoolean("remove-Mojang-username-check", removeMojangUsernameCheck, -+ "Remove username check of Mojang", -+ "enabling all characters as username"); -+ removeSpigotCheckBungeeConfig = getBoolean("remove-Spigot-check-bungee-config", removeSpigotCheckBungeeConfig, -+ "Enable player enter backend server through proxy", -+ "without backend server enabling its bungee mode"); -+ removeUseItemOnPacketTooFar = getBoolean("remove-UseItemOnPacket-too-far-check", removeUseItemOnPacketTooFar, -+ "To enable this, players can use some packet modules with hack clients and the NoCom Exploit!!"); -+ maxUseItemDistance = getDouble("max-UseItem-distance", maxUseItemDistance, "The max distance of UseItem for players"); -+ } -+ -+ public static boolean enableAsyncMobSpawning = true; -+ public static boolean asyncMobSpawningInitialized; -+ public static boolean dabEnabled = true; -+ public static int startDistance = 12; -+ public static int startDistanceSquared; -+ public static int maximumActivationPrio = 20; -+ public static int activationDistanceMod = 8; -+ public static boolean throttleInactiveGoalSelectorTick = true; -+ public static Map projectileTimeouts; -+ public static boolean useSpigotItemMergingMechanism = true; -+ public static boolean asyncPathfinding = false; -+ public static int asyncPathfindingMaxThreads = 0; -+ public static int asyncPathfindingKeepalive = 60; -+ public static boolean cacheMinecartCollision = false; -+ private static void performance() { -+ boolean asyncMobSpawning = getBoolean("performance.enable-async-mob-spawning", enableAsyncMobSpawning, -+ "Whether or not asynchronous mob spawning should be enabled.", -+ "On servers with many entities, this can improve performance by up to 15%. You must have", -+ "paper's per-player-mob-spawns setting set to true for this to work.", -+ "One quick note - this does not actually spawn mobs async (that would be very unsafe).", -+ "This just offloads some expensive calculations that are required for mob spawning."); -+ // This prevents us from changing the value during a reload. -+ if (!asyncMobSpawningInitialized) { -+ asyncMobSpawningInitialized = true; -+ enableAsyncMobSpawning = asyncMobSpawning; -+ } -+ dabEnabled = getBoolean("performance.dab.enabled", "dab.enabled", dabEnabled); -+ startDistance = getInt("performance.dab.start-distance", "dab.start-distance", startDistance, -+ "This value determines how far away an entity has to be", -+ "from the player to start being effected by DEAR."); -+ startDistanceSquared = startDistance * startDistance; -+ maximumActivationPrio = getInt("performance.dab.max-tick-freq", "dab.max-tick-freq", maximumActivationPrio, -+ "This value defines how often in ticks, the furthest entity", -+ "will get their pathfinders and behaviors ticked. 20 = 1s"); -+ activationDistanceMod = getInt("performance.dab.activation-dist-mod", "dab.activation-dist-mod", activationDistanceMod, -+ "This value defines how much distance modifies an entity's", -+ "tick frequency. freq = (distanceToPlayer^2) / (2^value)", -+ "If you want further away entities to tick less often, use 7.", -+ "If you want further away entities to tick more often, try 9."); -+ for (EntityType entityType : BuiltInRegistries.ENTITY_TYPE) { -+ entityType.dabEnabled = true; // reset all, before setting the ones to true -+ } -+ getStringList("performance.dab.blacklisted-entities", "dab.blacklisted-entities", Collections.emptyList(), "A list of entities to ignore for activation") -+ .forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> { -+ entityType.dabEnabled = false; -+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\""))); -+ setComment("performance.dab", "Optimizes entity brains when", "they're far away from the player"); -+ throttleInactiveGoalSelectorTick = getBoolean("performance.inactive-goal-selector-throttle", "inactive-goal-selector-throttle", throttleInactiveGoalSelectorTick, -+ "Throttles the AI goal selector in entity inactive ticks.", -+ "This can improve performance by a few percent, but has minor gameplay implications."); -+ // Set some defaults -+ getInt("performance.entity_timeouts.SNOWBALL", -1); -+ getInt("performance.entity_timeouts.LLAMA_SPIT", -1); -+ setComment("entity_timeouts", -+ "These values define a entity's maximum lifespan. If an", -+ "entity is in this list and it has survived for longer than", -+ "that number of ticks, then it will be removed. Setting a value to", -+ "-1 disables this feature."); -+ for (EntityType entityType : BuiltInRegistries.ENTITY_TYPE) { -+ String type = EntityType.getKey(entityType).getPath().toUpperCase(Locale.ROOT); -+ entityType.ttl = config.getInt("entity_timeouts." + type, -1); -+ } -+ useSpigotItemMergingMechanism = getBoolean("performance.use-spigot-item-merging-mechanism", useSpigotItemMergingMechanism); -+ asyncPathfinding = getBoolean("performance.async-pathfinding.enable", asyncPathfinding); -+ asyncPathfindingMaxThreads = getInt("performance.async-pathfinding.max-threads", asyncPathfindingMaxThreads); -+ asyncPathfindingKeepalive = getInt("performance.async-pathfinding.keepalive", asyncPathfindingKeepalive); -+ if (asyncPathfindingMaxThreads < 0) -+ asyncPathfindingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() + asyncPathfindingMaxThreads, 1); -+ else if (asyncPathfindingMaxThreads == 0) -+ asyncPathfindingMaxThreads = Math.max(Runtime.getRuntime().availableProcessors() / 4, 1); -+ if (!asyncPathfinding) -+ asyncPathfindingMaxThreads = 0; -+ else -+ Bukkit.getLogger().log(Level.INFO, "Using " + asyncPathfindingMaxThreads + " threads for Async Pathfinding"); -+ cacheMinecartCollision = getBoolean("performance.cache-minecart-collision", cacheMinecartCollision, -+ "Cache the minecart collision result to prevent massive stacked minecart lag the server.", -+ "The known issue: entity can't enter the minecart after enabling this!"); -+ } -+ -+ public static boolean jadeProtocol = false; -+ public static boolean appleskinProtocol = false; -+ public static boolean xaeroMapProtocol = false; + + public class ProtocolSupport implements IConfigModule { + +@@ -27,5 +27,5 @@ public class ProtocolSupport implements IConfigModule { + @ConfigInfo(baseName = "xaero-map-protocol") + public static boolean xaeroMapProtocol = false; + @ConfigInfo(baseName = "xaero-map-server-id") +- public static int xaeroMapServerID = new Random().nextInt(); + public static int xaeroMapServerID = ThreadLocalRandom.current().nextInt(); // Leaf - Faster Random -+ private static void network() { -+ jadeProtocol = getBoolean("network.protocol.jade-protocol", jadeProtocol); -+ appleskinProtocol = getBoolean("network.protocol.appleskin-protocol", appleskinProtocol); -+ xaeroMapProtocol = getBoolean("network.protocol.xaero-map-protocol", xaeroMapProtocol); -+ xaeroMapServerID = getInt("network.protocol.xaero-map-server-id", xaeroMapServerID); -+ } -+ -+ public static String sentryDsn = ""; -+ private static void sentryDsn() { -+ String sentryEnvironment = System.getenv("SENTRY_DSN"); -+ String sentryConfig = getString("sentry-dsn", sentryDsn, "Sentry DSN for improved error logging, leave blank to disable", "Obtain from https://sentry.io/welcome/"); -+ sentryDsn = sentryEnvironment == null ? sentryConfig : sentryEnvironment; -+ if (sentryDsn != null && !sentryDsn.isBlank()) { -+ gg.pufferfish.pufferfish.sentry.SentryManager.init(); -+ } -+ } -+} + } +\ No newline at end of file diff --git a/patches/server/0039-Petal-Async-Pathfinding.patch b/patches/server/0039-Petal-Async-Pathfinding.patch index 72f2647f7..6204fae11 100644 --- a/patches/server/0039-Petal-Async-Pathfinding.patch +++ b/patches/server/0039-Petal-Async-Pathfinding.patch @@ -14,7 +14,7 @@ This patch was ported downstream from the Petal fork. Makes most pathfinding-related work happen asynchronously diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 455a0a96ac6aa6106e9011cd41be228b5a880fe5..211099df1a84748eafccfba984926fc545ed3c14 100644 +index 79c67810af9a1ace6ac98f54188f15dc18883e9b..41d2a9d5bec1cb170cf6e3aebf5ebe9607770815 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -292,6 +292,7 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -26,7 +26,7 @@ index 455a0a96ac6aa6106e9011cd41be228b5a880fe5..211099df1a84748eafccfba984926fc5 } diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index aed7e9affaae1e0d1e3324a41e5818435f76fd0f..1ec76b42e979b70adb4e0c953a071e5eb8647d06 100644 +index aed7e9affaae1e0d1e3324a41e5818435f76fd0f..d1adbd661e635507cc25e2439dba43acb8538d5e 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java @@ -7,7 +7,6 @@ import java.util.HashSet; @@ -50,7 +50,7 @@ index aed7e9affaae1e0d1e3324a41e5818435f76fd0f..1ec76b42e979b70adb4e0c953a071e5e Set, BlockPos>> set = new java.util.HashSet<>(poiposes); // Paper end - optimise POI access + // Kaiiju start - petal - Async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) { ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) { + // await on path async + Path possiblePath = findPathToPois(entity, set); + @@ -95,7 +95,7 @@ index aed7e9affaae1e0d1e3324a41e5818435f76fd0f..1ec76b42e979b70adb4e0c953a071e5e return true; } diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java -index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..16809bd3e914b19dddb5985d3468808cd0f90d91 100644 +index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..e37ecae581e3723e36808fe51bcee9034b69b803 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java @@ -21,6 +21,7 @@ public class MoveToTargetSink extends Behavior { @@ -111,10 +111,10 @@ index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..16809bd3e914b19dddb5985d3468808c WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); boolean bl = this.reachedTarget(entity, walkTarget); - if (!bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { -+ if (!org.dreeam.leaf.LeafConfig.asyncPathfinding && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { // Kaiiju - petal - async path processing means we can't know if the path is reachable here ++ if (!org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled && !bl && this.tryComputePath(entity, walkTarget, world.getGameTime())) { // Kaiiju - petal - async path processing means we can't know if the path is reachable here this.lastTargetPos = walkTarget.getTarget().currentBlockPosition(); return true; -+ } else if (org.dreeam.leaf.LeafConfig.asyncPathfinding && !bl) { return true; // Kaiiju - async pathfinding ++ } else if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled && !bl) { return true; // Kaiiju - async pathfinding } else { brain.eraseMemory(MemoryModuleType.WALK_TARGET); if (bl) { @@ -122,7 +122,7 @@ index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..16809bd3e914b19dddb5985d3468808c @Override protected boolean canStillUse(ServerLevel world, Mob entity, long time) { -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding && !this.finishedProcessing) return true; // Kaiiju - petal - wait for processing ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled && !this.finishedProcessing) return true; // Kaiiju - petal - wait for processing if (this.path != null && this.lastTargetPos != null) { Optional optional = entity.getBrain().getMemory(MemoryModuleType.WALK_TARGET); boolean bl = optional.map(MoveToTargetSink::isWalkTargetSpectator).orElse(false); @@ -131,7 +131,7 @@ index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..16809bd3e914b19dddb5985d3468808c @Override protected void start(ServerLevel serverLevel, Mob mob, long l) { + // Kaiiju start - petal - start processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) { ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) { + Brain brain = mob.getBrain(); + WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get(); + @@ -148,7 +148,7 @@ index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..16809bd3e914b19dddb5985d3468808c @Override protected void tick(ServerLevel serverLevel, Mob mob, long l) { + // Kaiiju start - petal - Async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) { ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) { + if (this.path != null && !this.path.isProcessed()) return; // wait for processing + + if (!this.finishedProcessing) { @@ -220,7 +220,7 @@ index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..16809bd3e914b19dddb5985d3468808c private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) { BlockPos blockPos = walkTarget.getTarget().currentBlockPosition(); diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java -index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..d5c26e4effb7695b0ed7ee91cd49091bc7e8e904 100644 +index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..67310486641c87a6b80fd0ebf5029ef6aa5564b1 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/SetClosestHomeAsWalkTarget.java @@ -20,6 +20,7 @@ import net.minecraft.world.entity.ai.village.poi.PoiTypes; @@ -236,7 +236,7 @@ index 271efbb027f6f5d69ac5bc5dc51102a1eb00ab31..d5c26e4effb7695b0ed7ee91cd49091b return poiType.is(PoiTypes.HOME); }, predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY).collect(Collectors.toSet()); + // Kaiiju start - petal - Async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) { ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) { + // await on path async + Path possiblePath = AcquirePoi.findPathToPois(entity, set); + @@ -280,7 +280,7 @@ index 6771f2dc974317b6b152288bf41d1a95bc78a8e4..7a641747b17164b09bb8483cda7f69d1 Node node = path.getNode(i); this.doorPos = new BlockPos(node.x, node.y + 1, node.z); diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java -index 97bd4c9f83257c8c54694110d369d0487e4df9f9..75e46adf28a656e8496e1f87ce4a61e6b8b65d4c 100644 +index 97bd4c9f83257c8c54694110d369d0487e4df9f9..f1fed8c65218c0165e29fe211ef97c7c6d5772b6 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/AmphibiousPathNavigation.java @@ -6,16 +6,34 @@ import net.minecraft.world.level.Level; @@ -311,7 +311,7 @@ index 97bd4c9f83257c8c54694110d369d0487e4df9f9..75e46adf28a656e8496e1f87ce4a61e6 this.nodeEvaluator = new AmphibiousNodeEvaluator(false); this.nodeEvaluator.setCanPassDoors(true); + // Kaiiju start - petal - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); + else + // Kaiiju end @@ -319,7 +319,7 @@ index 97bd4c9f83257c8c54694110d369d0487e4df9f9..75e46adf28a656e8496e1f87ce4a61e6 } diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java -index acd0b946cab86eb173e713535194d3a9347c7d48..153d2549234b8d7ffa8a58801ee998d46cd6f9d9 100644 +index acd0b946cab86eb173e713535194d3a9347c7d48..0f5b414c2cbd126aeb4280f3a1bf5844b97b1cc4 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java @@ -10,16 +10,34 @@ import net.minecraft.world.level.pathfinder.FlyNodeEvaluator; @@ -350,7 +350,7 @@ index acd0b946cab86eb173e713535194d3a9347c7d48..153d2549234b8d7ffa8a58801ee998d4 this.nodeEvaluator = new FlyNodeEvaluator(); this.nodeEvaluator.setCanPassDoors(true); + // Kaiiju start - petal - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); + else + // Kaiiju end @@ -366,7 +366,7 @@ index acd0b946cab86eb173e713535194d3a9347c7d48..153d2549234b8d7ffa8a58801ee998d4 if (!this.isDone()) { if (this.canUpdatePath()) { diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java -index 71934af2dc4d209a9fbccfd36b5f2815ec196892..7685d6e762a9011b61dedd772ef8ac31c36f8a80 100644 +index 71934af2dc4d209a9fbccfd36b5f2815ec196892..92992ff786b70f67daa110c8ae112c767a7e59d0 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java @@ -13,6 +13,8 @@ import net.minecraft.world.level.pathfinder.Path; @@ -398,7 +398,7 @@ index 71934af2dc4d209a9fbccfd36b5f2815ec196892..7685d6e762a9011b61dedd772ef8ac31 this.nodeEvaluator = new WalkNodeEvaluator(); this.nodeEvaluator.setCanPassDoors(true); + // Kaiiju start - petal - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); + else + // Kaiiju end @@ -406,7 +406,7 @@ index 71934af2dc4d209a9fbccfd36b5f2815ec196892..7685d6e762a9011b61dedd772ef8ac31 } diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index 7d7fbe9309f3957ecad5d47ba65cf8ebb66d3423..e6b0d1bb2f071561186801bed0a31e783df81413 100644 +index 7d7fbe9309f3957ecad5d47ba65cf8ebb66d3423..1e2eff7f49a1394bf5d5189f06593b9016a815ff 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java @@ -25,6 +25,8 @@ import net.minecraft.world.level.pathfinder.PathFinder; @@ -434,7 +434,7 @@ index 7d7fbe9309f3957ecad5d47ba65cf8ebb66d3423..e6b0d1bb2f071561186801bed0a31e78 PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i)); Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier); + // Kaiiju start - petal - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) { ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) { + // assign early a target position. most calls will only have 1 position + if (!positions.isEmpty()) this.targetPos = positions.iterator().next(); + @@ -496,7 +496,7 @@ index 7d7fbe9309f3957ecad5d47ba65cf8ebb66d3423..e6b0d1bb2f071561186801bed0a31e78 Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0D, ((double)node.y + this.mob.getY()) / 2.0D, ((double)node.z + this.mob.getZ()) / 2.0D); return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex())); diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java -index 87887916ff2f685346699989ba30c35ef7e5715f..67b45b25852ea7f42ba83d01def0ead970856f38 100644 +index 87887916ff2f685346699989ba30c35ef7e5715f..b1da65ca63bfcc3c763c47795a33d09ed57199fa 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WaterBoundPathNavigation.java @@ -7,6 +7,8 @@ import net.minecraft.world.level.Level; @@ -528,7 +528,7 @@ index 87887916ff2f685346699989ba30c35ef7e5715f..67b45b25852ea7f42ba83d01def0ead9 this.allowBreaching = this.mob.getType() == EntityType.DOLPHIN; this.nodeEvaluator = new SwimNodeEvaluator(this.allowBreaching); + // Kaiiju start - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); + else + // Kaiiju end @@ -536,7 +536,7 @@ index 87887916ff2f685346699989ba30c35ef7e5715f..67b45b25852ea7f42ba83d01def0ead9 } diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java -index 8db20db72cd51046213625fac46c35854c59ec5d..fc99483dfe248d26885c904b72c93b0d68a29636 100644 +index 8db20db72cd51046213625fac46c35854c59ec5d..652e7ca5f77f03d9a03a7732717ce3a7208441c6 100644 --- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestBedSensor.java @@ -7,7 +7,7 @@ import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; @@ -561,7 +561,7 @@ index 8db20db72cd51046213625fac46c35854c59ec5d..fc99483dfe248d26885c904b72c93b0d // don't ask me why it's unbounded. ask mojang. io.papermc.paper.util.PoiAccess.findAnyPoiPositions(poiManager, type -> type.is(PoiTypes.HOME), predicate, entity.blockPosition(), 48, PoiManager.Occupancy.ANY, false, Integer.MAX_VALUE, poiposes); + // Kaiiju start - await on async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) { ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) { + Path possiblePath = AcquirePoi.findPathToPois(entity, new java.util.HashSet<>(poiposes)); + AsyncPathProcessor.awaitProcessing(entity, possiblePath, path -> { + // read canReach check @@ -613,7 +613,7 @@ index 6c04c8e7776b2830ac368229da834532e8ce163e..abf25dfbf33be9be1875470448ebef85 } } diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -index 57ea54559ae49af025bf9751320b3eecf1cc91db..a7b9ad9d49358b2e447cfd09135b0be4db5bbae9 100644 +index 57ea54559ae49af025bf9751320b3eecf1cc91db..41fc5e6fd985a0fc538313f74e2e1a2d8f5581dd 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java +++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java @@ -40,7 +40,6 @@ import net.minecraft.world.entity.VariantHolder; @@ -656,7 +656,7 @@ index 57ea54559ae49af025bf9751320b3eecf1cc91db..a7b9ad9d49358b2e447cfd09135b0be4 this.nodeEvaluator = new Frog.FrogNodeEvaluator(true); this.nodeEvaluator.setCanPassDoors(true); + // Kaiiju start - petal - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); + else + // Kaiiju end @@ -685,7 +685,7 @@ index 63a1cf5604c14025171d7be7434e2d6b64c98107..5058e53325b61a37e7b6398e59248bc3 if (blockposition != null) { diff --git a/src/main/java/net/minecraft/world/entity/monster/Strider.java b/src/main/java/net/minecraft/world/entity/monster/Strider.java -index cfa603c7ccaaf1940aa89fa7cd8fafba29529075..4ccfb2306b195e8853547b228c0f708d0d435287 100644 +index cfa603c7ccaaf1940aa89fa7cd8fafba29529075..c8bd85c798cb48c53c2b9ccba2b44bb0ae817aa5 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Strider.java +++ b/src/main/java/net/minecraft/world/entity/monster/Strider.java @@ -72,6 +72,8 @@ import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; @@ -717,7 +717,7 @@ index cfa603c7ccaaf1940aa89fa7cd8fafba29529075..4ccfb2306b195e8853547b228c0f708d this.nodeEvaluator = new WalkNodeEvaluator(); this.nodeEvaluator.setCanPassDoors(true); + // Kaiiju start - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, nodeEvaluatorGenerator); + else + // Kaiiju end @@ -725,7 +725,7 @@ index cfa603c7ccaaf1940aa89fa7cd8fafba29529075..4ccfb2306b195e8853547b228c0f708d } diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 56bbee840ad585148943e52cf2ddc98baba93fc5..d88697eaab51ca73065c8939cc83f1828145bd3d 100644 +index 56bbee840ad585148943e52cf2ddc98baba93fc5..481eff9eedf49c4f545b39cce79eaef6216681d4 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java +++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java @@ -621,6 +621,16 @@ public class Warden extends Monster implements VibrationSystem { @@ -733,7 +733,7 @@ index 56bbee840ad585148943e52cf2ddc98baba93fc5..d88697eaab51ca73065c8939cc83f182 this.nodeEvaluator = new WalkNodeEvaluator(); this.nodeEvaluator.setCanPassDoors(true); + // Kaiiju start - petal - async path processing -+ if (org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + return new PathFinder(this.nodeEvaluator, range, GroundPathNavigation.nodeEvaluatorGenerator) { + @Override + protected float distance(Node a, Node b) { @@ -794,7 +794,7 @@ index 2a335f277bd0e4b8ad0f60d8226eb8aaa80a871f..b2c3c459fae7d0cb5ef0fcbc2ff0e61c return false; } else if (o.nodes.size() != this.nodes.size()) { diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index c4052d1a7c2903564a8a6226c1b019d299c71b2a..97490ba1adeed8d0c941587d42700d35b5a41fd5 100644 +index c4052d1a7c2903564a8a6226c1b019d299c71b2a..56020653c9d80ec9275d24a6d8a0162230c0c36b 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java @@ -1,20 +1,18 @@ @@ -846,7 +846,7 @@ index c4052d1a7c2903564a8a6226c1b019d299c71b2a..97490ba1adeed8d0c941587d42700d35 - this.openSet.clear(); - this.nodeEvaluator.prepare(world, mob); - Node node = this.nodeEvaluator.getStart(); -+ if (!org.dreeam.leaf.LeafConfig.asyncPathfinding) ++ if (!org.dreeam.leaf.config.modules.async.AsyncPathfinding.enabled) + this.openSet.clear(); // Kaiiju - petal - it's always cleared in processPath + // Kaiiju start - petal - use a generated evaluator if we have one otherwise run sync + NodeEvaluator nodeEvaluator = this.nodeEvaluatorGenerator == null @@ -1283,7 +1283,7 @@ index 0000000000000000000000000000000000000000..d0123bae825b88bc5cf71bf2b1f21aa0 +} diff --git a/src/main/java/org/dreeam/leaf/path/AsyncPathProcessor.java b/src/main/java/org/dreeam/leaf/path/AsyncPathProcessor.java new file mode 100644 -index 0000000000000000000000000000000000000000..e9e0bdc03d7f3634388bdd12650ada38db1c0407 +index 0000000000000000000000000000000000000000..e8aba17b535359ba36ca67206330831a8c516e65 --- /dev/null +++ b/src/main/java/org/dreeam/leaf/path/AsyncPathProcessor.java @@ -0,0 +1,52 @@ @@ -1307,8 +1307,8 @@ index 0000000000000000000000000000000000000000..e9e0bdc03d7f3634388bdd12650ada38 + + private static final Executor pathProcessingExecutor = new ThreadPoolExecutor( + 1, -+ org.dreeam.leaf.LeafConfig.asyncPathfindingMaxThreads, -+ org.dreeam.leaf.LeafConfig.asyncPathfindingKeepalive, TimeUnit.SECONDS, ++ org.dreeam.leaf.config.modules.async.AsyncPathfinding.asyncPathfindingMaxThreads, ++ org.dreeam.leaf.config.modules.async.AsyncPathfinding.asyncPathfindingKeepalive, TimeUnit.SECONDS, + new LinkedBlockingQueue<>(), + new ThreadFactoryBuilder() + .setNameFormat("petal-path-processor-%d") diff --git a/patches/server/0041-Petal-reduce-work-done-by-game-event-system.patch b/patches/server/0041-Petal-reduce-work-done-by-game-event-system.patch index 052e92185..834ae3b10 100644 --- a/patches/server/0041-Petal-reduce-work-done-by-game-event-system.patch +++ b/patches/server/0041-Petal-reduce-work-done-by-game-event-system.patch @@ -11,7 +11,7 @@ Original project: https://github.com/Bloom-host/Petal 2. EuclideanGameEventListenerRegistry is not used concurrently so we ban that usage for improved performance with allays diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -index 6c378e3485fef4e8b8906c33a45a23e6f77e9cdd..68a2a31477f9ad6ec854b5b464070baa7e059ecf 100644 +index 6c378e3485fef4e8b8906c33a45a23e6f77e9cdd..d85d6d8364382fe88a58f479b22b2fa791dea49e 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java @@ -58,7 +58,7 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi @@ -30,7 +30,7 @@ index 6c378e3485fef4e8b8906c33a45a23e6f77e9cdd..68a2a31477f9ad6ec854b5b464070baa + // Leaf start - petal + @Override + public boolean listensToEvent(GameEvent gameEvent, GameEvent.Context context) { -+ return !SculkCatalystBlockEntity.this.isRemoved() && gameEvent == GameEvent.ENTITY_DIE.value() && context.sourceEntity() instanceof LivingEntity; ++ return !SculkCatalystBlockEntity.this.isRemoved() && gameEvent == GameEvent.ENTITY_DIE && context.sourceEntity() instanceof LivingEntity; + } + // Leaf end - petal + @@ -167,14 +167,14 @@ index 48132c44ddc147eea0f751c1fc568388730104c5..e344b6c56e3ea7ec26e4c5bf374aeef3 return bl; } diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java -index 744160405680babbb83c99abcbe2dc89bf312398..fd81025bc40c85cca3242a1c6bbde94336d701aa 100644 +index 744160405680babbb83c99abcbe2dc89bf312398..90ea66ca33981ab10ef1fede26466665489e2e88 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java +++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java @@ -44,6 +44,7 @@ public class GameEventDispatcher { int k1 = SectionPos.blockToSectionCoord(blockposition.getZ() + i); List list = new ArrayList(); GameEventListenerRegistry.ListenerVisitor gameeventlistenerregistry_a = (gameeventlistener, vec3d1) -> { -+ if (!gameeventlistener.listensToEvent(event.value(), emitter)) return; // Leaf - petal - If they don't listen, ignore ++ if (!gameeventlistener.listensToEvent(event, emitter)) return; // Leaf - petal - If they don't listen, ignore if (gameeventlistener.getDeliveryMode() == GameEventListener.DeliveryMode.BY_DISTANCE) { list.add(new GameEvent.ListenerInfo(event, emitterPos, emitter, gameeventlistener, vec3d1)); } else { diff --git a/patches/server/0046-Configurable-fix-tripwire-dupe.patch b/patches/server/0046-Configurable-fix-tripwire-dupe.patch index f206ce8ce..5492f47b6 100644 --- a/patches/server/0046-Configurable-fix-tripwire-dupe.patch +++ b/patches/server/0046-Configurable-fix-tripwire-dupe.patch @@ -41,7 +41,7 @@ index eb1ecbbb5c0f887ee1c7de85a6137f2f182b3fc0..641a0c65f95acb7ca180bd6e1933cdbb } else if (iblockdata1.is((Block) this)) { ++k; diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -index 004dce26ff073f1de52a84cd425c4f60fdab5e50..65ce625e80949788ceb7e33a02b0fb19ed480382 100644 +index 004dce26ff073f1de52a84cd425c4f60fdab5e50..b58a42eaa0b35b1b458d99831c9c85c830aca5c0 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java @@ -108,12 +108,6 @@ public class TripWireHookBlock extends Block { @@ -65,15 +65,6 @@ index 004dce26ff073f1de52a84cd425c4f60fdab5e50..65ce625e80949788ceb7e33a02b0fb19 aiblockdata[k] = iblockdata2; if (k == i) { world.scheduleTick(pos, (Block) this, 10); -@@ -182,7 +175,7 @@ public class TripWireHookBlock extends Block { - - this.emitState(world, pos, flag4, flag5, flag2, flag3); - if (!beingRemoved) { -- if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - validate -+ if (!org.dreeam.leaf.LeafConfig.fixTripwireDupe || world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - validate // Leaf - Configurable fix tripwire dupe - world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3); - if (flag1) { - this.notifyNeighbors(world, pos, enumdirection); @@ -195,9 +188,8 @@ public class TripWireHookBlock extends Block { BlockState iblockdata4 = aiblockdata[l]; diff --git a/patches/server/0049-Configurable-bamboo-collision.patch b/patches/server/0049-Configurable-bamboo-collision.patch index 1923e99b4..2dc6b1875 100644 --- a/patches/server/0049-Configurable-bamboo-collision.patch +++ b/patches/server/0049-Configurable-bamboo-collision.patch @@ -37,25 +37,42 @@ index a5d391af2c6b733d653188f4aeeec2afffd96adf..5413c59c50f8cf60eaddbb0dce62b5e7 } @Override -diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index e25b4f2ad080d0fbd6782cee305a7c5f4f206a2a..4eadad401c642ec28845f60ed7485bd35bc6b488 100644 ---- a/src/main/java/org/dreeam/leaf/LeafConfig.java -+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -1,5 +1,6 @@ - package org.dreeam.leaf; - +diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/ConfigurableBambooCollision.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/ConfigurableBambooCollision.java +new file mode 100644 +index 0000000000000000000000000000000000000000..c40ba24f1bdcdbb9d1c2acab46ff2985ce8c3dc3 +--- /dev/null ++++ b/src/main/java/org/dreeam/leaf/config/modules/gameplay/ConfigurableBambooCollision.java +@@ -0,0 +1,33 @@ ++package org.dreeam.leaf.config.modules.gameplay; ++ +import com.electronwill.nightconfig.core.file.CommentedFileConfig; - import com.google.common.collect.ImmutableMap; - import net.minecraft.core.registries.BuiltInRegistries; - import java.util.concurrent.ThreadLocalRandom; -@@ -295,7 +296,9 @@ public class LeafConfig { - } - - public static boolean fixTripwireDupe = true; -- private static void tripwireDupe() { -+ public static boolean configurableBambooCollision = true; -+ private static void gameplay() { - fixTripwireDupe = getBoolean("gameplay.fix-tripwire-dupe", fixTripwireDupe); -+ configurableBambooCollision = getBoolean("gameplay.configurable_bamboo_collision", configurableBambooCollision); - } - } ++import org.dreeam.leaf.config.ConfigInfo; ++import org.dreeam.leaf.config.EnumConfigCategory; ++import org.dreeam.leaf.config.HotReloadUnsupported; ++import org.dreeam.leaf.config.IConfigModule; ++ ++public class ConfigurableBambooCollision implements IConfigModule { ++ ++ @Override ++ public EnumConfigCategory getCategory() { ++ return EnumConfigCategory.GAMEPLAY; ++ } ++ ++ @Override ++ public String getBaseName() { ++ return "configurable_bamboo_collision"; ++ } ++ ++ @HotReloadUnsupported ++ @ConfigInfo(baseName = "enable-collision") ++ public static boolean enableCollision = true; ++ ++ @Override ++ public void onLoaded(CommentedFileConfig config) { ++ config.setComment("gameplay.configurable_bamboo_collision", """ ++ Should we enable the collision of bamboo? ++ Disable collision will fix Geyser players' buggy movement when they close to these blocks ++ But all players can pass through Bamboo blocks directly ++ """); ++ } ++}