diff --git a/build-data/leaf.at b/build-data/leaf.at index f0c75d48..55828ad9 100644 --- a/build-data/leaf.at +++ b/build-data/leaf.at @@ -5,6 +5,8 @@ protected-f net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase$ public net.minecraft.util.Mth SIN public net.minecraft.world.entity.Entity updateInWaterStateAndDoWaterCurrentPushing()V public net.minecraft.world.entity.LivingEntity canGlide()Z +public net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities lineOfSightTest +public net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities nearbyEntities public net.minecraft.world.entity.decoration.ArmorStand noTickEquipmentDirty public net.minecraft.world.entity.monster.Shulker MAX_SCALE public net.minecraft.world.entity.player.Player canGlide()Z diff --git a/gradle.properties b/gradle.properties index 0114ce25..9b106683 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=cn.dreeam.leaf mcVersion=1.21.4 version=1.21.4-R0.1-SNAPSHOT -galeCommit=8372ff60079ad128a4c40b879e428d1f18c443e7 +galeCommit=0b5fbea3d4797d2a189fe3790105f5ce613ee93c org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/leaf-archived-patches/removed/hardfork/server/0120-Replace-criterion-listener-map-with-optimized-collec.patch b/leaf-archived-patches/removed/hardfork/server/0120-Replace-criterion-listener-map-with-optimized-collec.patch new file mode 100644 index 00000000..93d9ce96 --- /dev/null +++ b/leaf-archived-patches/removed/hardfork/server/0120-Replace-criterion-listener-map-with-optimized-collec.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sun, 9 Feb 2025 01:36:24 +0100 +Subject: [PATCH] Replace criterion listener map with optimized collection + + +diff --git a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +index 4b2ae046413146b11912e7aa4a9a3d643de6afd1..6a4889d4ba90c1995e15c0daa6bb52682ec87eb4 100644 +--- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java ++++ b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +@@ -19,7 +19,7 @@ public abstract class SimpleCriterionTrigger listener) { +- playerAdvancements.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(listener); // Paper - fix PlayerAdvancements leak ++ playerAdvancements.criterionData.computeIfAbsent(this, managerx -> new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>()).add(listener); // Paper - fix PlayerAdvancements leak // Leaf - Replace criterion listener map with optimized collection + } + + @Override +@@ -43,7 +43,7 @@ public abstract class SimpleCriterionTrigger> set = (Set) advancements.criterionData.get(this); // Paper - fix PlayerAdvancements leak + if (set != null && !set.isEmpty()) { + LootContext lootContext = null; // EntityPredicate.createContext(player, player); // Paper - Perf: lazily create LootContext for criterions +- List> list = null; ++ it.unimi.dsi.fastutil.objects.ObjectArrayList> list = null; // Leaf - Replace criterion listener map with optimized collection + + for (CriterionTrigger.Listener listener : set) { + T simpleInstance = listener.trigger(); +@@ -51,7 +51,7 @@ public abstract class SimpleCriterionTrigger optional = simpleInstance.player(); + if (optional.isEmpty() || optional.get().matches(lootContext = (lootContext == null ? EntityPredicate.createContext(player, player) : lootContext))) { // Paper - Perf: lazily create LootContext for criterions + if (list == null) { +- list = Lists.newArrayList(); ++ list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); // Leaf - Replace criterion listener map with optimized collection + } + + list.add(listener); diff --git a/leaf-archived-patches/work/server/0110-Cache-ItemStack-max-stack-size.patch b/leaf-archived-patches/work/server/0110-Cache-ItemStack-max-stack-size.patch new file mode 100644 index 00000000..55d9d72f --- /dev/null +++ b/leaf-archived-patches/work/server/0110-Cache-ItemStack-max-stack-size.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Fri, 7 Feb 2025 21:41:51 +0100 +Subject: [PATCH] Cache ItemStack max stack size + +TODO: check this, fix get max stack size + +diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java +index fd7c1e800cbd4919a1a47f6c468c8776535bd028..fdd7e89bacc98e23f067ba17d0bd93ee84a388cb 100644 +--- a/net/minecraft/world/item/ItemStack.java ++++ b/net/minecraft/world/item/ItemStack.java +@@ -194,6 +194,7 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods + private static final Logger LOGGER = LogUtils.getLogger(); + public static final ItemStack EMPTY = new ItemStack((Void)null); + private static final Component DISABLED_ITEM_TOOLTIP = Component.translatable("item.disabled").withStyle(ChatFormatting.RED); ++ private int maxStackSize; + private int count; + private int popTime; + @Deprecated +@@ -289,11 +290,13 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods + this.count = count; + this.components = components; + this.getItem().verifyComponentsAfterLoad(this); ++ this.maxStackSize = getMaxStackSizeInternal(); // Leaf - Cache ItemStack max stack size + } + + private ItemStack(@Nullable Void unused) { + this.item = null; + this.components = new PatchedDataComponentMap(DataComponentMap.EMPTY); ++ this.maxStackSize = 1; // Leaf - Cache ItemStack max stack size - taken from ItemStack#isEmpty + } + + public static DataResult validateComponents(DataComponentMap components) { +@@ -619,9 +622,15 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods + } + + public int getMaxStackSize() { +- return this.getOrDefault(DataComponents.MAX_STACK_SIZE, Integer.valueOf(1)); ++ return maxStackSize; // Leaf - Cache ItemStack max stack size + } + ++ // Leaf start - Cache ItemStack max stack size ++ private int getMaxStackSizeInternal() { ++ return this.getOrDefault(DataComponents.MAX_STACK_SIZE, 1); ++ } ++ // Leaf end - Cache ItemStack max stack size ++ + public boolean isStackable() { + return this.getMaxStackSize() > 1 && (!this.isDamageableItem() || !this.isDamaged()); + } +@@ -1339,6 +1348,7 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods + this.components = new PatchedDataComponentMap(this.item.components()); + this.applyComponents(patch); + // Paper end - change base component prototype ++ this.maxStackSize = getMaxStackSizeInternal(); // Leaf - Cache ItemStack max stack size + } + // CraftBukkit end + +@@ -1396,6 +1406,7 @@ public final class ItemStack implements DataComponentHolder, net.caffeinemc.mods + } + // Leaf end - Lithium - equipment tracking + this.count = count; ++ maxStackSize = count <= 0 ? 1 : getMaxStackSizeInternal(); // Leaf - Cache ItemStack max stack size - taken from ItemStack#isEmpty + } + + public void limitSize(int maxSize) { diff --git a/leaf-server/gale-patches/features/0001-Leaf-Commands.patch b/leaf-server/gale-patches/features/0001-Leaf-Commands.patch new file mode 100644 index 00000000..7a96a92b --- /dev/null +++ b/leaf-server/gale-patches/features/0001-Leaf-Commands.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> +Date: Mon, 4 Nov 2024 23:07:27 -0500 +Subject: [PATCH] Leaf Commands + + +diff --git a/src/main/java/org/galemc/gale/command/GaleCommand.java b/src/main/java/org/galemc/gale/command/GaleCommand.java +index c2000206777f62592a4950d7ba96a14d15717126..a077869e1385695ac99e6ddb74aba5f4e215df08 100644 +--- a/src/main/java/org/galemc/gale/command/GaleCommand.java ++++ b/src/main/java/org/galemc/gale/command/GaleCommand.java +@@ -37,7 +37,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.RED; + public final class GaleCommand extends Command { + public static final String COMMAND_LABEL = "gale"; + public static final String BASE_PERM = GaleCommands.COMMAND_BASE_PERM + "." + COMMAND_LABEL; +- private static final Permission basePermission = new Permission(BASE_PERM, PermissionDefault.TRUE); ++ private static final Permission basePermission = new Permission(BASE_PERM, PermissionDefault.OP); // Leaf - Leaf commands + // subcommand label -> subcommand + private static final GaleSubcommand RELOAD_SUBCOMMAND = new ReloadCommand(); + private static final GaleSubcommand VERSION_SUBCOMMAND = new VersionCommand(); diff --git a/leaf-server/gale-patches/features/0001-Fix-Pufferfish-and-Purpur-patches.patch b/leaf-server/gale-patches/features/0002-Fix-Pufferfish-and-Purpur-patches.patch similarity index 100% rename from leaf-server/gale-patches/features/0001-Fix-Pufferfish-and-Purpur-patches.patch rename to leaf-server/gale-patches/features/0002-Fix-Pufferfish-and-Purpur-patches.patch diff --git a/leaf-server/gale-patches/features/0002-KeYi-Disable-arrow-despawn-counter-by-default.patch b/leaf-server/gale-patches/features/0003-KeYi-Disable-arrow-despawn-counter-by-default.patch similarity index 100% rename from leaf-server/gale-patches/features/0002-KeYi-Disable-arrow-despawn-counter-by-default.patch rename to leaf-server/gale-patches/features/0003-KeYi-Disable-arrow-despawn-counter-by-default.patch diff --git a/leaf-server/gale-patches/features/0003-Reduce-active-items-finding-hopper-nearby-check.patch b/leaf-server/gale-patches/features/0004-Reduce-active-items-finding-hopper-nearby-check.patch similarity index 100% rename from leaf-server/gale-patches/features/0003-Reduce-active-items-finding-hopper-nearby-check.patch rename to leaf-server/gale-patches/features/0004-Reduce-active-items-finding-hopper-nearby-check.patch diff --git a/leaf-server/minecraft-patches/features/0003-Leaf-Commands.patch b/leaf-server/minecraft-patches/features/0003-Leaf-Commands.patch new file mode 100644 index 00000000..d7c7a191 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0003-Leaf-Commands.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> +Date: Mon, 4 Nov 2024 23:07:27 -0500 +Subject: [PATCH] Leaf Commands + +Currently the config reload is just a simple poc, +if necessary, I will add @DoNotLoad feature in the future, like Luminol + +TODOs: +Leaf status command +Leaf config command +Leaf version command enhanced (ability to show the list of new commits based on current version) (optional) + +Leaf config +Leaf config only get config value (TODO: check whether work, and whether need to set config value back to keep the key in the config file) +Leaf config convert from toml to yaml +Leaf config v3 move to new key +... + +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index f2e24d52240a84ff7ca69ad2c8ec0d1c197467c0..26929c35cdd005fbc1838c5b10ea156b02b555a1 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -227,6 +227,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized + io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command + org.galemc.gale.command.GaleCommands.registerCommands(this); // Gale - Gale commands - register commands ++ org.dreeam.leaf.command.LeafCommands.registerCommands(this); // Leaf - Leaf commands + this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now diff --git a/leaf-server/minecraft-patches/features/0003-Pufferfish-Optimize-mob-spawning.patch b/leaf-server/minecraft-patches/features/0004-Pufferfish-Optimize-mob-spawning.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0003-Pufferfish-Optimize-mob-spawning.patch rename to leaf-server/minecraft-patches/features/0004-Pufferfish-Optimize-mob-spawning.patch index bfab3e30..0e7bdb60 100644 --- a/leaf-server/minecraft-patches/features/0003-Pufferfish-Optimize-mob-spawning.patch +++ b/leaf-server/minecraft-patches/features/0004-Pufferfish-Optimize-mob-spawning.patch @@ -34,10 +34,10 @@ index 4ba85d704ffebae38f7a76a97a182e3674730c6f..a76b67a846b12a7b3d0c41b6ac4833d4 public static S spin(Function threadFunction) { ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index f2e24d52240a84ff7ca69ad2c8ec0d1c197467c0..30dc45b2201bf7435d7f38866dfa4b5fbbf44957 100644 +index 26929c35cdd005fbc1838c5b10ea156b02b555a1..1e32d308c42194b0ae0a07e5baf12dfa43846ffe 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -362,6 +362,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -363,6 +363,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface LOGGER.info("JMX monitoring enabled"); } diff --git a/leaf-server/minecraft-patches/features/0004-Pufferfish-Dynamic-Activation-of-Brain.patch b/leaf-server/minecraft-patches/features/0005-Pufferfish-Dynamic-Activation-of-Brain.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0004-Pufferfish-Dynamic-Activation-of-Brain.patch rename to leaf-server/minecraft-patches/features/0005-Pufferfish-Dynamic-Activation-of-Brain.patch index 9e7d7b46..515b5091 100644 --- a/leaf-server/minecraft-patches/features/0004-Pufferfish-Dynamic-Activation-of-Brain.patch +++ b/leaf-server/minecraft-patches/features/0005-Pufferfish-Dynamic-Activation-of-Brain.patch @@ -73,7 +73,7 @@ index 6db99585fa47fe2d2ae6eff8efe16190dd756511..a9269356de964585028e69a3713ca64f } } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 9fe9ce0488be5eeb4f5da2f2716accc2093f6a4e..e1f5e3cc57a8c2945b7925a31bde06f6c6525726 100644 +index 8160a0cf746889b26a448f4501a112cc0654f018..b69a1a5a81cb0a8d4d01c8ab1de039e46f3426f6 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -781,6 +781,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe diff --git a/leaf-server/minecraft-patches/features/0005-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch b/leaf-server/minecraft-patches/features/0006-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch similarity index 94% rename from leaf-server/minecraft-patches/features/0005-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch rename to leaf-server/minecraft-patches/features/0006-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch index 4c6d83a9..e107aada 100644 --- a/leaf-server/minecraft-patches/features/0005-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch +++ b/leaf-server/minecraft-patches/features/0006-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/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index cc452ca41c336891473fae98b8681768c52f822d..1b74114d0833eb9ca2c854122727d4bf76a11071 100644 +index 86d78bcb6ddf23d298430406cc75e4b482538773..b66e4061d5248961f385691d0db95fb8a22f888f 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -213,11 +213,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab diff --git a/leaf-server/minecraft-patches/features/0006-Purpur-Server-Minecraft-Changes.patch b/leaf-server/minecraft-patches/features/0007-Purpur-Server-Minecraft-Changes.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0006-Purpur-Server-Minecraft-Changes.patch rename to leaf-server/minecraft-patches/features/0007-Purpur-Server-Minecraft-Changes.patch index 83070416..28517049 100644 --- a/leaf-server/minecraft-patches/features/0006-Purpur-Server-Minecraft-Changes.patch +++ b/leaf-server/minecraft-patches/features/0007-Purpur-Server-Minecraft-Changes.patch @@ -490,7 +490,7 @@ index 8b7af734ca4ed3cafa810460b2cea6c1e6342a69..c394e4ea9b066895a8ad370615383a4a ItemEntity itemEntity = serverPlayer.drop(itemStack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event if (itemEntity != null) { diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 30dc45b2201bf7435d7f38866dfa4b5fbbf44957..6e7ac9128378586160230bd33462edb7d6880154 100644 +index 1e32d308c42194b0ae0a07e5baf12dfa43846ffe..4027873ebfb71d73d9c6c9d00602f11ac5cbc78c 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java @@ -106,6 +106,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @@ -517,8 +517,8 @@ index 30dc45b2201bf7435d7f38866dfa4b5fbbf44957..6e7ac9128378586160230bd33462edb7 // Paper start - initialize global and world-defaults configuration this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); -@@ -229,6 +239,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - org.galemc.gale.command.GaleCommands.registerCommands(this); // Gale - Gale commands - register commands +@@ -230,6 +240,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + org.dreeam.leaf.command.LeafCommands.registerCommands(this); // Leaf - Leaf commands this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + /*// Purpur start - Purpur config files // Purpur - Configurable void damage height and damage @@ -533,7 +533,7 @@ index 30dc45b2201bf7435d7f38866dfa4b5fbbf44957..6e7ac9128378586160230bd33462edb7 com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now // Gale start - Pufferfish - SIMD support -@@ -283,6 +302,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -284,6 +303,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface if (true) throw new IllegalStateException("Failed to bind to port", var10); // Paper - Propagate failed to bind to port error return false; } @@ -564,7 +564,7 @@ index 30dc45b2201bf7435d7f38866dfa4b5fbbf44957..6e7ac9128378586160230bd33462edb7 // CraftBukkit start // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up -@@ -364,6 +407,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -365,6 +408,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) mobSpawnExecutor.start(); // Pufferfish @@ -724,7 +724,7 @@ index f262a7c5ae4e7d56f16f5c0f4f145a2e428abbe4..614c7d9f673c926562acc8fa3b378862 private JComponent buildOnboardingPanel() { String onboardingLink = "https://docs.papermc.io/paper/next-steps"; diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index e1f5e3cc57a8c2945b7925a31bde06f6c6525726..cb8556fcf50293341cb090616e1e25e04d2eb5d8 100644 +index b69a1a5a81cb0a8d4d01c8ab1de039e46f3426f6..a1cbdab00636ee08ffad5726a7750e31d75ed44d 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -205,6 +205,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe diff --git a/leaf-server/minecraft-patches/features/0007-Fix-Pufferfish-and-Purpur-patches.patch b/leaf-server/minecraft-patches/features/0008-Fix-Pufferfish-and-Purpur-patches.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0007-Fix-Pufferfish-and-Purpur-patches.patch rename to leaf-server/minecraft-patches/features/0008-Fix-Pufferfish-and-Purpur-patches.patch diff --git a/leaf-server/minecraft-patches/features/0008-Purpur-Configurable-server-mod-name.patch b/leaf-server/minecraft-patches/features/0009-Purpur-Configurable-server-mod-name.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0008-Purpur-Configurable-server-mod-name.patch rename to leaf-server/minecraft-patches/features/0009-Purpur-Configurable-server-mod-name.patch diff --git a/leaf-server/minecraft-patches/features/0009-Configurable-server-GUI-name.patch b/leaf-server/minecraft-patches/features/0010-Configurable-server-GUI-name.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0009-Configurable-server-GUI-name.patch rename to leaf-server/minecraft-patches/features/0010-Configurable-server-GUI-name.patch diff --git a/leaf-server/minecraft-patches/features/0010-Remove-vanilla-username-check.patch b/leaf-server/minecraft-patches/features/0011-Remove-vanilla-username-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0010-Remove-vanilla-username-check.patch rename to leaf-server/minecraft-patches/features/0011-Remove-vanilla-username-check.patch diff --git a/leaf-server/minecraft-patches/features/0011-Remove-Spigot-check-for-broken-BungeeCord-configurat.patch b/leaf-server/minecraft-patches/features/0012-Remove-Spigot-check-for-broken-BungeeCord-configurat.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0011-Remove-Spigot-check-for-broken-BungeeCord-configurat.patch rename to leaf-server/minecraft-patches/features/0012-Remove-Spigot-check-for-broken-BungeeCord-configurat.patch diff --git a/leaf-server/minecraft-patches/features/0012-Remove-UseItemOnPacket-Too-Far-check.patch b/leaf-server/minecraft-patches/features/0013-Remove-UseItemOnPacket-Too-Far-check.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0012-Remove-UseItemOnPacket-Too-Far-check.patch rename to leaf-server/minecraft-patches/features/0013-Remove-UseItemOnPacket-Too-Far-check.patch index c3b0fbf1..75a4940c 100644 --- a/leaf-server/minecraft-patches/features/0012-Remove-UseItemOnPacket-Too-Far-check.patch +++ b/leaf-server/minecraft-patches/features/0013-Remove-UseItemOnPacket-Too-Far-check.patch @@ -7,7 +7,7 @@ This Check is added in 1.17.x -> 1.18.x that updated by Mojang. By removing this check, it gives ability for hackers to use some modules of hack clients. diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index e3fa94538ec5756e39ca55ba2216971d499215cc..9706e382ad2b597a04ff637881c3b5d32f26d281 100644 +index ffe2f8577ec42c9f071d72a191e8fefc6ba67f0e..e77b62d17df2acfa32c310bdba8de1bcf5aab9c6 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2005,8 +2005,13 @@ public class ServerGamePacketListenerImpl diff --git a/leaf-server/minecraft-patches/features/0013-Remove-change-non-editable-sign-warning.patch b/leaf-server/minecraft-patches/features/0014-Remove-change-non-editable-sign-warning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0013-Remove-change-non-editable-sign-warning.patch rename to leaf-server/minecraft-patches/features/0014-Remove-change-non-editable-sign-warning.patch diff --git a/leaf-server/minecraft-patches/features/0014-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch b/leaf-server/minecraft-patches/features/0015-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0014-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch rename to leaf-server/minecraft-patches/features/0015-KeYi-Add-an-option-for-spigot-item-merging-mechanism.patch diff --git a/leaf-server/minecraft-patches/features/0015-Carpet-Fixes-Optimized-getBiome-method.patch b/leaf-server/minecraft-patches/features/0016-Carpet-Fixes-Optimized-getBiome-method.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0015-Carpet-Fixes-Optimized-getBiome-method.patch rename to leaf-server/minecraft-patches/features/0016-Carpet-Fixes-Optimized-getBiome-method.patch diff --git a/leaf-server/minecraft-patches/features/0016-Carpet-Fixes-Use-optimized-RecipeManager.patch b/leaf-server/minecraft-patches/features/0017-Carpet-Fixes-Use-optimized-RecipeManager.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0016-Carpet-Fixes-Use-optimized-RecipeManager.patch rename to leaf-server/minecraft-patches/features/0017-Carpet-Fixes-Use-optimized-RecipeManager.patch diff --git a/leaf-server/minecraft-patches/features/0017-Akarin-Save-Json-list-asynchronously.patch b/leaf-server/minecraft-patches/features/0018-Akarin-Save-Json-list-asynchronously.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0017-Akarin-Save-Json-list-asynchronously.patch rename to leaf-server/minecraft-patches/features/0018-Akarin-Save-Json-list-asynchronously.patch diff --git a/leaf-server/minecraft-patches/features/0018-Slice-Smooth-Teleports.patch b/leaf-server/minecraft-patches/features/0019-Slice-Smooth-Teleports.patch similarity index 94% rename from leaf-server/minecraft-patches/features/0018-Slice-Smooth-Teleports.patch rename to leaf-server/minecraft-patches/features/0019-Slice-Smooth-Teleports.patch index 97a53b25..da250278 100644 --- a/leaf-server/minecraft-patches/features/0018-Slice-Smooth-Teleports.patch +++ b/leaf-server/minecraft-patches/features/0019-Slice-Smooth-Teleports.patch @@ -9,7 +9,7 @@ Original project: https://github.com/Cryptite/Slice Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 1173deb1aeb5abc225e7b5914cc3c325afdfab16..00c7afd995d179efe1c96fb6daf342b6b357fa65 100644 +index 31fdda8a62d80f8e48914c8bed0d9cf1bb8bbffb..622257dbbe572de33e15abef9055016268730261 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java @@ -396,6 +396,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc @@ -21,7 +21,7 @@ index 1173deb1aeb5abc225e7b5914cc3c325afdfab16..00c7afd995d179efe1c96fb6daf342b6 // Paper start - rewrite chunk system private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index b4f2b794ca0c6e04da0355e02c19493c892ebccf..c334ce5c688ad362ffc96bd90d32c676acd50d4d 100644 +index 08a028ac0892552f7e6b95985233c1e625e11e44..ef189bdd6c52c3f062774a6e9ae73a186d1d8346 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -798,11 +798,11 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0019-Parchment-Make-FixLight-use-action-bar.patch b/leaf-server/minecraft-patches/features/0020-Parchment-Make-FixLight-use-action-bar.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0019-Parchment-Make-FixLight-use-action-bar.patch rename to leaf-server/minecraft-patches/features/0020-Parchment-Make-FixLight-use-action-bar.patch diff --git a/leaf-server/minecraft-patches/features/0020-Leaves-Protocol-Core.patch b/leaf-server/minecraft-patches/features/0021-Leaves-Protocol-Core.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0020-Leaves-Protocol-Core.patch rename to leaf-server/minecraft-patches/features/0021-Leaves-Protocol-Core.patch diff --git a/leaf-server/minecraft-patches/features/0021-Leaves-Jade-Protocol.patch b/leaf-server/minecraft-patches/features/0022-Leaves-Jade-Protocol.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0021-Leaves-Jade-Protocol.patch rename to leaf-server/minecraft-patches/features/0022-Leaves-Jade-Protocol.patch diff --git a/leaf-server/minecraft-patches/features/0022-Leaves-Xaero-Map-Protocol.patch b/leaf-server/minecraft-patches/features/0023-Leaves-Xaero-Map-Protocol.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0022-Leaves-Xaero-Map-Protocol.patch rename to leaf-server/minecraft-patches/features/0023-Leaves-Xaero-Map-Protocol.patch index 3853a19a..3ec4ef54 100644 --- a/leaf-server/minecraft-patches/features/0022-Leaves-Xaero-Map-Protocol.patch +++ b/leaf-server/minecraft-patches/features/0023-Leaves-Xaero-Map-Protocol.patch @@ -9,7 +9,7 @@ Original project: https://github.com/LeavesMC/Leaves This patch is Powered by Xaero Map diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 0e81a445a4f960eab5c873bc16f79a9ebfab0122..03bf654aaf1b4f7df9608ee1ad99230f7aa507f9 100644 +index 924faf76763588fb41b8aee53236ccb05b1239b1..e3d09d5f4efb32bb276e001e5ee747a775b502ee 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -1222,6 +1222,7 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0023-Leaves-Syncmatica-Protocol.patch b/leaf-server/minecraft-patches/features/0024-Leaves-Syncmatica-Protocol.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0023-Leaves-Syncmatica-Protocol.patch rename to leaf-server/minecraft-patches/features/0024-Leaves-Syncmatica-Protocol.patch index 1dc4ae46..d6baf1c8 100644 --- a/leaf-server/minecraft-patches/features/0023-Leaves-Syncmatica-Protocol.patch +++ b/leaf-server/minecraft-patches/features/0024-Leaves-Syncmatica-Protocol.patch @@ -9,7 +9,7 @@ Original project: https://github.com/LeavesMC/Leaves This patch is Powered by Syncmatica (https://github.com/End-Tech/syncmatica) diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index c58a231183655e2910748a5ecdf3b2ce0d7b00a1..ffb8d4c5b894e130d7e330459e9797356db2a262 100644 +index e77b62d17df2acfa32c310bdba8de1bcf5aab9c6..1e834d51cc57255fd6075c25b05e2b3816bd501b 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -324,6 +324,7 @@ public class ServerGamePacketListenerImpl diff --git a/leaf-server/minecraft-patches/features/0024-Leaves-Replay-Mod-API.patch b/leaf-server/minecraft-patches/features/0025-Leaves-Replay-Mod-API.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0024-Leaves-Replay-Mod-API.patch rename to leaf-server/minecraft-patches/features/0025-Leaves-Replay-Mod-API.patch index 4296ceee..962c2b72 100644 --- a/leaf-server/minecraft-patches/features/0024-Leaves-Replay-Mod-API.patch +++ b/leaf-server/minecraft-patches/features/0025-Leaves-Replay-Mod-API.patch @@ -134,7 +134,7 @@ index 5c0a04db38821dbb0cba2bb6f0787f113d167efd..cd153db93f709c3142942fac88ae3ca2 .filter(player -> !playerList.isOp(player.getGameProfile())) .map(player -> player.getGameProfile().getName()), diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index cb8556fcf50293341cb090616e1e25e04d2eb5d8..d23e367b2e4374764dc059232c136a99db1cc9c6 100644 +index a1cbdab00636ee08ffad5726a7750e31d75ed44d..01836d12c5a4603d04bad192657540e0ae5a1ec0 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -216,6 +216,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe diff --git a/leaf-server/minecraft-patches/features/0025-Petal-Async-Pathfinding.patch b/leaf-server/minecraft-patches/features/0026-Petal-Async-Pathfinding.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0025-Petal-Async-Pathfinding.patch rename to leaf-server/minecraft-patches/features/0026-Petal-Async-Pathfinding.patch diff --git a/leaf-server/minecraft-patches/features/0026-Petal-reduce-work-done-by-game-event-system.patch b/leaf-server/minecraft-patches/features/0027-Petal-reduce-work-done-by-game-event-system.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0026-Petal-reduce-work-done-by-game-event-system.patch rename to leaf-server/minecraft-patches/features/0027-Petal-reduce-work-done-by-game-event-system.patch diff --git a/leaf-server/minecraft-patches/features/0027-Reduce-canSee-work.patch b/leaf-server/minecraft-patches/features/0028-Reduce-canSee-work.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0027-Reduce-canSee-work.patch rename to leaf-server/minecraft-patches/features/0028-Reduce-canSee-work.patch diff --git a/leaf-server/minecraft-patches/features/0028-Fix-sprint-glitch.patch b/leaf-server/minecraft-patches/features/0029-Fix-sprint-glitch.patch similarity index 90% rename from leaf-server/minecraft-patches/features/0028-Fix-sprint-glitch.patch rename to leaf-server/minecraft-patches/features/0029-Fix-sprint-glitch.patch index caf10d51..a772263c 100644 --- a/leaf-server/minecraft-patches/features/0028-Fix-sprint-glitch.patch +++ b/leaf-server/minecraft-patches/features/0029-Fix-sprint-glitch.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix sprint glitch diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 4fb6102c8ef930de80356c66397ca2167b1d0174..c7f58236400dbb9d26cf4a5b83b3a9202b10471d 100644 +index c9870c7ce29e240d60b5b29bdf4deba85023be60..ca1d8c9ea018368cc85da46185aee71df8d48ce0 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -1379,7 +1379,8 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0029-Configurable-movement-speed-of-more-entities.patch b/leaf-server/minecraft-patches/features/0030-Configurable-movement-speed-of-more-entities.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0029-Configurable-movement-speed-of-more-entities.patch rename to leaf-server/minecraft-patches/features/0030-Configurable-movement-speed-of-more-entities.patch diff --git a/leaf-server/minecraft-patches/features/0030-Faster-sequencing-of-futures-for-chunk-structure-gen.patch b/leaf-server/minecraft-patches/features/0031-Faster-sequencing-of-futures-for-chunk-structure-gen.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0030-Faster-sequencing-of-futures-for-chunk-structure-gen.patch rename to leaf-server/minecraft-patches/features/0031-Faster-sequencing-of-futures-for-chunk-structure-gen.patch diff --git a/leaf-server/minecraft-patches/features/0031-Reduce-active-items-finding-hopper-nearby-check.patch b/leaf-server/minecraft-patches/features/0032-Reduce-active-items-finding-hopper-nearby-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0031-Reduce-active-items-finding-hopper-nearby-check.patch rename to leaf-server/minecraft-patches/features/0032-Reduce-active-items-finding-hopper-nearby-check.patch diff --git a/leaf-server/minecraft-patches/features/0032-Linear-region-file-format.patch b/leaf-server/minecraft-patches/features/0033-Linear-region-file-format.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0032-Linear-region-file-format.patch rename to leaf-server/minecraft-patches/features/0033-Linear-region-file-format.patch diff --git a/leaf-server/minecraft-patches/features/0033-Plazma-Add-some-missing-Pufferfish-configurations.patch b/leaf-server/minecraft-patches/features/0034-Plazma-Add-some-missing-Pufferfish-configurations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0033-Plazma-Add-some-missing-Pufferfish-configurations.patch rename to leaf-server/minecraft-patches/features/0034-Plazma-Add-some-missing-Pufferfish-configurations.patch diff --git a/leaf-server/minecraft-patches/features/0034-Plazma-Add-missing-purpur-configuration-options.patch b/leaf-server/minecraft-patches/features/0035-Plazma-Add-missing-purpur-configuration-options.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0034-Plazma-Add-missing-purpur-configuration-options.patch rename to leaf-server/minecraft-patches/features/0035-Plazma-Add-missing-purpur-configuration-options.patch diff --git a/leaf-server/minecraft-patches/features/0035-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch b/leaf-server/minecraft-patches/features/0036-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0035-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch rename to leaf-server/minecraft-patches/features/0036-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch diff --git a/leaf-server/minecraft-patches/features/0036-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch b/leaf-server/minecraft-patches/features/0037-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0036-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch rename to leaf-server/minecraft-patches/features/0037-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch diff --git a/leaf-server/minecraft-patches/features/0037-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch b/leaf-server/minecraft-patches/features/0038-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0037-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch rename to leaf-server/minecraft-patches/features/0038-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch diff --git a/leaf-server/minecraft-patches/features/0038-SparklyPaper-Optimize-canSee-checks.patch b/leaf-server/minecraft-patches/features/0039-SparklyPaper-Optimize-canSee-checks.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0038-SparklyPaper-Optimize-canSee-checks.patch rename to leaf-server/minecraft-patches/features/0039-SparklyPaper-Optimize-canSee-checks.patch diff --git a/leaf-server/minecraft-patches/features/0039-SparklyPaper-Allow-throttling-hopper-checks-if-the-t.patch b/leaf-server/minecraft-patches/features/0040-SparklyPaper-Allow-throttling-hopper-checks-if-the-t.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0039-SparklyPaper-Allow-throttling-hopper-checks-if-the-t.patch rename to leaf-server/minecraft-patches/features/0040-SparklyPaper-Allow-throttling-hopper-checks-if-the-t.patch diff --git a/leaf-server/minecraft-patches/features/0040-Polpot-Make-egg-and-snowball-can-knockback-player.patch b/leaf-server/minecraft-patches/features/0041-Polpot-Make-egg-and-snowball-can-knockback-player.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0040-Polpot-Make-egg-and-snowball-can-knockback-player.patch rename to leaf-server/minecraft-patches/features/0041-Polpot-Make-egg-and-snowball-can-knockback-player.patch diff --git a/leaf-server/minecraft-patches/features/0041-Redirect-vanilla-getProfiler-to-inactive-in-PathNavi.patch b/leaf-server/minecraft-patches/features/0042-Redirect-vanilla-getProfiler-to-inactive-in-PathNavi.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0041-Redirect-vanilla-getProfiler-to-inactive-in-PathNavi.patch rename to leaf-server/minecraft-patches/features/0042-Redirect-vanilla-getProfiler-to-inactive-in-PathNavi.patch diff --git a/leaf-server/minecraft-patches/features/0042-Remove-useless-creating-stats-json-bases-on-player-n.patch b/leaf-server/minecraft-patches/features/0043-Remove-useless-creating-stats-json-bases-on-player-n.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0042-Remove-useless-creating-stats-json-bases-on-player-n.patch rename to leaf-server/minecraft-patches/features/0043-Remove-useless-creating-stats-json-bases-on-player-n.patch index dbb97070..e96778ac 100644 --- a/leaf-server/minecraft-patches/features/0042-Remove-useless-creating-stats-json-bases-on-player-n.patch +++ b/leaf-server/minecraft-patches/features/0043-Remove-useless-creating-stats-json-bases-on-player-n.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove useless creating stats json bases on player name logic diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 86ce80765eb7645533806f730b15557f8ea6a9a2..29275d0fd6b3d320d5e444fb32aa4004f4370720 100644 +index 78b15d750d75e5d4c2318a3a18e83afdd5f4fbe1..3d6efee3469302f37e60a9013f6a3adf970a580a 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -1556,6 +1556,8 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0043-Improve-Purpur-AFK-system.patch b/leaf-server/minecraft-patches/features/0044-Improve-Purpur-AFK-system.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0043-Improve-Purpur-AFK-system.patch rename to leaf-server/minecraft-patches/features/0044-Improve-Purpur-AFK-system.patch diff --git a/leaf-server/minecraft-patches/features/0044-Virtual-thread-for-chat-executor.patch b/leaf-server/minecraft-patches/features/0045-Virtual-thread-for-chat-executor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0044-Virtual-thread-for-chat-executor.patch rename to leaf-server/minecraft-patches/features/0045-Virtual-thread-for-chat-executor.patch diff --git a/leaf-server/minecraft-patches/features/0045-Virtual-thread-for-user-authenticator.patch b/leaf-server/minecraft-patches/features/0046-Virtual-thread-for-user-authenticator.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0045-Virtual-thread-for-user-authenticator.patch rename to leaf-server/minecraft-patches/features/0046-Virtual-thread-for-user-authenticator.patch diff --git a/leaf-server/minecraft-patches/features/0046-Mirai-Configurable-chat-message-signatures.patch b/leaf-server/minecraft-patches/features/0047-Mirai-Configurable-chat-message-signatures.patch similarity index 97% rename from leaf-server/minecraft-patches/features/0046-Mirai-Configurable-chat-message-signatures.patch rename to leaf-server/minecraft-patches/features/0047-Mirai-Configurable-chat-message-signatures.patch index ee726040..2f9fe613 100644 --- a/leaf-server/minecraft-patches/features/0046-Mirai-Configurable-chat-message-signatures.patch +++ b/leaf-server/minecraft-patches/features/0047-Mirai-Configurable-chat-message-signatures.patch @@ -91,10 +91,10 @@ index 30bd254542d631676494f349ff3f44f52d54ab2f..63e6411d8bac1629e143cc620fe35dba public record Favicon(byte[] iconBytes) { diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 6e7ac9128378586160230bd33462edb7d6880154..92eda3826518cf54891cccb46eed9e0d3da165ba 100644 +index 4027873ebfb71d73d9c6c9d00602f11ac5cbc78c..e3c395ff665d741136ec868a889042390bd25f73 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -667,6 +667,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -668,6 +668,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public boolean enforceSecureProfile() { @@ -138,7 +138,7 @@ index ee8cdd532b73180cb484fcc37c36f09c40faacda..becadda1642c1b9342f2fdff1fc062a2 if (packet == null || this.processedDisconnect) { // Spigot return; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 2d8c20ddd675173e9ea5734cfde6687ac042e01d..739835ce8c02e485abbe8de2e02d19ce9b3f44f9 100644 +index 03f3e1de0c5df76a4d14c5dc62647ecfc2b17dce..fdda542612ccdd769647b9448fce9d8c465d1e02 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -1516,7 +1516,7 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0047-Cache-player-profileResult.patch b/leaf-server/minecraft-patches/features/0048-Cache-player-profileResult.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0047-Cache-player-profileResult.patch rename to leaf-server/minecraft-patches/features/0048-Cache-player-profileResult.patch diff --git a/leaf-server/minecraft-patches/features/0048-Matter-Secure-Seed.patch b/leaf-server/minecraft-patches/features/0049-Matter-Secure-Seed.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0048-Matter-Secure-Seed.patch rename to leaf-server/minecraft-patches/features/0049-Matter-Secure-Seed.patch index a955e3ec..dc6696e9 100644 --- a/leaf-server/minecraft-patches/features/0048-Matter-Secure-Seed.patch +++ b/leaf-server/minecraft-patches/features/0049-Matter-Secure-Seed.patch @@ -48,7 +48,7 @@ index 90a8494840faa0e7f605c904c657a953be64b17d..4070a6eb52f6097e38c2d85c231d39ea } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 69a807ccda1ec5334316863604aa3192065d16a1..40b6b5e4a1f73ee447ff0ee192d5d8ba5045f286 100644 +index 01836d12c5a4603d04bad192657540e0ae5a1ec0..8c739c7a168c84b7735288da3c10a6c97408a05e 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -633,6 +633,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe diff --git a/leaf-server/minecraft-patches/features/0049-Matter-Secure-Seed-command.patch b/leaf-server/minecraft-patches/features/0050-Matter-Secure-Seed-command.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0049-Matter-Secure-Seed-command.patch rename to leaf-server/minecraft-patches/features/0050-Matter-Secure-Seed-command.patch diff --git a/leaf-server/minecraft-patches/features/0050-Faster-random-generator.patch b/leaf-server/minecraft-patches/features/0051-Faster-random-generator.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0050-Faster-random-generator.patch rename to leaf-server/minecraft-patches/features/0051-Faster-random-generator.patch index 9934fc97..1ae87ae4 100644 --- a/leaf-server/minecraft-patches/features/0050-Faster-random-generator.patch +++ b/leaf-server/minecraft-patches/features/0051-Faster-random-generator.patch @@ -27,7 +27,7 @@ index 4070a6eb52f6097e38c2d85c231d39ea3785cf46..bb76dbf98979fdc725676c98dafe64ea final ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)levelChunk).moonrise$getChunkAndHolder().holder()) .moonrise$getRealChunkHolder().holderData; diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 40b6b5e4a1f73ee447ff0ee192d5d8ba5045f286..f9e335c86684969b744a7d7c1d96458e830bbd35 100644 +index 8c739c7a168c84b7735288da3c10a6c97408a05e..dd27e6b47233776fdec8860391be772029c987aa 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -902,7 +902,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -89,7 +89,7 @@ index 98a54bc4de251014342cda6d0951b7fea79ce553..6d56134cc9ed9d73104ae77b1a0baa5a RandomSource fork(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 761b3806ddec0675935dc2e24d36e4b221c53c9b..8bb2abb01f1af34d6829cbbf759a425d871f3e3f 100644 +index b775996b6dbc09c95c83a542da12dee7bf65bf4c..970420761b2c3b82a60479c556e76e385bf211e1 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -143,7 +143,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0051-Don-t-save-primed-tnt-entity.patch b/leaf-server/minecraft-patches/features/0052-Don-t-save-primed-tnt-entity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0051-Don-t-save-primed-tnt-entity.patch rename to leaf-server/minecraft-patches/features/0052-Don-t-save-primed-tnt-entity.patch diff --git a/leaf-server/minecraft-patches/features/0052-Don-t-save-falling-block-entity.patch b/leaf-server/minecraft-patches/features/0053-Don-t-save-falling-block-entity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0052-Don-t-save-falling-block-entity.patch rename to leaf-server/minecraft-patches/features/0053-Don-t-save-falling-block-entity.patch diff --git a/leaf-server/minecraft-patches/features/0053-Configurable-connection-message.patch b/leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0053-Configurable-connection-message.patch rename to leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch index b17436c6..69cebad8 100644 --- a/leaf-server/minecraft-patches/features/0053-Configurable-connection-message.patch +++ b/leaf-server/minecraft-patches/features/0054-Configurable-connection-message.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable connection message diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 739835ce8c02e485abbe8de2e02d19ce9b3f44f9..9aa924cb58ea6d50572d67f628d35eebb809ae72 100644 +index fdda542612ccdd769647b9448fce9d8c465d1e02..c247b1dd9504b10ea73ec3bd96d2bf9e48fabf3e 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -434,7 +434,7 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0054-Configurable-unknown-command-message.patch b/leaf-server/minecraft-patches/features/0055-Configurable-unknown-command-message.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0054-Configurable-unknown-command-message.patch rename to leaf-server/minecraft-patches/features/0055-Configurable-unknown-command-message.patch diff --git a/leaf-server/minecraft-patches/features/0055-Remove-stream-in-BlockBehaviour-cache-blockstate.patch b/leaf-server/minecraft-patches/features/0056-Remove-stream-in-BlockBehaviour-cache-blockstate.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0055-Remove-stream-in-BlockBehaviour-cache-blockstate.patch rename to leaf-server/minecraft-patches/features/0056-Remove-stream-in-BlockBehaviour-cache-blockstate.patch diff --git a/leaf-server/minecraft-patches/features/0056-Remove-stream-in-entity-visible-effects-filter.patch b/leaf-server/minecraft-patches/features/0057-Remove-stream-in-entity-visible-effects-filter.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0056-Remove-stream-in-entity-visible-effects-filter.patch rename to leaf-server/minecraft-patches/features/0057-Remove-stream-in-entity-visible-effects-filter.patch index 17d0b8cb..0e7a3551 100644 --- a/leaf-server/minecraft-patches/features/0056-Remove-stream-in-entity-visible-effects-filter.patch +++ b/leaf-server/minecraft-patches/features/0057-Remove-stream-in-entity-visible-effects-filter.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove stream in entity visible effects filter diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index c7f58236400dbb9d26cf4a5b83b3a9202b10471d..7bdf6db0dd0e72d798de301d1acd190216dc8bc7 100644 +index ca1d8c9ea018368cc85da46185aee71df8d48ce0..a307ee08f12cb21d17cfbaf969db7c46f10040fb 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -988,12 +988,15 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0057-Remove-stream-and-double-iteration-in-enough-deep-sl.patch b/leaf-server/minecraft-patches/features/0058-Remove-stream-and-double-iteration-in-enough-deep-sl.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0057-Remove-stream-and-double-iteration-in-enough-deep-sl.patch rename to leaf-server/minecraft-patches/features/0058-Remove-stream-and-double-iteration-in-enough-deep-sl.patch diff --git a/leaf-server/minecraft-patches/features/0058-Remove-stream-in-trial-spawner-ticking.patch b/leaf-server/minecraft-patches/features/0059-Remove-stream-in-trial-spawner-ticking.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0058-Remove-stream-in-trial-spawner-ticking.patch rename to leaf-server/minecraft-patches/features/0059-Remove-stream-in-trial-spawner-ticking.patch diff --git a/leaf-server/minecraft-patches/features/0059-Remove-stream-in-Brain.patch b/leaf-server/minecraft-patches/features/0060-Remove-stream-in-Brain.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0059-Remove-stream-in-Brain.patch rename to leaf-server/minecraft-patches/features/0060-Remove-stream-in-Brain.patch diff --git a/leaf-server/minecraft-patches/features/0060-Remove-stream-in-BehaviorUtils.patch b/leaf-server/minecraft-patches/features/0061-Remove-stream-in-BehaviorUtils.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0060-Remove-stream-in-BehaviorUtils.patch rename to leaf-server/minecraft-patches/features/0061-Remove-stream-in-BehaviorUtils.patch diff --git a/leaf-server/minecraft-patches/features/0061-Remove-stream-in-YieldJobSite.patch b/leaf-server/minecraft-patches/features/0062-Remove-stream-in-YieldJobSite.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0061-Remove-stream-in-YieldJobSite.patch rename to leaf-server/minecraft-patches/features/0062-Remove-stream-in-YieldJobSite.patch diff --git a/leaf-server/minecraft-patches/features/0062-Remove-stream-in-PlayerSensor.patch b/leaf-server/minecraft-patches/features/0063-Remove-stream-in-PlayerSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0062-Remove-stream-in-PlayerSensor.patch rename to leaf-server/minecraft-patches/features/0063-Remove-stream-in-PlayerSensor.patch diff --git a/leaf-server/minecraft-patches/features/0063-Remove-stream-in-GolemSensor.patch b/leaf-server/minecraft-patches/features/0064-Remove-stream-in-GolemSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0063-Remove-stream-in-GolemSensor.patch rename to leaf-server/minecraft-patches/features/0064-Remove-stream-in-GolemSensor.patch diff --git a/leaf-server/minecraft-patches/features/0064-Remove-stream-in-GateBehavior.patch b/leaf-server/minecraft-patches/features/0065-Remove-stream-in-GateBehavior.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0064-Remove-stream-in-GateBehavior.patch rename to leaf-server/minecraft-patches/features/0065-Remove-stream-in-GateBehavior.patch diff --git a/leaf-server/minecraft-patches/features/0065-Remove-stream-in-updateFluidOnEyes.patch b/leaf-server/minecraft-patches/features/0066-Remove-stream-in-updateFluidOnEyes.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0065-Remove-stream-in-updateFluidOnEyes.patch rename to leaf-server/minecraft-patches/features/0066-Remove-stream-in-updateFluidOnEyes.patch diff --git a/leaf-server/minecraft-patches/features/0066-Remove-stream-in-matchingSlot.patch b/leaf-server/minecraft-patches/features/0067-Remove-stream-in-matchingSlot.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0066-Remove-stream-in-matchingSlot.patch rename to leaf-server/minecraft-patches/features/0067-Remove-stream-in-matchingSlot.patch diff --git a/leaf-server/minecraft-patches/features/0067-Replace-Entity-active-effects-map-with-optimized-col.patch b/leaf-server/minecraft-patches/features/0068-Replace-Entity-active-effects-map-with-optimized-col.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0067-Replace-Entity-active-effects-map-with-optimized-col.patch rename to leaf-server/minecraft-patches/features/0068-Replace-Entity-active-effects-map-with-optimized-col.patch index e77ec39f..237d0012 100644 --- a/leaf-server/minecraft-patches/features/0067-Replace-Entity-active-effects-map-with-optimized-col.patch +++ b/leaf-server/minecraft-patches/features/0068-Replace-Entity-active-effects-map-with-optimized-col.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Replace Entity active effects map with optimized collection Dreeam TODO: check this diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 7bdf6db0dd0e72d798de301d1acd190216dc8bc7..54b7ae45de54dc335a88a8c48e5212e7e663bc54 100644 +index a307ee08f12cb21d17cfbaf969db7c46f10040fb..4f0da30fa659ecabdfbd1d17e50888c32501b6e7 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -211,6 +211,10 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0068-Replace-criterion-map-with-optimized-collection.patch b/leaf-server/minecraft-patches/features/0069-Replace-criterion-map-with-optimized-collection.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0068-Replace-criterion-map-with-optimized-collection.patch rename to leaf-server/minecraft-patches/features/0069-Replace-criterion-map-with-optimized-collection.patch diff --git a/leaf-server/minecraft-patches/features/0069-Replace-brain-maps-with-optimized-collection.patch b/leaf-server/minecraft-patches/features/0070-Replace-brain-maps-with-optimized-collection.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0069-Replace-brain-maps-with-optimized-collection.patch rename to leaf-server/minecraft-patches/features/0070-Replace-brain-maps-with-optimized-collection.patch diff --git a/leaf-server/minecraft-patches/features/0070-Reduce-worldgen-allocations.patch b/leaf-server/minecraft-patches/features/0071-Reduce-worldgen-allocations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0070-Reduce-worldgen-allocations.patch rename to leaf-server/minecraft-patches/features/0071-Reduce-worldgen-allocations.patch diff --git a/leaf-server/minecraft-patches/features/0071-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch b/leaf-server/minecraft-patches/features/0072-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0071-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch rename to leaf-server/minecraft-patches/features/0072-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch index 4ccf9dcd..345b5ee3 100644 --- a/leaf-server/minecraft-patches/features/0071-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch +++ b/leaf-server/minecraft-patches/features/0072-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Use caffeine cache for kickPermission instead of using diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 44f2182b5d78b0e51e8f5253fa9c89ea687b72df..7b493b28f57977c92c4a45049cedcb0cedbe8ae9 100644 +index 4af5f13eb9a0c76d037074fa0fd5c1b2061dc59b..9960b26d5f5d931bacea3fb5c8fbe14dddd8d0e2 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -328,17 +328,12 @@ public class ServerGamePacketListenerImpl diff --git a/leaf-server/minecraft-patches/features/0072-Do-not-place-player-if-the-server-is-full.patch b/leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0072-Do-not-place-player-if-the-server-is-full.patch rename to leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch index 40c2c8be..698b73a2 100644 --- a/leaf-server/minecraft-patches/features/0072-Do-not-place-player-if-the-server-is-full.patch +++ b/leaf-server/minecraft-patches/features/0073-Do-not-place-player-if-the-server-is-full.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Do not place player if the server is full Fix https://github.com/PaperMC/Paper/issues/10668 diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 9aa924cb58ea6d50572d67f628d35eebb809ae72..6327d508252b35fcbd2daebad078f00d44291c6e 100644 +index c247b1dd9504b10ea73ec3bd96d2bf9e48fabf3e..119ffa8f10bdcc27ff4b7dc4e1ef18212607c4bf 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -341,6 +341,13 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0073-Fix-MC-65198.patch b/leaf-server/minecraft-patches/features/0074-Fix-MC-65198.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0073-Fix-MC-65198.patch rename to leaf-server/minecraft-patches/features/0074-Fix-MC-65198.patch diff --git a/leaf-server/minecraft-patches/features/0074-Fix-MC-200418.patch b/leaf-server/minecraft-patches/features/0075-Fix-MC-200418.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0074-Fix-MC-200418.patch rename to leaf-server/minecraft-patches/features/0075-Fix-MC-200418.patch diff --git a/leaf-server/minecraft-patches/features/0075-Fix-MC-119417.patch b/leaf-server/minecraft-patches/features/0076-Fix-MC-119417.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0075-Fix-MC-119417.patch rename to leaf-server/minecraft-patches/features/0076-Fix-MC-119417.patch diff --git a/leaf-server/minecraft-patches/features/0076-Fix-MC-223153.patch b/leaf-server/minecraft-patches/features/0077-Fix-MC-223153.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0076-Fix-MC-223153.patch rename to leaf-server/minecraft-patches/features/0077-Fix-MC-223153.patch diff --git a/leaf-server/minecraft-patches/features/0077-Configurable-player-knockback-zombie.patch b/leaf-server/minecraft-patches/features/0078-Configurable-player-knockback-zombie.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0077-Configurable-player-knockback-zombie.patch rename to leaf-server/minecraft-patches/features/0078-Configurable-player-knockback-zombie.patch index 974f34a1..2df01656 100644 --- a/leaf-server/minecraft-patches/features/0077-Configurable-player-knockback-zombie.patch +++ b/leaf-server/minecraft-patches/features/0078-Configurable-player-knockback-zombie.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable player knockback zombie diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 54b7ae45de54dc335a88a8c48e5212e7e663bc54..a7f87ba5a447be8bd1a4029da999aca34a583b5e 100644 +index 4f0da30fa659ecabdfbd1d17e50888c32501b6e7..f744c9dca670cbbcc7549be17bf51eb683dd1ae0 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -1998,6 +1998,8 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0078-Hide-specified-item-components.patch b/leaf-server/minecraft-patches/features/0079-Hide-specified-item-components.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0078-Hide-specified-item-components.patch rename to leaf-server/minecraft-patches/features/0079-Hide-specified-item-components.patch diff --git a/leaf-server/minecraft-patches/features/0079-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch b/leaf-server/minecraft-patches/features/0080-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0079-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch rename to leaf-server/minecraft-patches/features/0080-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch diff --git a/leaf-server/minecraft-patches/features/0080-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch b/leaf-server/minecraft-patches/features/0081-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0080-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch rename to leaf-server/minecraft-patches/features/0081-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch diff --git a/leaf-server/minecraft-patches/features/0081-PaperPR-Fix-some-beacon-event-issues.patch b/leaf-server/minecraft-patches/features/0082-PaperPR-Fix-some-beacon-event-issues.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0081-PaperPR-Fix-some-beacon-event-issues.patch rename to leaf-server/minecraft-patches/features/0082-PaperPR-Fix-some-beacon-event-issues.patch diff --git a/leaf-server/minecraft-patches/features/0082-Dont-send-useless-entity-packets.patch b/leaf-server/minecraft-patches/features/0083-Dont-send-useless-entity-packets.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0082-Dont-send-useless-entity-packets.patch rename to leaf-server/minecraft-patches/features/0083-Dont-send-useless-entity-packets.patch diff --git a/leaf-server/minecraft-patches/features/0083-Don-t-spawn-if-lastSpawnState-is-null.patch b/leaf-server/minecraft-patches/features/0084-Don-t-spawn-if-lastSpawnState-is-null.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0083-Don-t-spawn-if-lastSpawnState-is-null.patch rename to leaf-server/minecraft-patches/features/0084-Don-t-spawn-if-lastSpawnState-is-null.patch diff --git a/leaf-server/minecraft-patches/features/0084-Multithreaded-Tracker.patch b/leaf-server/minecraft-patches/features/0085-Multithreaded-Tracker.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0084-Multithreaded-Tracker.patch rename to leaf-server/minecraft-patches/features/0085-Multithreaded-Tracker.patch index 0b80083a..7d7a7c05 100644 --- a/leaf-server/minecraft-patches/features/0084-Multithreaded-Tracker.patch +++ b/leaf-server/minecraft-patches/features/0085-Multithreaded-Tracker.patch @@ -218,7 +218,7 @@ index d8298c7925e3bcea07ead4d438478cc51abcfa16..75670751064add901c2628d53d802835 attributesToSync.clear(); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 23f57512e2b4284af0bdbb6f4fc823f26a32d739..623d5e02090b18b2b54dd6fc0da5e579021caca5 100644 +index dd27e6b47233776fdec8860391be772029c987aa..cbbc27e8030d28f95dccebec9b496f2ac8eb38a9 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -2497,7 +2497,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe diff --git a/leaf-server/minecraft-patches/features/0085-Nitori-Async-playerdata-Save.patch b/leaf-server/minecraft-patches/features/0086-Nitori-Async-playerdata-Save.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0085-Nitori-Async-playerdata-Save.patch rename to leaf-server/minecraft-patches/features/0086-Nitori-Async-playerdata-Save.patch diff --git a/leaf-server/minecraft-patches/features/0086-Optimize-nearby-alive-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0087-Optimize-nearby-alive-players-for-spawning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0086-Optimize-nearby-alive-players-for-spawning.patch rename to leaf-server/minecraft-patches/features/0087-Optimize-nearby-alive-players-for-spawning.patch diff --git a/leaf-server/minecraft-patches/features/0087-Cache-blockstate-cache-array.patch b/leaf-server/minecraft-patches/features/0088-Cache-blockstate-cache-array.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0087-Cache-blockstate-cache-array.patch rename to leaf-server/minecraft-patches/features/0088-Cache-blockstate-cache-array.patch diff --git a/leaf-server/minecraft-patches/features/0088-Asynchronous-locator.patch b/leaf-server/minecraft-patches/features/0089-Asynchronous-locator.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0088-Asynchronous-locator.patch rename to leaf-server/minecraft-patches/features/0089-Asynchronous-locator.patch diff --git a/leaf-server/minecraft-patches/features/0089-Smart-sort-entities-in-NearestLivingEntitySensor.patch b/leaf-server/minecraft-patches/features/0090-Smart-sort-entities-in-NearestLivingEntitySensor.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0089-Smart-sort-entities-in-NearestLivingEntitySensor.patch rename to leaf-server/minecraft-patches/features/0090-Smart-sort-entities-in-NearestLivingEntitySensor.patch index 657eff5b..88628c47 100644 --- a/leaf-server/minecraft-patches/features/0089-Smart-sort-entities-in-NearestLivingEntitySensor.patch +++ b/leaf-server/minecraft-patches/features/0090-Smart-sort-entities-in-NearestLivingEntitySensor.patch @@ -10,7 +10,7 @@ on entity count, if entity count doesn't reach the Bucket Sort threshold, FastBitRadix Sort will be used. (see https://ieeexplore.ieee.org/document/7822019 for more) When entity count reached the threshold, Bucket Sort will be used. -In non-strict testing, this can give ~20-40% improvement (54MSPT -> 44MSPT), +In non-strict test, this can give ~20-40% improvement (54MSPT -> 44MSPT), under 625 villagers situation. diff --git a/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java diff --git a/leaf-server/minecraft-patches/features/0090-Further-reduce-memory-footprint-of-CompoundTag.patch b/leaf-server/minecraft-patches/features/0091-Further-reduce-memory-footprint-of-CompoundTag.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0090-Further-reduce-memory-footprint-of-CompoundTag.patch rename to leaf-server/minecraft-patches/features/0091-Further-reduce-memory-footprint-of-CompoundTag.patch diff --git a/leaf-server/minecraft-patches/features/0091-Optimize-Entity-distanceToSqr.patch b/leaf-server/minecraft-patches/features/0092-Optimize-Entity-distanceToSqr.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0091-Optimize-Entity-distanceToSqr.patch rename to leaf-server/minecraft-patches/features/0092-Optimize-Entity-distanceToSqr.patch diff --git a/leaf-server/minecraft-patches/features/0092-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch b/leaf-server/minecraft-patches/features/0093-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0092-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch rename to leaf-server/minecraft-patches/features/0093-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch diff --git a/leaf-server/minecraft-patches/features/0093-Cache-tile-entity-position.patch b/leaf-server/minecraft-patches/features/0094-Cache-tile-entity-position.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0093-Cache-tile-entity-position.patch rename to leaf-server/minecraft-patches/features/0094-Cache-tile-entity-position.patch diff --git a/leaf-server/minecraft-patches/features/0094-TT20-Lag-compensation.patch b/leaf-server/minecraft-patches/features/0095-TT20-Lag-compensation.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0094-TT20-Lag-compensation.patch rename to leaf-server/minecraft-patches/features/0095-TT20-Lag-compensation.patch diff --git a/leaf-server/minecraft-patches/features/0095-C2ME-Reduce-Allocations.patch b/leaf-server/minecraft-patches/features/0096-C2ME-Reduce-Allocations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0095-C2ME-Reduce-Allocations.patch rename to leaf-server/minecraft-patches/features/0096-C2ME-Reduce-Allocations.patch diff --git a/leaf-server/minecraft-patches/features/0096-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch b/leaf-server/minecraft-patches/features/0097-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0096-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch rename to leaf-server/minecraft-patches/features/0097-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch diff --git a/leaf-server/minecraft-patches/features/0097-Lithium-fast-util.patch b/leaf-server/minecraft-patches/features/0098-Lithium-fast-util.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0097-Lithium-fast-util.patch rename to leaf-server/minecraft-patches/features/0098-Lithium-fast-util.patch diff --git a/leaf-server/minecraft-patches/features/0098-Lithium-CompactSineLUT.patch b/leaf-server/minecraft-patches/features/0099-Lithium-CompactSineLUT.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0098-Lithium-CompactSineLUT.patch rename to leaf-server/minecraft-patches/features/0099-Lithium-CompactSineLUT.patch diff --git a/leaf-server/minecraft-patches/features/0099-Lithium-cached-iterate-outwards.patch b/leaf-server/minecraft-patches/features/0100-Lithium-cached-iterate-outwards.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0099-Lithium-cached-iterate-outwards.patch rename to leaf-server/minecraft-patches/features/0100-Lithium-cached-iterate-outwards.patch diff --git a/leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch b/leaf-server/minecraft-patches/features/0101-Smooth-teleport-config.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch rename to leaf-server/minecraft-patches/features/0101-Smooth-teleport-config.patch index 6b809f32..8498a309 100644 --- a/leaf-server/minecraft-patches/features/0100-Smooth-teleport-config.patch +++ b/leaf-server/minecraft-patches/features/0101-Smooth-teleport-config.patch @@ -30,7 +30,7 @@ index e1a1bddfc11da20f3a1b9a2773b19d4317fac914..01c30802a1d0127f2ed36efa7511c2ac level.addDuringTeleport(this); this.triggerDimensionChangeTriggers(serverLevel); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 6327d508252b35fcbd2daebad078f00d44291c6e..e686d435dcca9dc74a0d569878e51f643210653c 100644 +index 119ffa8f10bdcc27ff4b7dc4e1ef18212607c4bf..e402e5a741c3864f66cf9c713f2bb83191d4607e 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -955,11 +955,11 @@ public abstract class PlayerList { diff --git a/leaf-server/minecraft-patches/features/0101-Use-faster-and-thread-safe-ban-list-date-format-pars.patch b/leaf-server/minecraft-patches/features/0102-Use-faster-and-thread-safe-ban-list-date-format-pars.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0101-Use-faster-and-thread-safe-ban-list-date-format-pars.patch rename to leaf-server/minecraft-patches/features/0102-Use-faster-and-thread-safe-ban-list-date-format-pars.patch diff --git a/leaf-server/minecraft-patches/features/0102-Collect-then-startEachNonRunningBehavior-in-Brain.patch b/leaf-server/minecraft-patches/features/0103-Collect-then-startEachNonRunningBehavior-in-Brain.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0102-Collect-then-startEachNonRunningBehavior-in-Brain.patch rename to leaf-server/minecraft-patches/features/0103-Collect-then-startEachNonRunningBehavior-in-Brain.patch diff --git a/leaf-server/minecraft-patches/features/0103-Lithium-equipment-tracking.patch b/leaf-server/minecraft-patches/features/0104-Lithium-equipment-tracking.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0103-Lithium-equipment-tracking.patch rename to leaf-server/minecraft-patches/features/0104-Lithium-equipment-tracking.patch diff --git a/leaf-server/minecraft-patches/features/0104-C2ME-Optimize-world-gen-math.patch b/leaf-server/minecraft-patches/features/0105-C2ME-Optimize-world-gen-math.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0104-C2ME-Optimize-world-gen-math.patch rename to leaf-server/minecraft-patches/features/0105-C2ME-Optimize-world-gen-math.patch diff --git a/leaf-server/minecraft-patches/features/0105-Cache-chunk-key.patch b/leaf-server/minecraft-patches/features/0106-Cache-chunk-key.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0105-Cache-chunk-key.patch rename to leaf-server/minecraft-patches/features/0106-Cache-chunk-key.patch index 9dd9ad7b..31e3ccaf 100644 --- a/leaf-server/minecraft-patches/features/0105-Cache-chunk-key.patch +++ b/leaf-server/minecraft-patches/features/0106-Cache-chunk-key.patch @@ -84,7 +84,7 @@ index 571db5f9bf94745a8afe2cd313e593fb15db5e37..1487b7d8be435b3fbad2aabd05796965 valueInMap = new ServerChunkTasks( keyInMap, ServerLightQueue.this.lightInterface, ServerLightQueue.this, priority diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 623d5e02090b18b2b54dd6fc0da5e579021caca5..26223a3c26691303a91b988b6d84373a303785dd 100644 +index cbbc27e8030d28f95dccebec9b496f2ac8eb38a9..1277b4b6b5283afebb78b403824e6a5aa1e5734f 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -508,7 +508,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe diff --git a/leaf-server/minecraft-patches/features/0106-Cache-random-tick-block-status.patch b/leaf-server/minecraft-patches/features/0107-Cache-random-tick-block-status.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0106-Cache-random-tick-block-status.patch rename to leaf-server/minecraft-patches/features/0107-Cache-random-tick-block-status.patch diff --git a/leaf-server/minecraft-patches/features/0107-Cache-part-of-canHoldFluid-result.patch b/leaf-server/minecraft-patches/features/0108-Cache-part-of-canHoldFluid-result.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0107-Cache-part-of-canHoldFluid-result.patch rename to leaf-server/minecraft-patches/features/0108-Cache-part-of-canHoldFluid-result.patch diff --git a/leaf-server/minecraft-patches/features/0108-Only-broadcast-carried-item-if-changed.patch b/leaf-server/minecraft-patches/features/0109-Only-broadcast-carried-item-if-changed.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0108-Only-broadcast-carried-item-if-changed.patch rename to leaf-server/minecraft-patches/features/0109-Only-broadcast-carried-item-if-changed.patch diff --git a/leaf-server/minecraft-patches/features/0110-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch b/leaf-server/minecraft-patches/features/0110-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch new file mode 100644 index 00000000..5538756e --- /dev/null +++ b/leaf-server/minecraft-patches/features/0110-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Sun, 26 Nov 2023 13:02:16 -0300 +Subject: [PATCH] PaperPR: Fix MC-117075: Block Entities Unload Lag Spike + +Original license: GPLv3 +Original project: https://github.com/SparklyPower/SparklyPaper +Paper pull request: https://github.com/PaperMC/Paper/pull/9970 + +We replaced the `blockEntityTickers` list with a custom list based on fastutil's `ObjectArrayList` with a small yet huge change for us: A method that allows us to remove a list of indexes from the list. + +This is WAY FASTER than using `removeAll` with a list of entries to be removed, because we don't need to calculate the identity of each block entity to be removed, and we can jump directly to where the search should begin, giving a performance boost for small removals (because we don't need to loop thru the entire list to find what element should be removed) and a performance boost for big removals (no need to calculate the identity of each block entity). + +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index 53cabe7dabc83618c8941c95e95c5b7e23ee694e..7d3163802640449b6bdaa93595518d7d0f62488b 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -113,7 +113,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + 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; +- public final List blockEntityTickers = Lists.newArrayList(); // Paper - public ++ public final org.dreeam.leaf.util.list.BlockEntityTickersList blockEntityTickers = new org.dreeam.leaf.util.list.BlockEntityTickersList(); // Paper - public // SparklyPaper - optimize block entity removals + protected final NeighborUpdater neighborUpdater; + private final List pendingBlockEntityTickers = Lists.newArrayList(); + private boolean tickingBlockEntities; +@@ -1523,14 +1523,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + boolean runsNormally = this.tickRateManager().runsNormally(); + + int tickedEntities = 0; // Paper - rewrite chunk system +- var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll +- toRemove.add(null); // Paper - Fix MC-117075 + for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters + this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; + TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition); + // Spigot end + if (tickingBlockEntity.isRemoved()) { +- toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll ++ this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // toRemove.add(tickingBlockEntity); // SparklyPaper - optimize block entity removals // Paper - Fix MC-117075; use removeAll + } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { + tickingBlockEntity.tick(); + // Paper start - rewrite chunk system +@@ -1540,7 +1538,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + // Paper end - rewrite chunk system + } + } +- this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 ++ this.blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals + + this.tickingBlockEntities = false; + this.spigotConfig.currentPrimedTnt = 0; // Spigot diff --git a/leaf-server/minecraft-patches/features/0111-Sepals-Rearrange-the-attackable-conditions.patch b/leaf-server/minecraft-patches/features/0111-Sepals-Rearrange-the-attackable-conditions.patch new file mode 100644 index 00000000..6da07367 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0111-Sepals-Rearrange-the-attackable-conditions.patch @@ -0,0 +1,71 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: cao-awa +Date: Fri, 23 Aug 2024 00:23:32 +0800 +Subject: [PATCH] Sepals: Rearrange the attackable conditions + +Original license: GPLv3 +Original project: https://github.com/cao-awa/Sepals + +Rearrange the attackable conditions +let less costs predicate running first +reduce the probability of high-costs calculating + +-- The complaints -- +Mojang's attackable predicate is: + +!entity.getBrain().hasMemoryModule(MemoryModuleType.HAS_HUNTING_COOLDOWN) + && Sensor.testAttackableTargetPredicate(entity, target) + && FrogEntity.isValidFrogFood(target) + && !this.isTargetUnreachable(entity, target) + && target.isInRange(entity, 10.0) + +in this case, 'Sensor#testAttackableTargetPredicate' has calls 'TargetPredicate#test' +that cause a very lots raycast calculate when entities too much in the area +but... minecraft's raycast is absolutely bad, very slow + +the 'TargetPredicate#test' in this case (800 frogs) has make 9.8ms costs in once game tick +among them, 'BlockView.raycast' contributed 7.3ms + +then i make it be: + +FrogEntity.isValidFrogFood(target) && + entity.getBrain().hasMemoryModule(MemoryModuleType.HAS_HUNTING_COOLDOWN) && + target.isInRange(entity, 10.0) && + Sensor.testAttackableTargetPredicate(entity, target) && + isTargetUnreachable(entity, target); + +the 'isValidFrogFood' is simple conditions, check the entity's tag has in 'frog_food' +and a extra check when entity is slime then skip it when it size not 1 + +the 'isInRange' and 'hasMemoryModule' also simple, it only a few math calculates + +Test Result: +800 frogs cramming in a 7x7 space: + +| Environment | time | Percent(Avg.) | +|-------------------------------------------------:|:------:|:-------------:| +| Vanilla (FrogAttackablesSensor#matches) | 10 ms | 100 % | +| With Lithium (FrogAttackablesSensor#matches) | 5.7 ms | 57 % | +| With Sepals (SepalsFrogBrain#attackable) | 0.1 ms | 1 % | +| With Sepals+Lithium (SepalsFrogBrain#attackable) | 0.1 ms | 1 % | + +diff --git a/net/minecraft/world/entity/ai/sensing/FrogAttackablesSensor.java b/net/minecraft/world/entity/ai/sensing/FrogAttackablesSensor.java +index d163a363273b52b3b3f0b5a74ac4d4ab37d24bb7..e88479ba1ebeff67a93baad4f6f8c83119ff5ff7 100644 +--- a/net/minecraft/world/entity/ai/sensing/FrogAttackablesSensor.java ++++ b/net/minecraft/world/entity/ai/sensing/FrogAttackablesSensor.java +@@ -13,11 +13,11 @@ public class FrogAttackablesSensor extends NearestVisibleLivingEntitySensor { + + @Override + protected boolean isMatchingEntity(ServerLevel level, LivingEntity entity, LivingEntity target) { +- return !entity.getBrain().hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN) ++ return Frog.canEat(target) ++ && !entity.getBrain().hasMemoryValue(MemoryModuleType.HAS_HUNTING_COOLDOWN) ++ && target.closerThan(entity, 10.0) + && Sensor.isEntityAttackable(level, entity, target) +- && Frog.canEat(target) +- && !this.isUnreachableAttackTarget(entity, target) +- && target.closerThan(entity, 10.0); ++ && !this.isUnreachableAttackTarget(entity, target); // Sepals - Rearrange the attackable conditions + } + + private boolean isUnreachableAttackTarget(LivingEntity attacker, LivingEntity target) { diff --git a/leaf-server/minecraft-patches/features/0112-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch b/leaf-server/minecraft-patches/features/0112-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch new file mode 100644 index 00000000..ea9f51d9 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0112-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Mon, 13 Jan 2025 14:32:08 -0300 +Subject: [PATCH] SparklyPaper: Skip dirty stats copy when requesting player + stats + + +diff --git a/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java +index b26dbe807e5cb0a42f6c06b933397902310e5616..ce89060bd01b253af7577fd0e6c03fc95f046b91 100644 +--- a/net/minecraft/stats/ServerStatsCounter.java ++++ b/net/minecraft/stats/ServerStatsCounter.java +@@ -81,11 +81,15 @@ public class ServerStatsCounter extends StatsCounter { + this.dirty.add(stat); + } + ++ // SparklyPaper start - Skip dirty stats copy when requesting player stats ++ /* + private Set> getDirty() { + Set> set = Sets.newHashSet(this.dirty); + this.dirty.clear(); + return set; + } ++ */ ++ // SparklyPaper end + + public void parseLocal(DataFixer fixerUpper, String json) { + try { +@@ -194,10 +198,12 @@ public class ServerStatsCounter extends StatsCounter { + public void sendStats(ServerPlayer player) { + Object2IntMap> map = new Object2IntOpenHashMap<>(); + +- for (Stat stat : this.getDirty()) { ++ for (Stat stat : this.dirty) { // SparklyPaper - Skip dirty stats copy when requesting player stats + map.put(stat, this.getValue(stat)); + } + ++ this.dirty.clear(); // SparklyPaper - Skip dirty stats copy when requesting player stats ++ + player.connection.send(new ClientboundAwardStatsPacket(map)); + } + } diff --git a/leaf-server/minecraft-patches/features/0113-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch b/leaf-server/minecraft-patches/features/0113-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch new file mode 100644 index 00000000..c9472249 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0113-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrPowerGamerBR +Date: Wed, 5 Jun 2024 15:20:00 -0300 +Subject: [PATCH] SparklyPaper: Reset dirty flag when loading maps from the + disk + +By default, the server will start rewriting all map datas to the disk after loading it, even if the map didn't have any changes + +This also slows down world saving a lot if you have a lot of maps + +diff --git a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +index 681dec447486138088fe5f705ef4fadab531139f..07f9287ff1f1dbd1795582c74102c072ea59b29f 100644 +--- a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java ++++ b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +@@ -198,6 +198,7 @@ public class MapItemSavedData extends SavedData { + } + } + ++ mapItemSavedData.setDirty(false); // SparklyPaper - reset dirty flag when loading maps from the disk (context for updates: this modification is at the end of the map "load" function) + return mapItemSavedData; + } + diff --git a/leaf-server/minecraft-patches/features/0114-Optimize-checking-nearby-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0114-Optimize-checking-nearby-players-for-spawning.patch new file mode 100644 index 00000000..6fde26d4 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0114-Optimize-checking-nearby-players-for-spawning.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sat, 8 Feb 2025 05:32:30 +0100 +Subject: [PATCH] Optimize checking nearby players for spawning + + +diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java +index 8986c059e7aadb58ae8d9ab7b848de10f9faa6b2..546b20f8998c71ca1a701de7efcedd8d821105e4 100644 +--- a/net/minecraft/server/level/ChunkMap.java ++++ b/net/minecraft/server/level/ChunkMap.java +@@ -719,7 +719,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + } + + private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos, boolean reducedRange) { +- double blockRange; // Paper - use from event ++ //double blockRange; // Paper - use from event // Leaf - Optimize checking nearby players for spawning - move down + // Spigot end + // Paper start - chunk tick iteration optimisation + final ca.spottedleaf.moonrise.common.list.ReferenceList players = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers().getPlayers( +@@ -731,23 +731,39 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + + final ServerPlayer[] raw = players.getRawDataUnchecked(); + final int len = players.size(); ++ // Leaf start - Optimize checking nearby players for spawning ++ // Precompute chunk center once ++ // inline, copy from SectionPos#sectionToBlockCoord ++ final double centerX = (chunkPos.x << 4) + 8; ++ final double centerZ = (chunkPos.z << 4) + 8; + +- Objects.checkFromIndexSize(0, len, raw.length); + for (int i = 0; i < len; ++i) { + final ServerPlayer serverPlayer = raw[i]; +- // Paper start - PlayerNaturallySpawnCreaturesEvent +- com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event; +- blockRange = 16384.0D; ++ ++ if (serverPlayer.isSpectator()) continue; // Skip spectators early ++ ++ final double blockRangeSquared; ++ + if (reducedRange) { +- event = serverPlayer.playerNaturallySpawnedEvent; ++ // Handle reduced range from PlayerNaturallySpawnCreaturesEvent ++ // Paper start - PlayerNaturallySpawnCreaturesEvent ++ final com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = serverPlayer.playerNaturallySpawnedEvent; + if (event == null || event.isCancelled()) continue; +- blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); ++ final int spawnRadius = event.getSpawnRadius(); ++ blockRangeSquared = (double) (spawnRadius * spawnRadius) * 256.0; // (radius << 4)^2 ++ // Paper end - PlayerNaturallySpawnCreaturesEvent ++ } else { ++ blockRangeSquared = 16384.0D; // Default 128^2 + } +- // Paper end - PlayerNaturallySpawnCreaturesEvent +- if (this.playerIsCloseEnoughForSpawning(serverPlayer, chunkPos, blockRange)) { ++ ++ // Calculate squared distance using precomputed center ++ final double dx = serverPlayer.getX() - centerX; ++ final double dz = serverPlayer.getZ() - centerZ; ++ if (dx * dx + dz * dz < blockRangeSquared) { + return true; + } + } ++ // Leaf end - Optimize checking nearby players for spawning + + return false; + // Paper end - chunk tick iteration optimisation diff --git a/leaf-server/minecraft-patches/features/0115-Cache-supporting-block-check.patch b/leaf-server/minecraft-patches/features/0115-Cache-supporting-block-check.patch new file mode 100644 index 00000000..133644d2 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0115-Cache-supporting-block-check.patch @@ -0,0 +1,63 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sat, 8 Feb 2025 05:32:30 +0100 +Subject: [PATCH] Cache supporting block check + + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 4544dd876d3cbcdb9b774b4a1f0c4737f3124bc5..6ca446fd9ab38329ba505526a56f8e4f64a9a639 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -1083,12 +1083,36 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + return this.mainSupportingBlockPos.isPresent() && this.mainSupportingBlockPos.get().equals(pos); + } + ++ // Leaf start - Cache supporting block check ++ private boolean canSkipSupportingBlockSearch = false; ++ private BlockState cachedSupportingBlockState = null; ++ // Leaf end - Cache supporting block check ++ + protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) { ++ // Leaf start - Cache supporting block check ++ // Skip full check if no movement and cache is valid ++ if (movement == null || (movement.x == 0 && movement.z == 0 && movement.y == 0)) { ++ if (canSkipSupportingBlockSearch) { ++ return; ++ } ++ } else { ++ // Invalidate cache on movement ++ canSkipSupportingBlockSearch = false; ++ cachedSupportingBlockState = null; ++ } ++ // Leaf end - Cache supporting block check + if (onGround) { + AABB boundingBox = this.getBoundingBox(); + AABB aabb = new AABB(boundingBox.minX, boundingBox.minY - 1.0E-6, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ); + Optional optional = this.level.findSupportingBlock(this, aabb); + if (optional.isPresent() || this.onGroundNoBlocks) { ++ // Leaf start - Cache supporting block check ++ if (optional.isPresent()) { // Cache the block state if found ++ BlockPos pos = optional.get(); ++ cachedSupportingBlockState = this.level.getBlockState(pos); ++ canSkipSupportingBlockSearch = true; ++ } ++ // Leaf end - Cache supporting block check + this.mainSupportingBlockPos = optional; + } else if (movement != null) { + AABB aabb1 = aabb.move(-movement.x, 0.0, -movement.z); +@@ -1105,6 +1129,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + } + ++ ++ // Leaf start - Cache supporting block check ++ // Helper method to get cached supporting block state ++ @Nullable ++ public BlockState getCachedSupportingBlock() { ++ return canSkipSupportingBlockSearch ? cachedSupportingBlockState : null; ++ } ++ // Leaf end - Cache supporting block check ++ + public boolean onGround() { + return this.onGround; + } diff --git a/leaf-server/minecraft-patches/features/0116-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch b/leaf-server/minecraft-patches/features/0116-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch new file mode 100644 index 00000000..f9feba13 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0116-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MachineBreaker +Date: Wed, 16 Oct 2024 03:39:24 -0400 +Subject: [PATCH] Avoid useless deque clear on LevelTicks#cleanupAfterTick + + +diff --git a/net/minecraft/world/ticks/LevelTicks.java b/net/minecraft/world/ticks/LevelTicks.java +index fbf0d3b808c66e8971c747619f6acf7417af5ef7..d4542a86a2a9bfcfa7b6b7a213f233542ffed797 100644 +--- a/net/minecraft/world/ticks/LevelTicks.java ++++ b/net/minecraft/world/ticks/LevelTicks.java +@@ -182,7 +182,7 @@ public class LevelTicks implements LevelTickAccess { + } + + private void cleanupAfterTick() { +- this.toRunThisTick.clear(); ++ //this.toRunThisTick.clear(); // Leaf - Avoid useless deque clear on LevelTicks#cleanupAfterTick - This method runs after toRunThisTick is polled so this is always empty + this.containersToTick.clear(); + this.alreadyRunThisTick.clear(); + this.toRunThisTickSet.clear(); diff --git a/leaf-server/minecraft-patches/features/0117-Replace-brain-activity-maps-with-optimized-collectio.patch b/leaf-server/minecraft-patches/features/0117-Replace-brain-activity-maps-with-optimized-collectio.patch new file mode 100644 index 00000000..dbdcd2c0 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0117-Replace-brain-activity-maps-with-optimized-collectio.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sat, 8 Feb 2025 20:45:14 +0100 +Subject: [PATCH] Replace brain activity maps with optimized collection + + +diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java +index ea6c8e85ccff67b1c24109732f74f1e8199cad07..e27284f9897923f67985e3d60c3438bd00cc4a51 100644 +--- a/net/minecraft/world/entity/ai/Brain.java ++++ b/net/minecraft/world/entity/ai/Brain.java +@@ -390,8 +390,8 @@ public class Brain { + + for (Pair> pair : tasks) { + this.availableBehaviorsByPriority +- .computeIfAbsent(pair.getFirst(), integer -> Maps.newHashMap()) +- .computeIfAbsent(activity, activity1 -> Sets.newLinkedHashSet()) ++ .computeIfAbsent(pair.getFirst(), integer -> new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()) // Leaf - Replace brain activity maps with optimized collection ++ .computeIfAbsent(activity, activity1 -> new it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet<>()) // Leaf - Replace brain activity maps with optimized collection + .add((BehaviorControl)pair.getSecond()); + } + } diff --git a/leaf-server/minecraft-patches/features/0118-Remove-stream-in-villagers.patch b/leaf-server/minecraft-patches/features/0118-Remove-stream-in-villagers.patch new file mode 100644 index 00000000..445dc443 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0118-Remove-stream-in-villagers.patch @@ -0,0 +1,65 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sat, 8 Feb 2025 22:11:16 +0100 +Subject: [PATCH] Remove stream in villagers + +TradeWithVillager#figureOutWhatIAmWillingToTrade +In the test, this can give ~40% improvement (~20ms -> ~12ms), +under 2048 villagers situation. +And ~100% improvement (~36ms -> ~0ms), under 512 villagers situation. + +Villager#countFoodPointsInInventory +In the test, this can give ~82.14% improvement (~1456ms -> ~260ms), +under 2048 villagers situation. +And ~93.92% improvement (~1382ms -> ~84ms), under 512 villagers situation. + +diff --git a/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java b/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java +index 4d8523a43d60cd6b4fd5546ffb3a61417b2c475b..8921faa7b893aae9e91a6f8e36dcd751308f9bab 100644 +--- a/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java ++++ b/net/minecraft/world/entity/ai/behavior/TradeWithVillager.java +@@ -77,9 +77,19 @@ public class TradeWithVillager extends Behavior { + } + + private static Set figureOutWhatIAmWillingToTrade(Villager villager, Villager other) { +- ImmutableSet set = other.getVillagerData().getProfession().requestedItems(); +- ImmutableSet set1 = villager.getVillagerData().getProfession().requestedItems(); +- return set.stream().filter(item -> !set1.contains(item)).collect(Collectors.toSet()); ++ // Leaf start - Remove stream in villagers ++ ImmutableSet otherItems = other.getVillagerData().getProfession().requestedItems(); ++ ImmutableSet villagerItems = villager.getVillagerData().getProfession().requestedItems(); ++ Set result = new java.util.HashSet<>(); ++ ++ for (Item item : otherItems) { ++ if (!villagerItems.contains(item)) { ++ result.add(item); ++ } ++ } ++ ++ return result; ++ // Leaf end - Remove stream in villagers + } + + private static void throwHalfStack(Villager villager, Set stack, LivingEntity entity) { +diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java +index bee017f2c47a9f0876e2e05ce1c720332fb74566..0b4c4707139c9c72929799818ec1a1b25575d70e 100644 +--- a/net/minecraft/world/entity/npc/Villager.java ++++ b/net/minecraft/world/entity/npc/Villager.java +@@ -985,7 +985,17 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + + private int countFoodPointsInInventory() { + SimpleContainer inventory = this.getInventory(); +- return FOOD_POINTS.entrySet().stream().mapToInt(entry -> inventory.countItem(entry.getKey()) * entry.getValue()).sum(); ++ // Leaf start - Remove stream in villagers ++ int sum = 0; ++ ++ for (Map.Entry entry : FOOD_POINTS.entrySet()) { ++ Item item = entry.getKey(); ++ int points = entry.getValue(); ++ sum += inventory.countItem(item) * points; ++ } ++ ++ return sum; ++ // Leaf end - Remove stream in villagers + } + + public boolean hasFarmSeeds() { diff --git a/leaf-server/minecraft-patches/features/0119-Optimize-baby-villager-sensor.patch b/leaf-server/minecraft-patches/features/0119-Optimize-baby-villager-sensor.patch new file mode 100644 index 00000000..9004445f --- /dev/null +++ b/leaf-server/minecraft-patches/features/0119-Optimize-baby-villager-sensor.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sat, 8 Feb 2025 22:36:31 +0100 +Subject: [PATCH] Optimize baby villager sensor + +In the test, this can give ~16.58% improvement (~2316ms -> ~1932ms), +under 2048 villagers situation. +And ~42.93% improvement (~764ms -> ~436ms), under 512 villagers situation. + +diff --git a/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java b/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java +index 1c010e5b75506945e5281021a2ddad424044d28f..2b973a3ba7d65330fa4690e71e5321c28457ec61 100644 +--- a/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java ++++ b/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java +@@ -42,7 +42,7 @@ public class NearestVisibleLivingEntities { + } + + public Iterable findAll(Predicate predicate) { +- return Iterables.filter(this.nearbyEntities, target -> predicate.test(target) && this.lineOfSightTest.test(target)); ++ return Iterables.filter(this.nearbyEntities, target -> predicate.test(target) && this.lineOfSightTest.test(target)); // Leaf - Optimize baby villager sensor - diff on change + } + + public Stream find(Predicate predicate) { +diff --git a/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java b/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java +index 24d1928445b5571e040a2b12d5c82e77a880d9bd..4b2964aeb4e21fe41f42c2902db63ce28322063a 100644 +--- a/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java ++++ b/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java +@@ -22,11 +22,25 @@ public class VillagerBabiesSensor extends Sensor { + } + + private List getNearestVillagerBabies(LivingEntity livingEntity) { +- return ImmutableList.copyOf(this.getVisibleEntities(livingEntity).findAll(this::isVillagerBaby)); ++ // Leaf start - Optimize baby villager sensor ++ NearestVisibleLivingEntities visibleEntities = this.getVisibleEntities(livingEntity); ++ ImmutableList.Builder babies = ImmutableList.builder(); ++ ++ // Inline and use single loop - copy from NearestVisibleLivingEntities#findAll and isVillagerBaby ++ for (LivingEntity target : visibleEntities.nearbyEntities) { ++ if (target.getType() == EntityType.VILLAGER ++ && target.isBaby() ++ && visibleEntities.lineOfSightTest.test(target)) { ++ babies.add(target); ++ } ++ } ++ ++ return babies.build(); ++ // Leaf end - Optimize baby villager sensor + } + + private boolean isVillagerBaby(LivingEntity livingEntity) { +- return livingEntity.getType() == EntityType.VILLAGER && livingEntity.isBaby(); ++ return livingEntity.getType() == EntityType.VILLAGER && livingEntity.isBaby(); // Leaf - Optimize baby villager sensor - diff on change + } + + private NearestVisibleLivingEntities getVisibleEntities(LivingEntity livingEntity) { diff --git a/leaf-server/minecraft-patches/features/0120-Only-player-pushable.patch b/leaf-server/minecraft-patches/features/0120-Only-player-pushable.patch new file mode 100644 index 00000000..e86dea63 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0120-Only-player-pushable.patch @@ -0,0 +1,94 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> +Date: Wed, 27 Nov 2024 23:13:12 -0500 +Subject: [PATCH] Only player pushable + +Useful for extreme cases like massive entities collide together in a small area + +diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index f4f978073fca1be8fe18bc13f64385d4c0cd4b3d..deb31fa0e0c9c8ccb21c5ae7e86bb1c5406e2177 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -3624,7 +3624,7 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf + this.checkAutoSpinAttack(boundingBox, this.getBoundingBox()); + } + +- this.pushEntities(); ++ if (!org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled) this.pushEntities(); // Leaf - Only player pushable + // Paper start - Add EntityMoveEvent + // Purpur start - Ridables + if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { +@@ -3762,7 +3762,14 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf + return; + } + // Paper end - don't run getEntities if we're not going to use its result +- List entities = this.level().getEntities(this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - Climbing should not bypass cramming gamerule ++ // Leaf start - Only player pushable ++ final AABB box = this.getBoundingBox(); ++ final Predicate conditions = EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule); ++ ++ List entities = org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled ++ ? getNearbyPushablePlayers(this, box, conditions) ++ : this.level().getEntities(this, box, conditions); // Paper - Climbing should not bypass cramming gamerule ++ // Leaf end - Only player pushable + if (!entities.isEmpty()) { + // Paper - don't run getEntities if we're not going to use its result; moved up + if (_int > 0 && entities.size() > _int - 1 && this.random.nextInt(4) == 0) { +@@ -3795,6 +3802,44 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf + } + } + ++ // Leaf start - Only player pushable ++ public List getNearbyPushablePlayers(Entity entity, AABB box, Predicate conditions) { ++ final Vec3 vec = entity.position; ++ final net.minecraft.core.BlockPos.MutableBlockPos mutablePos = new net.minecraft.core.BlockPos.MutableBlockPos(); ++ ++ mutablePos.set(vec.x, vec.y, vec.z); ++ ++ final ca.spottedleaf.moonrise.common.list.ReferenceList players = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel) this.level()).moonrise$getNearbyPlayers().getPlayers( ++ mutablePos, ca.spottedleaf.moonrise.common.misc.NearbyPlayers.NearbyMapType.SPAWN_RANGE ++ ); ++ ++ if (players == null) { ++ return new ArrayList<>(); ++ } ++ ++ List ret = null; ++ ++ final ServerPlayer[] raw = players.getRawDataUnchecked(); ++ final int len = players.size(); ++ ++ java.util.Objects.checkFromIndexSize(0, len, raw.length); ++ ++ for (int i = 0; i < len; ++i) { ++ final ServerPlayer player = raw[i]; ++ if (player != entity && box.intersects(player.getBoundingBox()) && conditions.test(player)) { ++ if (ret == null) { ++ ret = new ArrayList<>(len - i); ++ ret.add(player); ++ } else { ++ ret.add(player); ++ } ++ } ++ } ++ ++ return ret == null ? new ArrayList<>() : ret; ++ } ++ // Leaf end - Only player pushable ++ + protected void checkAutoSpinAttack(AABB boundingBoxBeforeSpin, AABB boundingBoxAfterSpin) { + AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); + List entities = this.level().getEntities(this, aabb); +diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java +index 21153f37c169e987d7876d1b914105223ac10ee7..a8bd9f027b5ce360b9e720a7734451bcf9f701d4 100644 +--- a/net/minecraft/world/entity/decoration/ArmorStand.java ++++ b/net/minecraft/world/entity/decoration/ArmorStand.java +@@ -326,7 +326,7 @@ public class ArmorStand extends LivingEntity implements net.caffeinemc.mods.lith + + @Override + protected void pushEntities() { +- if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups ++ if (org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled || !this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups // Leaf - Only player pushable + for (Entity entity : this.level().getEntitiesOfClass(AbstractMinecart.class, this.getBoundingBox(), RIDABLE_MINECARTS)) { // Paper - optimise collisions + if (this.distanceToSqr(entity) <= 0.2) { + entity.push(this); diff --git a/leaf-server/minecraft-patches/features/0121-Remove-iterators-from-Inventory-contains.patch b/leaf-server/minecraft-patches/features/0121-Remove-iterators-from-Inventory-contains.patch new file mode 100644 index 00000000..38c4d642 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0121-Remove-iterators-from-Inventory-contains.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Thu, 13 Feb 2025 01:25:40 +0100 +Subject: [PATCH] Remove iterators from Inventory#contains + + +diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java +index 839cbb67d3d38960d9114a4db5bab911b66a573c..e2237ffebadc8f010688c6e7336f4278193a1a20 100644 +--- a/net/minecraft/world/entity/player/Inventory.java ++++ b/net/minecraft/world/entity/player/Inventory.java +@@ -568,9 +568,13 @@ public class Inventory implements Container, Nameable { + } + + public boolean contains(ItemStack stack) { +- for (List list : this.compartments) { +- for (ItemStack itemStack : list) { +- if (!itemStack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack)) { ++ // Leaf start - Remove iterators from Inventory#contains ++ for (int i = 0; i < this.compartments.size(); i++) { ++ List list = this.compartments.get(i); ++ for (int j = 0; j < list.size(); j++) { ++ ItemStack itemstack1 = list.get(j); ++ if (!itemstack1.isEmpty() && ItemStack.isSameItemSameComponents(itemstack1, stack)) { ++ // Leaf end - Remove iterators from Inventory#contains + return true; + } + } +@@ -580,9 +584,13 @@ public class Inventory implements Container, Nameable { + } + + public boolean contains(TagKey tag) { +- for (List list : this.compartments) { +- for (ItemStack itemStack : list) { +- if (!itemStack.isEmpty() && itemStack.is(tag)) { ++ // Leaf start - Remove iterators from Inventory#contains ++ for (int i = 0; i < this.compartments.size(); i++) { ++ List list = this.compartments.get(i); ++ for (int j = 0; j < list.size(); j++) { ++ ItemStack itemstack = list.get(j); ++ if (!itemstack.isEmpty() && itemstack.is(tag)) { ++ // Leaf end - Remove iterators from Inventory#contains + return true; + } + } +@@ -592,9 +600,13 @@ public class Inventory implements Container, Nameable { + } + + public boolean contains(Predicate predicate) { +- for (List list : this.compartments) { +- for (ItemStack itemStack : list) { +- if (predicate.test(itemStack)) { ++ // Leaf start - Remove iterators from Inventory#contains ++ for (int i = 0; i < this.compartments.size(); i++) { ++ List list = this.compartments.get(i); ++ for (int j = 0; j < list.size(); j++) { ++ ItemStack itemstack = list.get(j); ++ if (predicate.test(itemstack)) { ++ // Leaf end - Remove iterators from Inventory#contains + return true; + } + } diff --git a/leaf-server/minecraft-patches/features/0122-Alternative-Brain-Behaviour.patch b/leaf-server/minecraft-patches/features/0122-Alternative-Brain-Behaviour.patch new file mode 100644 index 00000000..b6b27059 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0122-Alternative-Brain-Behaviour.patch @@ -0,0 +1,72 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Fri, 14 Feb 2025 14:58:59 +0100 +Subject: [PATCH] Alternative Brain Behaviour + +In the test, this can give ~54.87% improvement (~25712ms -> ~11604ms), +under 1024 villagers situation. + +diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java +index e27284f9897923f67985e3d60c3438bd00cc4a51..0ff7564e0e848bd38e82f9089bfd7249fa649dc5 100644 +--- a/net/minecraft/world/entity/ai/Brain.java ++++ b/net/minecraft/world/entity/ai/Brain.java +@@ -268,23 +268,52 @@ public class Brain { + return this.activeActivities; + } + ++ // Leaf start - Alternative Brain Behaviour ++ private ObjectArrayList> runningBehaviorsCache; ++ private long lastRunningBehaviorCheck = -1; ++ // Leaf end - Alternative Brain Behaviour ++ + @Deprecated + @VisibleForDebug + public List> getRunningBehaviors() { +- List> list = new ObjectArrayList<>(); ++ // Leaf start - Alternative Brain Behaviour ++ long currentTick = getCurrentTick(); ++ ++ // Use cached result if within update interval ++ if (runningBehaviorsCache != null && (currentTick - lastRunningBehaviorCheck) < org.dreeam.leaf.config.modules.opt.BrainRunningBehaviorCacheUpdate.interval) { ++ return runningBehaviorsCache; ++ } ++ ++ // Initialize or reuse cache list ++ if (runningBehaviorsCache == null) { ++ runningBehaviorsCache = new ObjectArrayList<>(32); ++ } else { ++ runningBehaviorsCache.clear(); ++ } ++ ++ for (Map>> activityMap : availableBehaviorsByPriority.values()) { ++ for (Set> behaviors : activityMap.values()) { ++ if (behaviors.isEmpty()) continue; + +- for (Map>> map : this.availableBehaviorsByPriority.values()) { +- for (Set> set : map.values()) { +- for (BehaviorControl behaviorControl : set) { +- if (behaviorControl.getStatus() == Behavior.Status.RUNNING) { +- list.add(behaviorControl); ++ for (BehaviorControl behavior : behaviors) { ++ if (behavior.getStatus() == Behavior.Status.RUNNING) { ++ runningBehaviorsCache.add(behavior); + } + } + } + } + +- return list; ++ lastRunningBehaviorCheck = currentTick; ++ ++ return runningBehaviorsCache; ++ } ++ ++ // Helper method to get current tick ++ private long getCurrentTick() { ++ // This should be implemented to return the current game tick ++ return System.nanoTime() / 50_000_000; // Approximate tick time of 50ms + } ++ // Leaf end - Alternative Brain Behaviour + + public void useDefaultActivity() { + this.setActiveActivity(this.defaultActivity); diff --git a/leaf-server/minecraft-patches/features/0123-Cache-eligible-players-for-despawn-checks.patch b/leaf-server/minecraft-patches/features/0123-Cache-eligible-players-for-despawn-checks.patch new file mode 100644 index 00000000..9c6ba3c8 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0123-Cache-eligible-players-for-despawn-checks.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Fri, 14 Feb 2025 20:08:14 +0100 +Subject: [PATCH] Cache eligible players for despawn checks + + +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 1277b4b6b5283afebb78b403824e6a5aa1e5734f..427bac8001e43826fa4922ef3bb91c6d2d93f858 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -735,6 +735,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + return this.structureManager; + } + ++ public Player[] eligibleDespawnCheckingPlayerCache = new Player[0]; // Leaf - Cache eligible players for despawn checks ++ + public void tick(BooleanSupplier hasTimeLeft) { + this.handlingTick = true; + TickRateManager tickRateManager = this.tickRateManager(); +@@ -802,6 +804,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + + io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR ++ ++ // Leaf start - Cache eligible players for despawn checks ++ List serverPlayers = new ArrayList<>(players().size()); ++ for (int i = 0; i < players().size(); i++) { ++ ServerPlayer player = players().get(i); ++ if (net.minecraft.world.entity.EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { ++ serverPlayers.add(player); ++ } ++ } ++ ++ eligibleDespawnCheckingPlayerCache = serverPlayers.toArray(new Player[0]); ++ // Leaf end - Cache eligible players for despawn checks ++ + this.entityTickList + .forEach( + entity -> { +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index 01c30802a1d0127f2ed36efa7511c2ac6b2b5cfa..523d27ae8837bc4da2f993964aa99ab91617ec01 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -1569,6 +1569,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.containerMenu.broadcastChanges(); + } + ++ // Leaf start - Cache eligible players for despawn checks ++ @Override ++ public boolean isAlive() { ++ return !this.isRemoved() && this.entityData.get(DATA_HEALTH_ID) > 0.0f && !this.dead; ++ } ++ // Leaf end - Cache eligible players for despawn checks ++ + // CraftBukkit start - moved bed result checks from below into separate method + private Either getBedResult(BlockPos at, Direction direction) { + if (this.isSleeping() || !this.isAlive()) { +diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java +index b541236c39e3f36bcc619fffe83e32987df20adf..67d9415a53813675d9b7dadf928756d59204208e 100644 +--- a/net/minecraft/world/entity/Mob.java ++++ b/net/minecraft/world/entity/Mob.java +@@ -854,7 +854,24 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { +- Entity nearestPlayer = this.level().findNearbyPlayer(this, -1.0, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper - Affects Spawning API ++ // Leaf start - Cache eligible players for despawn checks ++ Entity nearestPlayer = null; ++ ++ if (this.level() instanceof ServerLevel serverLevel) { ++ double minDist = Double.MAX_VALUE; ++ for (int i = 0; i < serverLevel.eligibleDespawnCheckingPlayerCache.length; i++) { ++ Player cachedPlayer = serverLevel.eligibleDespawnCheckingPlayerCache[i]; ++ double d1 = cachedPlayer.distanceToSqr(this); ++ if (d1 <= minDist) { ++ minDist = d1; ++ nearestPlayer = cachedPlayer; ++ } ++ } ++ } else { ++ nearestPlayer = this.level().findNearbyPlayer(this, -1.0, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper - Affects Spawning API ++ } ++ // Leaf end - Cache eligible players for despawn checks ++ + if (nearestPlayer != null) { + // Paper start - Configurable despawn distances + final io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DespawnRangePair despawnRangePair = this.level().paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()); diff --git a/leaf-server/minecraft-patches/features/0124-Slightly-optimise-getNearestPlayer.patch b/leaf-server/minecraft-patches/features/0124-Slightly-optimise-getNearestPlayer.patch new file mode 100644 index 00000000..9fb38c3c --- /dev/null +++ b/leaf-server/minecraft-patches/features/0124-Slightly-optimise-getNearestPlayer.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sun, 16 Feb 2025 09:21:50 +0100 +Subject: [PATCH] Slightly optimise getNearestPlayer + + +diff --git a/net/minecraft/world/level/EntityGetter.java b/net/minecraft/world/level/EntityGetter.java +index 670860df81a3abfc1b8b53be505fce0ee32ee2c4..083a2b5da246113913bcd5d0b2b9be42cf0554d9 100644 +--- a/net/minecraft/world/level/EntityGetter.java ++++ b/net/minecraft/world/level/EntityGetter.java +@@ -201,23 +201,42 @@ public interface EntityGetter extends ca.spottedleaf.moonrise.patches.chunk_syst + } + // Paper end - Affects Spawning API + ++ // Leaf start - Slightly optimise getNearestPlayer + @Nullable + default Player getNearestPlayer(double x, double y, double z, double distance, @Nullable Predicate predicate) { +- double d = -1.0; ++ if (distance < 0.0) { ++ distance = Double.MAX_VALUE; ++ } else { ++ distance = distance * distance; ++ } ++ + Player player = null; + +- for (Player player1 : this.players()) { +- if (predicate == null || predicate.test(player1)) { ++ if (predicate == null) { ++ for (int i = 0; i < this.players().size(); i++) { ++ Player player1 = this.players().get(i); + double d1 = player1.distanceToSqr(x, y, z); +- if ((distance < 0.0 || d1 < distance * distance) && (d == -1.0 || d1 < d)) { +- d = d1; ++ if (d1 < distance) { ++ distance = d1; + player = player1; + } + } ++ } else { ++ for (int i = 0; i < this.players().size(); i++) { ++ Player player1 = this.players().get(i); ++ if (predicate.test(player1)) { ++ double d1 = player1.distanceToSqr(x, y, z); ++ if (d1 < distance) { ++ distance = d1; ++ player = player1; ++ } ++ } ++ } + } + + return player; + } ++ // Leaf end - Slightly optimise getNearestPlayer + + // Paper start + default List findNearbyBukkitPlayers(double x, double y, double z, double radius, boolean notSpectator) { diff --git a/leaf-server/paper-patches/features/0003-Leaf-Commands.patch b/leaf-server/paper-patches/features/0003-Leaf-Commands.patch new file mode 100644 index 00000000..5a0c0a7f --- /dev/null +++ b/leaf-server/paper-patches/features/0003-Leaf-Commands.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> +Date: Mon, 4 Nov 2024 23:07:27 -0500 +Subject: [PATCH] Leaf Commands + + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java +index 7d66126c1f5957c109a2426d53f5d0072886309b..f623a1d9e580104e1ab8b7cf88b9d26212f8acd8 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java +@@ -6,6 +6,7 @@ import org.bukkit.util.permissions.DefaultPermissions; + public final class CraftDefaultPermissions { + private static final String ROOT = "minecraft"; + public static final String GALE_ROOT = "gale"; // Gale - set Gale permissions root ++ public static final String LEAF_ROOT = "leaf"; // Leaf - Leaf commands + + public static final String writeBooks = GALE_ROOT + ".writebooks"; // Gale - Pufferfish - make book writing configurable + diff --git a/leaf-server/paper-patches/features/0003-Pufferfish-Optimize-mob-spawning.patch b/leaf-server/paper-patches/features/0004-Pufferfish-Optimize-mob-spawning.patch similarity index 100% rename from leaf-server/paper-patches/features/0003-Pufferfish-Optimize-mob-spawning.patch rename to leaf-server/paper-patches/features/0004-Pufferfish-Optimize-mob-spawning.patch diff --git a/leaf-server/paper-patches/features/0004-Purpur-Server-Paper-Changes.patch b/leaf-server/paper-patches/features/0005-Purpur-Server-Paper-Changes.patch similarity index 100% rename from leaf-server/paper-patches/features/0004-Purpur-Server-Paper-Changes.patch rename to leaf-server/paper-patches/features/0005-Purpur-Server-Paper-Changes.patch diff --git a/leaf-server/paper-patches/features/0005-Fix-Pufferfish-and-Purpur-patches.patch b/leaf-server/paper-patches/features/0006-Fix-Pufferfish-and-Purpur-patches.patch similarity index 100% rename from leaf-server/paper-patches/features/0005-Fix-Pufferfish-and-Purpur-patches.patch rename to leaf-server/paper-patches/features/0006-Fix-Pufferfish-and-Purpur-patches.patch diff --git a/leaf-server/paper-patches/features/0006-Remove-Timings.patch b/leaf-server/paper-patches/features/0007-Remove-Timings.patch similarity index 100% rename from leaf-server/paper-patches/features/0006-Remove-Timings.patch rename to leaf-server/paper-patches/features/0007-Remove-Timings.patch diff --git a/leaf-server/paper-patches/features/0007-KeYi-Player-Skull-API.patch b/leaf-server/paper-patches/features/0008-KeYi-Player-Skull-API.patch similarity index 100% rename from leaf-server/paper-patches/features/0007-KeYi-Player-Skull-API.patch rename to leaf-server/paper-patches/features/0008-KeYi-Player-Skull-API.patch diff --git a/leaf-server/paper-patches/features/0008-Slice-Smooth-Teleports.patch b/leaf-server/paper-patches/features/0009-Slice-Smooth-Teleports.patch similarity index 94% rename from leaf-server/paper-patches/features/0008-Slice-Smooth-Teleports.patch rename to leaf-server/paper-patches/features/0009-Slice-Smooth-Teleports.patch index 6cc719c0..cd54e085 100644 --- a/leaf-server/paper-patches/features/0008-Slice-Smooth-Teleports.patch +++ b/leaf-server/paper-patches/features/0009-Slice-Smooth-Teleports.patch @@ -9,7 +9,7 @@ Original project: https://github.com/Cryptite/Slice Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 9604dbd470a58790637f4caa691043ff8b9b9721..add4414067eaaaa2cc5fa3e02aa6cd2a3cd5dadc 100644 +index 7b7bb03adbf6aa4f088b2930d2ae702ce0189efa..7c87ad4f7802a0d35b01168d9147fea423dac363 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1384,6 +1384,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/leaf-server/paper-patches/features/0009-Leaves-Protocol-Core.patch b/leaf-server/paper-patches/features/0010-Leaves-Protocol-Core.patch similarity index 100% rename from leaf-server/paper-patches/features/0009-Leaves-Protocol-Core.patch rename to leaf-server/paper-patches/features/0010-Leaves-Protocol-Core.patch diff --git a/leaf-server/paper-patches/features/0010-Leaves-Replay-Mod-API.patch b/leaf-server/paper-patches/features/0011-Leaves-Replay-Mod-API.patch similarity index 98% rename from leaf-server/paper-patches/features/0010-Leaves-Replay-Mod-API.patch rename to leaf-server/paper-patches/features/0011-Leaves-Replay-Mod-API.patch index 591cc4fe..ef4d77b4 100644 --- a/leaf-server/paper-patches/features/0010-Leaves-Replay-Mod-API.patch +++ b/leaf-server/paper-patches/features/0011-Leaves-Replay-Mod-API.patch @@ -74,7 +74,7 @@ index 8635cd772c5c2ae0ba326812ff2a1a179285a86f..cc024874fbde9678bdddfdca7c250808 if (entity instanceof EnderDragonPart complexPart) { if (complexPart.parentMob instanceof EnderDragon) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index add4414067eaaaa2cc5fa3e02aa6cd2a3cd5dadc..020f6fdb1e7a17a6189cefb9c2350289e2e0e10b 100644 +index 7c87ad4f7802a0d35b01168d9147fea423dac363..583744ac37c85354c3d4a40b1f0e0310b86c23c9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -2284,7 +2284,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/leaf-server/paper-patches/features/0011-Skip-event-if-no-listeners.patch b/leaf-server/paper-patches/features/0012-Skip-event-if-no-listeners.patch similarity index 100% rename from leaf-server/paper-patches/features/0011-Skip-event-if-no-listeners.patch rename to leaf-server/paper-patches/features/0012-Skip-event-if-no-listeners.patch diff --git a/leaf-server/paper-patches/features/0012-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch b/leaf-server/paper-patches/features/0013-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch similarity index 98% rename from leaf-server/paper-patches/features/0012-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch rename to leaf-server/paper-patches/features/0013-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch index bae29166..3846c779 100644 --- a/leaf-server/paper-patches/features/0012-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch +++ b/leaf-server/paper-patches/features/0013-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch @@ -75,7 +75,7 @@ index c03608fec96b51e1867f43d8f42e5aefb1520e46..bb56c56cdbd8a15803e85412b9c15b59 throw new IllegalStateException("Ticking retired scheduler"); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 3235ec3415407d1f4fa420d398364fd62f4fd135..83812f3d976d5344984a59ecffc901a3c55bc5a5 100644 +index cc024874fbde9678bdddfdca7c25080869d66de2..edcd209798740f31cb302f36d7864a0d8ea1d561 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -75,7 +75,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { diff --git a/leaf-server/paper-patches/features/0013-SparklyPaper-Optimize-canSee-checks.patch b/leaf-server/paper-patches/features/0014-SparklyPaper-Optimize-canSee-checks.patch similarity index 97% rename from leaf-server/paper-patches/features/0013-SparklyPaper-Optimize-canSee-checks.patch rename to leaf-server/paper-patches/features/0014-SparklyPaper-Optimize-canSee-checks.patch index f1dddfcf..f253d9bc 100644 --- a/leaf-server/paper-patches/features/0013-SparklyPaper-Optimize-canSee-checks.patch +++ b/leaf-server/paper-patches/features/0014-SparklyPaper-Optimize-canSee-checks.patch @@ -16,7 +16,7 @@ This seems stupid, but it does seem that it improves the performance a bit, and We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 020f6fdb1e7a17a6189cefb9c2350289e2e0e10b..ecf97945743b3988d910a7f5b010732d4b31526b 100644 +index 583744ac37c85354c3d4a40b1f0e0310b86c23c9..49702db99964b0e6b1a4a058b08f6d72a7d8bd70 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -214,7 +214,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/leaf-server/paper-patches/features/0014-Including-5s-in-getTPS.patch b/leaf-server/paper-patches/features/0015-Including-5s-in-getTPS.patch similarity index 100% rename from leaf-server/paper-patches/features/0014-Including-5s-in-getTPS.patch rename to leaf-server/paper-patches/features/0015-Including-5s-in-getTPS.patch diff --git a/leaf-server/paper-patches/features/0015-Don-t-throw-exception-on-missing-ResourceKey-value.patch b/leaf-server/paper-patches/features/0016-Don-t-throw-exception-on-missing-ResourceKey-value.patch similarity index 100% rename from leaf-server/paper-patches/features/0015-Don-t-throw-exception-on-missing-ResourceKey-value.patch rename to leaf-server/paper-patches/features/0016-Don-t-throw-exception-on-missing-ResourceKey-value.patch diff --git a/leaf-server/paper-patches/features/0016-Virtual-Thread-for-async-scheduler.patch b/leaf-server/paper-patches/features/0017-Virtual-Thread-for-async-scheduler.patch similarity index 100% rename from leaf-server/paper-patches/features/0016-Virtual-Thread-for-async-scheduler.patch rename to leaf-server/paper-patches/features/0017-Virtual-Thread-for-async-scheduler.patch diff --git a/leaf-server/paper-patches/features/0017-Mirai-Configurable-chat-message-signatures.patch b/leaf-server/paper-patches/features/0018-Mirai-Configurable-chat-message-signatures.patch similarity index 100% rename from leaf-server/paper-patches/features/0017-Mirai-Configurable-chat-message-signatures.patch rename to leaf-server/paper-patches/features/0018-Mirai-Configurable-chat-message-signatures.patch diff --git a/leaf-server/paper-patches/features/0018-Matter-Secure-Seed.patch b/leaf-server/paper-patches/features/0019-Matter-Secure-Seed.patch similarity index 100% rename from leaf-server/paper-patches/features/0018-Matter-Secure-Seed.patch rename to leaf-server/paper-patches/features/0019-Matter-Secure-Seed.patch diff --git a/leaf-server/paper-patches/features/0019-Faster-random-generator.patch b/leaf-server/paper-patches/features/0020-Faster-random-generator.patch similarity index 100% rename from leaf-server/paper-patches/features/0019-Faster-random-generator.patch rename to leaf-server/paper-patches/features/0020-Faster-random-generator.patch diff --git a/leaf-server/paper-patches/features/0020-Configurable-unknown-command-message.patch b/leaf-server/paper-patches/features/0021-Configurable-unknown-command-message.patch similarity index 100% rename from leaf-server/paper-patches/features/0020-Configurable-unknown-command-message.patch rename to leaf-server/paper-patches/features/0021-Configurable-unknown-command-message.patch diff --git a/leaf-server/paper-patches/features/0021-Replace-world-map-with-optimized-collection.patch b/leaf-server/paper-patches/features/0022-Replace-world-map-with-optimized-collection.patch similarity index 100% rename from leaf-server/paper-patches/features/0021-Replace-world-map-with-optimized-collection.patch rename to leaf-server/paper-patches/features/0022-Replace-world-map-with-optimized-collection.patch diff --git a/leaf-server/paper-patches/features/0022-Cache-CraftEntityType-minecraftToBukkit-convert.patch b/leaf-server/paper-patches/features/0023-Cache-CraftEntityType-minecraftToBukkit-convert.patch similarity index 100% rename from leaf-server/paper-patches/features/0022-Cache-CraftEntityType-minecraftToBukkit-convert.patch rename to leaf-server/paper-patches/features/0023-Cache-CraftEntityType-minecraftToBukkit-convert.patch diff --git a/leaf-server/paper-patches/features/0023-Multithreaded-Tracker.patch b/leaf-server/paper-patches/features/0024-Multithreaded-Tracker.patch similarity index 100% rename from leaf-server/paper-patches/features/0023-Multithreaded-Tracker.patch rename to leaf-server/paper-patches/features/0024-Multithreaded-Tracker.patch diff --git a/leaf-server/paper-patches/features/0024-Asynchronous-locator.patch b/leaf-server/paper-patches/features/0025-Asynchronous-locator.patch similarity index 100% rename from leaf-server/paper-patches/features/0024-Asynchronous-locator.patch rename to leaf-server/paper-patches/features/0025-Asynchronous-locator.patch diff --git a/leaf-server/paper-patches/features/0025-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch b/leaf-server/paper-patches/features/0026-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch similarity index 100% rename from leaf-server/paper-patches/features/0025-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch rename to leaf-server/paper-patches/features/0026-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch diff --git a/leaf-server/paper-patches/features/0026-Faster-CraftServer-getworlds-list-creation.patch b/leaf-server/paper-patches/features/0027-Faster-CraftServer-getworlds-list-creation.patch similarity index 100% rename from leaf-server/paper-patches/features/0026-Faster-CraftServer-getworlds-list-creation.patch rename to leaf-server/paper-patches/features/0027-Faster-CraftServer-getworlds-list-creation.patch diff --git a/leaf-server/paper-patches/features/0027-Cache-chunk-key.patch b/leaf-server/paper-patches/features/0028-Cache-chunk-key.patch similarity index 100% rename from leaf-server/paper-patches/features/0027-Cache-chunk-key.patch rename to leaf-server/paper-patches/features/0028-Cache-chunk-key.patch diff --git a/leaf-server/paper-patches/features/0028-Async-structure-locate-api.patch b/leaf-server/paper-patches/features/0029-Async-structure-locate-api.patch similarity index 100% rename from leaf-server/paper-patches/features/0028-Async-structure-locate-api.patch rename to leaf-server/paper-patches/features/0029-Async-structure-locate-api.patch diff --git a/leaf-server/paper-patches/features/0029-PlayerInventoryOverflowEvent.patch b/leaf-server/paper-patches/features/0030-PlayerInventoryOverflowEvent.patch similarity index 100% rename from leaf-server/paper-patches/features/0029-PlayerInventoryOverflowEvent.patch rename to leaf-server/paper-patches/features/0030-PlayerInventoryOverflowEvent.patch diff --git a/leaf-server/src/main/java/org/dreeam/leaf/command/LeafCommand.java b/leaf-server/src/main/java/org/dreeam/leaf/command/LeafCommand.java new file mode 100644 index 00000000..251020ca --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/command/LeafCommand.java @@ -0,0 +1,174 @@ +package org.dreeam.leaf.command; + +import io.papermc.paper.command.CommandUtil; +import it.unimi.dsi.fastutil.Pair; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.minecraft.Util; +import org.dreeam.leaf.command.subcommands.ReloadCommand; +import org.dreeam.leaf.command.subcommands.VersionCommand; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +public final class LeafCommand extends Command { + + public static final String COMMAND_LABEL = "leaf"; + public static final String BASE_PERM = LeafCommands.COMMAND_BASE_PERM + "." + COMMAND_LABEL; + private static final Permission basePermission = new Permission(BASE_PERM, PermissionDefault.OP); + // subcommand label -> subcommand + private static final LeafSubcommand RELOAD_SUBCOMMAND = new ReloadCommand(); + private static final LeafSubcommand VERSION_SUBCOMMAND = new VersionCommand(); + private static final Map SUBCOMMANDS = Util.make(() -> { + final Map, LeafSubcommand> commands = new HashMap<>(); + + commands.put(Set.of(ReloadCommand.LITERAL_ARGUMENT), RELOAD_SUBCOMMAND); + commands.put(Set.of(VersionCommand.LITERAL_ARGUMENT), VERSION_SUBCOMMAND); + + return commands.entrySet().stream() + .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + }); + // alias -> subcommand label + private static final Map ALIASES = Util.make(() -> { + final Map> aliases = new HashMap<>(); + + aliases.put(VersionCommand.LITERAL_ARGUMENT, Set.of("ver")); + + return aliases.entrySet().stream() + .flatMap(entry -> entry.getValue().stream().map(s -> Map.entry(s, entry.getKey()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + }); + + private String createUsageMessage(Collection arguments) { + return "/" + COMMAND_LABEL + " [" + String.join(" | ", arguments) + "]"; + } + + public LeafCommand() { + super(COMMAND_LABEL); + this.description = "Leaf related commands"; + this.usageMessage = this.createUsageMessage(SUBCOMMANDS.keySet()); + final List permissions = SUBCOMMANDS.values().stream().map(LeafSubcommand::getPermission).filter(Objects::nonNull).toList(); + this.setPermission(BASE_PERM); + final PluginManager pluginManager = Bukkit.getServer().getPluginManager(); + pluginManager.addPermission(basePermission); + for (final Permission permission : permissions) { + pluginManager.addPermission(permission); + } + } + + @Override + public @NotNull List tabComplete( + final @NotNull CommandSender sender, + final @NotNull String alias, + final String[] args, + final @Nullable Location location + ) throws IllegalArgumentException { + if (args.length <= 1) { + List subCommandArguments = new ArrayList<>(SUBCOMMANDS.size()); + + for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { + if (subCommandEntry.getValue().testPermission(sender)) { + subCommandArguments.add(subCommandEntry.getKey()); + } + } + + return CommandUtil.getListMatchingLast(sender, args, subCommandArguments); + } + + final @Nullable Pair subCommand = resolveCommand(args[0]); + + if (subCommand != null && subCommand.second().testPermission(sender)) { + return subCommand.second().tabComplete(sender, subCommand.first(), Arrays.copyOfRange(args, 1, args.length)); + } + + return Collections.emptyList(); + } + + private boolean testHasOnePermission(CommandSender sender) { + for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { + if (subCommandEntry.getValue().testPermission(sender)) { + return true; + } + } + + return false; + } + + @Override + public boolean execute( + final CommandSender sender, + final @NotNull String commandLabel, + final String[] args + ) { + // Check if the sender has the base permission and at least one specific permission + if (!sender.hasPermission(basePermission) || !this.testHasOnePermission(sender)) { + sender.sendMessage(Bukkit.permissionMessage()); + return true; + } + + // Determine the usage message with the subcommands they can perform + List subCommandArguments = new ArrayList<>(SUBCOMMANDS.size()); + for (Map.Entry subCommandEntry : SUBCOMMANDS.entrySet()) { + if (subCommandEntry.getValue().testPermission(sender)) { + subCommandArguments.add(subCommandEntry.getKey()); + } + } + + String specificUsageMessage = this.createUsageMessage(subCommandArguments); + + // If they did not give a subcommand + if (args.length == 0) { + sender.sendMessage(Component.text("Command usage: " + specificUsageMessage, NamedTextColor.GRAY)); + return false; + } + + // If they do not have permission for the subcommand they gave, or the argument is not a valid subcommand + final @Nullable Pair subCommand = resolveCommand(args[0]); + if (subCommand == null || !subCommand.second().testPermission(sender)) { + sender.sendMessage(Component.text("Usage: " + specificUsageMessage, NamedTextColor.RED)); + return false; + } + + // Execute the subcommand + final String[] choppedArgs = Arrays.copyOfRange(args, 1, args.length); + return subCommand.second().execute(sender, subCommand.first(), choppedArgs); + + } + + private static @Nullable Pair resolveCommand(String label) { + label = label.toLowerCase(Locale.ENGLISH); + @Nullable LeafSubcommand subCommand = SUBCOMMANDS.get(label); + if (subCommand == null) { + final @Nullable String command = ALIASES.get(label); + if (command != null) { + label = command; + subCommand = SUBCOMMANDS.get(command); + } + } + + if (subCommand != null) { + return Pair.of(label, subCommand); + } + + return null; + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/command/LeafCommands.java b/leaf-server/src/main/java/org/dreeam/leaf/command/LeafCommands.java new file mode 100644 index 00000000..bfbf9843 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/command/LeafCommands.java @@ -0,0 +1,29 @@ +package org.dreeam.leaf.command; + +import net.minecraft.server.MinecraftServer; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.bukkit.command.Command; +import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions; + +import java.util.HashMap; +import java.util.Map; + +@DefaultQualifier(NonNull.class) +public final class LeafCommands { + + public static final String COMMAND_BASE_PERM = CraftDefaultPermissions.LEAF_ROOT + ".command"; + + private LeafCommands() { + } + + private static final Map COMMANDS = new HashMap<>(); + + static { + COMMANDS.put(LeafCommand.COMMAND_LABEL, new LeafCommand()); + } + + public static void registerCommands(final MinecraftServer server) { + COMMANDS.forEach((s, command) -> server.server.getCommandMap().register(s, "Leaf", command)); + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/command/LeafSubcommand.java b/leaf-server/src/main/java/org/dreeam/leaf/command/LeafSubcommand.java new file mode 100644 index 00000000..a89df9a6 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/command/LeafSubcommand.java @@ -0,0 +1,24 @@ +package org.dreeam.leaf.command; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.jetbrains.annotations.Nullable; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; + +import java.util.Collections; +import java.util.List; + +@DefaultQualifier(NonNull.class) +public interface LeafSubcommand { + + boolean execute(CommandSender sender, String subCommand, String[] args); + + default List tabComplete(final CommandSender sender, final String subCommand, final String[] args) { + return Collections.emptyList(); + } + + boolean testPermission(CommandSender sender); + + @Nullable Permission getPermission(); +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/command/PermissionedLeafSubcommand.java b/leaf-server/src/main/java/org/dreeam/leaf/command/PermissionedLeafSubcommand.java new file mode 100644 index 00000000..63f7404b --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/command/PermissionedLeafSubcommand.java @@ -0,0 +1,30 @@ +package org.dreeam.leaf.command; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + +public abstract class PermissionedLeafSubcommand implements LeafSubcommand { + + public final Permission permission; + + protected PermissionedLeafSubcommand(Permission permission) { + this.permission = permission; + } + + protected PermissionedLeafSubcommand(String permission, PermissionDefault permissionDefault) { + this(new Permission(permission, permissionDefault)); + } + + @Override + public boolean testPermission(@NotNull CommandSender sender) { + return sender.hasPermission(this.permission); + } + + @Override + public @Nullable Permission getPermission() { + return this.permission; + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/command/subcommands/ReloadCommand.java b/leaf-server/src/main/java/org/dreeam/leaf/command/subcommands/ReloadCommand.java new file mode 100644 index 00000000..0f172d13 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/command/subcommands/ReloadCommand.java @@ -0,0 +1,35 @@ +package org.dreeam.leaf.command.subcommands; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.dreeam.leaf.command.LeafCommand; +import org.dreeam.leaf.command.PermissionedLeafSubcommand; +import org.dreeam.leaf.config.LeafConfig; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.PermissionDefault; + +@DefaultQualifier(NonNull.class) +public final class ReloadCommand extends PermissionedLeafSubcommand { + + public final static String LITERAL_ARGUMENT = "reload"; + public static final String PERM = LeafCommand.BASE_PERM + "." + LITERAL_ARGUMENT; + + public ReloadCommand() { + super(PERM, PermissionDefault.OP); + } + + @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + this.doReload(sender); + return true; + } + + private void doReload(final CommandSender sender) { + Command.broadcastCommandMessage(sender, Component.text("Reloading Leaf config...", NamedTextColor.GREEN)); + + LeafConfig.reloadAsync(sender); + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/command/subcommands/VersionCommand.java b/leaf-server/src/main/java/org/dreeam/leaf/command/subcommands/VersionCommand.java new file mode 100644 index 00000000..6689cc36 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/command/subcommands/VersionCommand.java @@ -0,0 +1,38 @@ +package org.dreeam.leaf.command.subcommands; + +import net.minecraft.server.MinecraftServer; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; +import org.dreeam.leaf.command.LeafCommand; +import org.dreeam.leaf.command.PermissionedLeafSubcommand; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.PermissionDefault; + +@DefaultQualifier(NonNull.class) +public final class VersionCommand extends PermissionedLeafSubcommand { + + public final static String LITERAL_ARGUMENT = "version"; + public static final String PERM = LeafCommand.BASE_PERM + "." + LITERAL_ARGUMENT; + + public VersionCommand() { + super(PERM, PermissionDefault.TRUE); + } + + @Override + public boolean execute(final CommandSender sender, final String subCommand, final String[] args) { + final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); + + if (ver != null) { + ver.execute(sender, LeafCommand.COMMAND_LABEL, me.titaniumtown.ArrayConstants.emptyStringArray); // Gale - JettPack - reduce array allocations + } + + return true; + } + + @Override + public boolean testPermission(CommandSender sender) { + return super.testPermission(sender) && sender.hasPermission("bukkit.command.version"); + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/ConfigModules.java b/leaf-server/src/main/java/org/dreeam/leaf/config/ConfigModules.java index eedc98c5..5c9939df 100644 --- a/leaf-server/src/main/java/org/dreeam/leaf/config/ConfigModules.java +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/ConfigModules.java @@ -36,7 +36,7 @@ public abstract class ConfigModules extends LeafConfig { } } if (!enabledExperimentalModules.isEmpty()) { - LeafConfig.LOGGER.warn("You have following experimental module(s) enabled: {}, please proceed with caution!", enabledExperimentalModules.stream().map(f -> f.getClass().getSimpleName() + "." + f.getName()).toList()); + LeafConfig.LOGGER.warn("You have following experimental module(s) enabled: {}, please proceed with caution!", enabledExperimentalModules.stream().map(f -> f.getDeclaringClass().getSimpleName() + "." + f.getName()).toList()); } } diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/OnlyPlayerPushable.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/OnlyPlayerPushable.java new file mode 100644 index 00000000..4ec9f29f --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/gameplay/OnlyPlayerPushable.java @@ -0,0 +1,21 @@ +package org.dreeam.leaf.config.modules.gameplay; + +import org.dreeam.leaf.config.ConfigModules; +import org.dreeam.leaf.config.EnumConfigCategory; + +public class OnlyPlayerPushable extends ConfigModules { + + public String getBasePath() { + return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".only-player-pushable"; + } + + public static boolean enabled = false; + + @Override + public void onLoaded() { + enabled = config.getBoolean(getBasePath(), enabled, config.pickStringRegionBased( + "Enable to make only player pushable", + "是否只允许玩家被实体推动" + )); + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/BrainRunningBehaviorCacheUpdate.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/BrainRunningBehaviorCacheUpdate.java new file mode 100644 index 00000000..f1ae5bf9 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/opt/BrainRunningBehaviorCacheUpdate.java @@ -0,0 +1,21 @@ +package org.dreeam.leaf.config.modules.opt; + +import org.dreeam.leaf.config.ConfigModules; +import org.dreeam.leaf.config.EnumConfigCategory; + +public class BrainRunningBehaviorCacheUpdate extends ConfigModules { + + public String getBasePath() { + return EnumConfigCategory.PERF.getBaseKeyName(); + } + + public static int interval = 5; + + @Override + public void onLoaded() { + interval = config.getInt(getBasePath() + ".entity-running-behavior-cache-update-interval", interval, + config.pickStringRegionBased( + "How often entity update current brain running behavior list.", + "生物更新现有 Brain Behavior 列表缓存的间隔.")); + } +} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/util/list/BlockEntityTickersList.java b/leaf-server/src/main/java/org/dreeam/leaf/util/list/BlockEntityTickersList.java new file mode 100644 index 00000000..48201f62 --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/util/list/BlockEntityTickersList.java @@ -0,0 +1,103 @@ +package org.dreeam.leaf.util.list; + +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.world.level.block.entity.TickingBlockEntity; + +import java.util.Arrays; +import java.util.Collection; + +/** + * A list for ServerLevel's blockEntityTickers + *

+ * This list behaves identically to ObjectArrayList, but it has an additional method, `removeAllByIndex`, that allows a list of integers to be passed indicating what + * indexes should be deleted from the list + *

+ * This is faster than using removeAll, since we don't need to compare the identity of each block entity, and faster than looping thru each index manually and deleting with remove, + * since we don't need to resize the array every single remove. + */ +public final class BlockEntityTickersList extends ObjectArrayList { + + private final IntOpenHashSet toRemove = new IntOpenHashSet(); + private int startSearchFromIndex = -1; + + /** + * Creates a new array list with {@link #DEFAULT_INITIAL_CAPACITY} capacity. + */ + public BlockEntityTickersList() { + super(); + } + + /** + * Creates a new array list and fills it with a given collection. + * + * @param c a collection that will be used to fill the array list. + */ + public BlockEntityTickersList(final Collection c) { + super(c); + } + + /** + * Marks an entry as removed + * + * @param index the index of the item on the list to be marked as removed + */ + public void markAsRemoved(final int index) { + // The block entities list always loop starting from 0, so we only need to check if the startSearchFromIndex is -1 and that's it + if (this.startSearchFromIndex == -1) + this.startSearchFromIndex = index; + + this.toRemove.add(index); + } + + /** + * Removes elements that have been marked as removed. + */ + public void removeMarkedEntries() { + if (this.startSearchFromIndex == -1) // No entries in the list, skip + return; + + removeAllByIndex(startSearchFromIndex, toRemove); + toRemove.clear(); + this.startSearchFromIndex = -1; // Reset the start search index + } + + /** + * Removes elements by their index. + */ + private void removeAllByIndex(final int startSearchFromIndex, final IntOpenHashSet c) { // can't use Set because we want to avoid autoboxing when using contains + final int requiredMatches = c.size(); + if (requiredMatches == 0) + return; // exit early, we don't need to do anything + + final Object[] a = this.a; + int j = startSearchFromIndex; + int matches = 0; + for (int i = startSearchFromIndex; i < size; i++) { // If the user knows the first index to be removed, we can skip a lot of unnecessary comparsions + if (!c.contains(i)) { + // TODO: It can be possible to optimize this loop by tracking the start/finish and then using arraycopy to "skip" the elements, + // this would optimize cases where the index to be removed are far apart, HOWEVER it does have a big performance impact if you are doing + // "arraycopy" for each element + a[j++] = a[i]; + } else { + matches++; + } + + if (matches == requiredMatches) { // Exit the loop if we already removed everything, we don't need to check anything else + // We need to update the final size here, because we know that we already found everything! + // Because we know that the size must be currentSize - requiredMatches (because we have matched everything), let's update the value + // However, we need to copy the rest of the stuff over + if (i != (size - 1)) { // If it isn't the last index... + // i + 1 because we want to copy the *next* element over + // and the size - i - 1 is because we want to get the current size, minus the current index (which is i), and then - 1 because we want to copy -1 ahead (remember, we are adding +1 to copy the *next* element) + System.arraycopy(a, i + 1, a, j, size - i - 1); + } + j = size - requiredMatches; + break; + } + } + + Arrays.fill(a, j, size, null); + size = j; + } +}