diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0120-Remove-iterators-from-Inventory-contains.patch b/leaf-archived-patches/unapplied/server/minecraft-patches/features/0120-Remove-iterators-from-Inventory-contains.patch deleted file mode 100644 index 38c4d642..00000000 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0120-Remove-iterators-from-Inventory-contains.patch +++ /dev/null @@ -1,61 +0,0 @@ -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-archived-patches/unapplied/server/minecraft-patches/features/0126-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch b/leaf-archived-patches/unapplied/server/minecraft-patches/features/0126-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch deleted file mode 100644 index 792385ff..00000000 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0126-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Taiyou06 -Date: Sun, 16 Feb 2025 01:13:04 +0100 -Subject: [PATCH] Directly use the pre-filtered ticking chunks list as the - output - -This patch uses already pre filtered chunks, which completely skips the isChunkNearPlayer check - -diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index c80464d333bd37a9b8bc7cea2291c8c72e6f9bd6..b1f1b596a597d559aa672a3cb46a03917ad746af 100644 ---- a/net/minecraft/server/level/ServerChunkCache.java -+++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -592,14 +592,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - // Leaf end - Use ensureCapacity to pre-populate the size of ticking chunks list output - - for (int i = 0; i < size; ++i) { -- final ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i]; -- final LevelChunk levelChunk = chunkAndHolder.chunk(); -- -- if (!this.isChunkNearPlayer(chunkMap, levelChunk.getPos(), levelChunk)) { -- continue; -- } -- -- output.add(levelChunk); -+ output.add(raw[i].chunk()); // Leaf - Directly use the pre-filtered ticking chunks list as the output - } - // Paper end - chunk tick iteration optimisation - } diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0089-Asynchronous-locator.patch b/leaf-server/minecraft-patches/features/0168-Asynchronous-locator.patch similarity index 84% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0089-Asynchronous-locator.patch rename to leaf-server/minecraft-patches/features/0168-Asynchronous-locator.patch index ee20df93..687248d6 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0089-Asynchronous-locator.patch +++ b/leaf-server/minecraft-patches/features/0168-Asynchronous-locator.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/thebrightspark/AsyncLocator diff --git a/net/minecraft/server/commands/LocateCommand.java b/net/minecraft/server/commands/LocateCommand.java -index 13bcd8653d766cd0b754a22e9aab261fbc62b0a5..e3e7c4e4da0bc95b015bb84e470477782bdb691c 100644 +index 2723d5377567241921fef61952e474c1c0ee9bbf..0918b528e0310b12378e185b29a478ed188a2d58 100644 --- a/net/minecraft/server/commands/LocateCommand.java +++ b/net/minecraft/server/commands/LocateCommand.java @@ -109,6 +109,38 @@ public class LocateCommand { @@ -50,10 +50,10 @@ index 13bcd8653d766cd0b754a22e9aab261fbc62b0a5..e3e7c4e4da0bc95b015bb84e47047778 stopwatch.stop(); if (pair == null) { diff --git a/net/minecraft/world/entity/animal/Dolphin.java b/net/minecraft/world/entity/animal/Dolphin.java -index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f046700d4 100644 +index 87ba416479df56bad5d13c01e96e92e45b7802a3..2508645b62e7f935dee00fe87b3a6446dbd22cf2 100644 --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -500,6 +500,10 @@ public class Dolphin extends AgeableWaterCreature { +@@ -486,6 +486,10 @@ public class Dolphin extends AgeableWaterCreature { static class DolphinSwimToTreasureGoal extends Goal { private final Dolphin dolphin; private boolean stuck; @@ -64,7 +64,7 @@ index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f DolphinSwimToTreasureGoal(Dolphin dolphin) { this.dolphin = dolphin; -@@ -519,6 +523,11 @@ public class Dolphin extends AgeableWaterCreature { +@@ -505,6 +509,11 @@ public class Dolphin extends AgeableWaterCreature { @Override public boolean canContinueToUse() { @@ -73,10 +73,10 @@ index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f + return true; + } + // Leaf end - Asynchronous locator - BlockPos treasurePos = this.dolphin.getTreasurePos(); - return !BlockPos.containing(treasurePos.getX(), this.dolphin.getY(), treasurePos.getZ()).closerToCenterThan(this.dolphin.position(), 4.0) - && !this.stuck -@@ -532,6 +541,22 @@ public class Dolphin extends AgeableWaterCreature { + BlockPos blockPos = this.dolphin.treasurePos; + return blockPos != null + && !BlockPos.containing(blockPos.getX(), this.dolphin.getY(), blockPos.getZ()).closerToCenterThan(this.dolphin.position(), 4.0) +@@ -519,6 +528,22 @@ public class Dolphin extends AgeableWaterCreature { this.stuck = false; this.dolphin.getNavigation().stop(); BlockPos blockPos = this.dolphin.blockPosition(); @@ -86,7 +86,7 @@ index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f + .thenOnServerThread(pos -> { + asyncLocator$locateTask = null; + if (pos != null) { -+ this.dolphin.setTreasurePos(pos); ++ this.dolphin.treasurePos = pos; + serverLevel.broadcastEntityEvent(this.dolphin, (byte) 38); + } else { + this.stuck = true; @@ -98,8 +98,8 @@ index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f + // Leaf end - Asynchronous locator BlockPos blockPos1 = serverLevel.findNearestMapStructure(StructureTags.DOLPHIN_LOCATED, blockPos, 50, false); if (blockPos1 != null) { - this.dolphin.setTreasurePos(blockPos1); -@@ -544,6 +569,12 @@ public class Dolphin extends AgeableWaterCreature { + this.dolphin.treasurePos = blockPos1; +@@ -531,6 +556,12 @@ public class Dolphin extends AgeableWaterCreature { @Override public void stop() { @@ -109,10 +109,10 @@ index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f + this.asyncLocator$locateTask = null; + } + // Leaf end - Asynchronous locator - BlockPos treasurePos = this.dolphin.getTreasurePos(); - if (BlockPos.containing(treasurePos.getX(), this.dolphin.getY(), treasurePos.getZ()).closerToCenterThan(this.dolphin.position(), 4.0) || this.stuck - ) -@@ -554,6 +585,11 @@ public class Dolphin extends AgeableWaterCreature { + BlockPos blockPos = this.dolphin.treasurePos; + if (blockPos == null + || BlockPos.containing(blockPos.getX(), this.dolphin.getY(), blockPos.getZ()).closerToCenterThan(this.dolphin.position(), 4.0) +@@ -541,6 +572,11 @@ public class Dolphin extends AgeableWaterCreature { @Override public void tick() { @@ -121,14 +121,14 @@ index 7003b532182737a745491e397a967b72e6b308aa..3ed9652510976770f5661dd7b317f27f + return; + } + // Leaf end - Asynchronous locator - Level level = this.dolphin.level(); - if (this.dolphin.closeToNextPos() || this.dolphin.getNavigation().isDone()) { - Vec3 vec3 = Vec3.atCenterOf(this.dolphin.getTreasurePos()); + if (this.dolphin.treasurePos != null) { + Level level = this.dolphin.level(); + if (this.dolphin.closeToNextPos() || this.dolphin.getNavigation().isDone()) { diff --git a/net/minecraft/world/entity/projectile/EyeOfEnder.java b/net/minecraft/world/entity/projectile/EyeOfEnder.java -index 01a9bad80a30a7879a69b800258b616b4d986108..d4f49e40461a165ebd6635e9fec8fe56d7f1acf6 100644 +index 59941c605085d93357211939114ecf1b88aef05d..74ffcc5417dd20635a52a3e799436eaf18076a0e 100644 --- a/net/minecraft/world/entity/projectile/EyeOfEnder.java +++ b/net/minecraft/world/entity/projectile/EyeOfEnder.java -@@ -26,6 +26,7 @@ public class EyeOfEnder extends Entity implements ItemSupplier { +@@ -29,6 +29,7 @@ public class EyeOfEnder extends Entity implements ItemSupplier { public double tz; public int life; public boolean surviveAfterDeath; @@ -136,7 +136,7 @@ index 01a9bad80a30a7879a69b800258b616b4d986108..d4f49e40461a165ebd6635e9fec8fe56 public EyeOfEnder(EntityType entityType, Level level) { super(entityType, level); -@@ -112,6 +113,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier { +@@ -116,6 +117,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier { @Override public void tick() { super.tick(); @@ -149,10 +149,10 @@ index 01a9bad80a30a7879a69b800258b616b4d986108..d4f49e40461a165ebd6635e9fec8fe56 double d = this.getX() + deltaMovement.x; double d1 = this.getY() + deltaMovement.y; diff --git a/net/minecraft/world/item/EnderEyeItem.java b/net/minecraft/world/item/EnderEyeItem.java -index 02f2c38b5f9a503097dea44d5c79518b03b63f9a..a7aa09d7c9d5f95706349e426cd54a79e963c6f9 100644 +index 68f33de233b716055f791fd87fe3be981580375c..bd60cc8f7e37cba981792412a8ce7f71ea8b33f5 100644 --- a/net/minecraft/world/item/EnderEyeItem.java +++ b/net/minecraft/world/item/EnderEyeItem.java -@@ -103,14 +103,47 @@ public class EnderEyeItem extends Item { +@@ -105,14 +105,47 @@ public class EnderEyeItem extends Item { } else { player.startUsingItem(hand); if (level instanceof ServerLevel serverLevel) { @@ -202,7 +202,7 @@ index 02f2c38b5f9a503097dea44d5c79518b03b63f9a..a7aa09d7c9d5f95706349e426cd54a79 level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); // CraftBukkit start if (!level.addFreshEntity(eyeOfEnder)) { -@@ -124,7 +157,7 @@ public class EnderEyeItem extends Item { +@@ -126,7 +159,7 @@ public class EnderEyeItem extends Item { float f = Mth.lerp(level.random.nextFloat(), 0.33F, 0.5F); level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.NEUTRAL, 1.0F, f); itemInHand.consume(1, player); diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0090-Smart-sort-entities-in-NearestLivingEntitySensor.patch b/leaf-server/minecraft-patches/features/0169-Smart-sort-entities-in-NearestLivingEntitySensor.patch similarity index 100% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0090-Smart-sort-entities-in-NearestLivingEntitySensor.patch rename to leaf-server/minecraft-patches/features/0169-Smart-sort-entities-in-NearestLivingEntitySensor.patch diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0091-Further-reduce-memory-footprint-of-CompoundTag.patch b/leaf-server/minecraft-patches/features/0170-Further-reduce-memory-footprint-of-CompoundTag.patch similarity index 89% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0091-Further-reduce-memory-footprint-of-CompoundTag.patch rename to leaf-server/minecraft-patches/features/0170-Further-reduce-memory-footprint-of-CompoundTag.patch index c6aa7572..7bc6cf9b 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0091-Further-reduce-memory-footprint-of-CompoundTag.patch +++ b/leaf-server/minecraft-patches/features/0170-Further-reduce-memory-footprint-of-CompoundTag.patch @@ -7,10 +7,10 @@ Original license: GPLv3 Original project: https://github.com/embeddedt/ModernFix diff --git a/net/minecraft/nbt/CompoundTag.java b/net/minecraft/nbt/CompoundTag.java -index 3bce1e8ef90e95abd8b1111f1160f952d2493e69..468566e8175d71e1562a80fae8e5f0cd32318c35 100644 +index 052ca6beb06a3256fdf04bac5f2085ad622d7df0..bc6ddaac8cb6c3a5353ad434ae8167607fd21abc 100644 --- a/net/minecraft/nbt/CompoundTag.java +++ b/net/minecraft/nbt/CompoundTag.java -@@ -49,7 +49,7 @@ public class CompoundTag implements Tag { +@@ -54,7 +54,7 @@ public final class CompoundTag implements Tag { private static CompoundTag loadCompound(DataInput input, NbtAccounter nbtAccounter) throws IOException { nbtAccounter.accountBytes(48L); @@ -19,7 +19,7 @@ index 3bce1e8ef90e95abd8b1111f1160f952d2493e69..468566e8175d71e1562a80fae8e5f0cd byte b; while ((b = input.readByte()) != 0) { -@@ -166,7 +166,7 @@ public class CompoundTag implements Tag { +@@ -171,7 +171,7 @@ public final class CompoundTag implements Tag { } public CompoundTag() { @@ -28,7 +28,7 @@ index 3bce1e8ef90e95abd8b1111f1160f952d2493e69..468566e8175d71e1562a80fae8e5f0cd } @Override -@@ -497,6 +497,11 @@ public class CompoundTag implements Tag { +@@ -402,6 +402,11 @@ public final class CompoundTag implements Tag { @Override public CompoundTag copy() { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0092-Optimize-Entity-distanceToSqr.patch b/leaf-server/minecraft-patches/features/0171-Optimize-Entity-distanceToSqr.patch similarity index 93% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0092-Optimize-Entity-distanceToSqr.patch rename to leaf-server/minecraft-patches/features/0171-Optimize-Entity-distanceToSqr.patch index 2e0a9008..00ed14ab 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0092-Optimize-Entity-distanceToSqr.patch +++ b/leaf-server/minecraft-patches/features/0171-Optimize-Entity-distanceToSqr.patch @@ -8,10 +8,10 @@ avoids multiple casting in Entity#distanceTo, using Math#sqrt directly instead o these methods more able to be inlined by the JIT compiler. diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 4d88aa70c01e03baf8aea897b00f335c7be91f46..4544dd876d3cbcdb9b774b4a1f0c4737f3124bc5 100644 +index 753515c65a2b49db15ef6616cc7caf276fdbbeb1..a2e9306d9a5eef738f8225e98fb1cc1f4bbca504 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -2194,31 +2194,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2186,31 +2186,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return new Vec3(this.xOld, this.yOld, this.zOld); } @@ -43,7 +43,7 @@ index 4d88aa70c01e03baf8aea897b00f335c7be91f46..4544dd876d3cbcdb9b774b4a1f0c4737 public void playerTouch(Player player) { } -@@ -5230,4 +5205,34 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5248,4 +5223,34 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return false; } // Purpur end - Ridables diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0093-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch b/leaf-server/minecraft-patches/features/0172-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch similarity index 83% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0093-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch rename to leaf-server/minecraft-patches/features/0172-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch index c6ff8122..e83ddd93 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0093-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch +++ b/leaf-server/minecraft-patches/features/0172-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch @@ -9,15 +9,15 @@ Original project: https://github.com/starlis/empirecraft Also see Leaf's EMC-Don-t-use-snapshots-for-acquiring-blockstate diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index 3fd0f42618e5c2c683335d1d3e0bb74c6d32ef66..8f4d13d897ac92c6ea239da22029c8058bd82eaa 100644 +index d7a08a4ecac2bb4f5626fb53e27f8d50b6936f1c..129af0e69a3ec9525756b6825b795e4441de66c9 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -361,7 +361,7 @@ public abstract class BlockEntity { +@@ -363,7 +363,7 @@ public abstract class BlockEntity { + // CraftBukkit start - add method public org.bukkit.inventory.InventoryHolder getOwner() { - // Paper start - return getOwner(true); + return getOwner(org.dreeam.leaf.config.modules.opt.TileEntitySnapshotCreation.enabled); // Leaf - EMC - Don't use snapshots for TileEntity::getOwner } + public org.bukkit.inventory.InventoryHolder getOwner(boolean useSnapshot) { - // Paper end diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0094-Cache-tile-entity-position.patch b/leaf-server/minecraft-patches/features/0173-Cache-tile-entity-position.patch similarity index 86% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0094-Cache-tile-entity-position.patch rename to leaf-server/minecraft-patches/features/0173-Cache-tile-entity-position.patch index 7a2cb3c8..6c41c0d8 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0094-Cache-tile-entity-position.patch +++ b/leaf-server/minecraft-patches/features/0173-Cache-tile-entity-position.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Cache tile entity position Dreeam TODO: Check if there is a way to cache isRemoved without problem diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 290163335cf3967e2745442fd7d4d4fa16fb7bc0..238e015d4ff5fabb99e569118f253366d545d269 100644 +index 800fc055024c176d1830e1d2686f5d96131c8712..5325989f46bd288c5a6f1362ec17d3354d55abfd 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -936,10 +936,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -940,10 +940,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p private final T blockEntity; private final BlockEntityTicker ticker; private boolean loggedInvalidBlockState; @@ -22,7 +22,7 @@ index 290163335cf3967e2745442fd7d4d4fa16fb7bc0..238e015d4ff5fabb99e569118f253366 } @Override -@@ -980,7 +982,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -984,7 +986,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @Override public BlockPos getPos() { @@ -31,7 +31,7 @@ index 290163335cf3967e2745442fd7d4d4fa16fb7bc0..238e015d4ff5fabb99e569118f253366 } @Override -@@ -1007,13 +1009,16 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1011,13 +1013,16 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p static class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { private TickingBlockEntity ticker; @@ -48,7 +48,7 @@ index 290163335cf3967e2745442fd7d4d4fa16fb7bc0..238e015d4ff5fabb99e569118f253366 } @Override -@@ -1028,7 +1033,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1032,7 +1037,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @Override public BlockPos getPos() { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0095-TT20-Lag-compensation.patch b/leaf-server/minecraft-patches/features/0174-TT20-Lag-compensation.patch similarity index 86% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0095-TT20-Lag-compensation.patch rename to leaf-server/minecraft-patches/features/0174-TT20-Lag-compensation.patch index 732d462e..4c026d8f 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0095-TT20-Lag-compensation.patch +++ b/leaf-server/minecraft-patches/features/0174-TT20-Lag-compensation.patch @@ -7,10 +7,10 @@ Original license: AGPL-3.0 Original project: https://github.com/snackbag/TT20 diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 1cb60107d95296fc9e2c106d70838c057564abeb..c50a301a0c2365c2052aefc6a23fcf6fa82e1b9d 100644 +index 354823def23167feb1e7b35cd9db5ef1584e7e8c..ae1cff1416cd57977d755056307252118e6ae821 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1556,6 +1556,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { +@@ -462,20 +462,29 @@ public class Brain { } private void startEachNonRunningBehavior(ServerLevel level, E entity) { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0104-C2ME-Optimize-world-gen-math.patch b/leaf-server/minecraft-patches/features/0182-C2ME-Optimize-world-gen-math.patch similarity index 95% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0104-C2ME-Optimize-world-gen-math.patch rename to leaf-server/minecraft-patches/features/0182-C2ME-Optimize-world-gen-math.patch index 309809d8..c9f61f47 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0104-C2ME-Optimize-world-gen-math.patch +++ b/leaf-server/minecraft-patches/features/0182-C2ME-Optimize-world-gen-math.patch @@ -32,10 +32,10 @@ index 55ce935a2fab7e32904d9ff599867269035d703f..6e2b2d258e47dcca30a5ad9f4f492598 public int getMiddleBlockX() { diff --git a/net/minecraft/world/level/levelgen/Beardifier.java b/net/minecraft/world/level/levelgen/Beardifier.java -index 131923282c9ecbcb1d7f45a826da907c02bd2716..47b6519f40ed978c05d93023a0cdc1c9e13f033f 100644 +index 74d8202b5c9bb2a3ee832be70f95c0b5cbecb460..9ea92c7beee917e47f02e24982bb97ff7eee7c7d 100644 --- a/net/minecraft/world/level/levelgen/Beardifier.java +++ b/net/minecraft/world/level/levelgen/Beardifier.java -@@ -132,8 +132,15 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { +@@ -131,8 +131,15 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { } private static double getBuryContribution(double x, double y, double z) { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0105-Cache-chunk-key.patch b/leaf-server/minecraft-patches/features/0183-Cache-chunk-key.patch similarity index 68% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0105-Cache-chunk-key.patch rename to leaf-server/minecraft-patches/features/0183-Cache-chunk-key.patch index a9932a9c..b8106663 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0105-Cache-chunk-key.patch +++ b/leaf-server/minecraft-patches/features/0183-Cache-chunk-key.patch @@ -31,50 +31,50 @@ index 1b8193587814225c2ef2c5d9e667436eb50ff6c5..288a3eb57f3431dd624ad8a4b0868456 public ReferenceList getPlayersByChunk(final int chunkX, final int chunkZ, final NearbyMapType type) { diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -index b5817aa8f537593f6d9fc6b612c82ccccb250ac7..be820c6093dd2ae7642b9bee11edf65e3a8d7242 100644 +index f473999938840562b1007a789600342e5796a123..ea4010df54dbd17cdae22d671ea1e4bd7b685b3e 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -@@ -506,7 +506,7 @@ public final class ChunkHolderManager { +@@ -540,7 +540,7 @@ public final class ChunkHolderManager { - public boolean addTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, + public boolean addTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, final T identifier) { - return this.addTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); + return this.addTicketAtLevel(type, chunkPos.longKey, level, identifier); // Leaf - Cache chunk key } - public boolean addTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, -@@ -604,7 +604,7 @@ public final class ChunkHolderManager { + public boolean addTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, +@@ -687,7 +687,7 @@ public final class ChunkHolderManager { } - public boolean removeTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, final T identifier) { + public boolean removeTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, final T identifier) { - return this.removeTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); + return this.removeTicketAtLevel(type, chunkPos.longKey, level, identifier); // Leaf - Cache chunk key } - public boolean removeTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, final T identifier) { -@@ -1224,7 +1224,7 @@ public final class ChunkHolderManager { + public boolean removeTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, final T identifier) { +@@ -1309,7 +1309,7 @@ public final class ChunkHolderManager { } - public static TicketOperation addOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { + public static TicketOperation addOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { - return addOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier); + return addOp(chunk.longKey, type, ticketLevel, identifier); // Leaf - Cache chunk key } - public static TicketOperation addOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { -@@ -1236,7 +1236,7 @@ public final class ChunkHolderManager { + public static TicketOperation addOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { +@@ -1321,7 +1321,7 @@ public final class ChunkHolderManager { } - public static TicketOperation removeOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { + public static TicketOperation removeOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { - return removeOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier); + return removeOp(chunk.longKey, type, ticketLevel, identifier); // Leaf - Cache chunk key } - public static TicketOperation removeOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { + public static TicketOperation removeOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java -index 571db5f9bf94745a8afe2cd313e593fb15db5e37..1487b7d8be435b3fbad2aabd05796965b4775a87 100644 +index 51f4dd4f583dfbd16cb00f1cb4418d1044cecb1c..e1812910d7c3941dec3d4f1c90f4cf966a631de3 100644 --- a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java +++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java -@@ -818,7 +818,7 @@ public final class StarLightInterface { +@@ -817,7 +817,7 @@ public final class StarLightInterface { } public ServerChunkTasks queueChunkLightTask(final ChunkPos pos, final BooleanSupplier lightTask, final Priority priority) { @@ -83,11 +83,24 @@ index 571db5f9bf94745a8afe2cd313e593fb15db5e37..1487b7d8be435b3fbad2aabd05796965 if (valueInMap == null) { valueInMap = new ServerChunkTasks( keyInMap, ServerLightQueue.this.lightInterface, ServerLightQueue.this, priority +diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java +index fd3d0f6cb53bc8b6186f0d86575f21007b2c20ed..cddeeab73e7b981701a42c5aad6b47778d46b792 100644 +--- a/net/minecraft/server/level/DistanceManager.java ++++ b/net/minecraft/server/level/DistanceManager.java +@@ -178,7 +178,7 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches + for (int i = 0; i < size; ++i) { + final LevelChunk chunk = raw[i]; + +- action.accept(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunk.getPos())); ++ action.accept(chunk.coordinateKey); // Leaf - Cache chunk key + } + // Paper end - rewrite chunk system + } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 5423d8228c1da56135ae32b958f432d5b94707ed..95bed1e67758543a7aec12eee1229ee2c4057c88 100644 +index 889b7e8752129dd3b5ba196c4b29449615499515..b9bff011c0ffb0efdaccc65847be69aad1a70681 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 +@@ -503,7 +503,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public final void moonrise$markChunkForPlayerTicking(final LevelChunk chunk) { final ChunkPos pos = chunk.getPos(); @@ -96,15 +109,24 @@ index 5423d8228c1da56135ae32b958f432d5b94707ed..95bed1e67758543a7aec12eee1229ee2 return; } -@@ -2569,7 +2569,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2543,7 +2543,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - public boolean isNaturalSpawningAllowed(ChunkPos chunkPos) { + public boolean areEntitiesActuallyLoadedAndTicking(ChunkPos chunkPos) { // Paper start - rewrite chunk system - final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos)); + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos.longKey); // Leaf - Cache chunk key return chunkHolder != null && chunkHolder.isEntityTickingReady(); // Paper end - rewrite chunk system } +@@ -2558,7 +2558,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + + public boolean canSpawnEntitiesInChunk(ChunkPos chunkPos) { + // Paper start - rewrite chunk system +- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos)); ++ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos.longKey); // Leaf - Cache chunk key + return chunkHolder != null && chunkHolder.isEntityTickingReady() && this.getWorldBorder().isWithinBounds(chunkPos); + // Paper end - rewrite chunk system + } diff --git a/net/minecraft/world/level/ChunkPos.java b/net/minecraft/world/level/ChunkPos.java index 6e2b2d258e47dcca30a5ad9f4f492598f2bc21fb..f9af074e833a6dab96414750314a27b35ec07bfc 100644 --- a/net/minecraft/world/level/ChunkPos.java diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0106-Cache-random-tick-block-status.patch b/leaf-server/minecraft-patches/features/0184-Cache-random-tick-block-status.patch similarity index 97% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0106-Cache-random-tick-block-status.patch rename to leaf-server/minecraft-patches/features/0184-Cache-random-tick-block-status.patch index 62c19578..71491533 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0106-Cache-random-tick-block-status.patch +++ b/leaf-server/minecraft-patches/features/0184-Cache-random-tick-block-status.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Cache random tick block status diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index 412e7b1cf8c24f0ddf6d174967bedad576f10aba..b8ac6a9ba7b56ccd034757f7d135d272b8e69e90 100644 +index 03edf6dc751cc59ae1f16c23340e41668350b32a..963c51d14f87d2557a3d686fb8fe3ec9cba367b3 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -21,6 +21,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0107-Cache-part-of-canHoldFluid-result.patch b/leaf-server/minecraft-patches/features/0185-Cache-part-of-canHoldFluid-result.patch similarity index 88% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0107-Cache-part-of-canHoldFluid-result.patch rename to leaf-server/minecraft-patches/features/0185-Cache-part-of-canHoldFluid-result.patch index cc9557f9..01793ae4 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0107-Cache-part-of-canHoldFluid-result.patch +++ b/leaf-server/minecraft-patches/features/0185-Cache-part-of-canHoldFluid-result.patch @@ -10,10 +10,10 @@ which the contains iteration call is very expensive if called everytime In the test, it can improve ~30% performance in ~1577000 times of canHoldAnyFluid calls (~159ms -> ~111ms) diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index 7f46f33fa565fa1a3aedce5524f19be8ba420352..d35211b0cae66b1a40e89539507e55973313f46f 100644 +index 84f4d772bfe06383ca718b6a00d983e97e2e35f4..3219b9caa654c7a64e5e4a92178528e1104b34c7 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -454,6 +454,8 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -451,6 +451,8 @@ public abstract class BlockBehaviour implements FeatureElement { private VoxelShape[] occlusionShapesByFace; private boolean propagatesSkylightDown; private int lightBlock; @@ -22,7 +22,7 @@ index 7f46f33fa565fa1a3aedce5524f19be8ba420352..d35211b0cae66b1a40e89539507e5597 // Paper start - rewrite chunk system private boolean isConditionallyFullOpaque; -@@ -603,6 +605,8 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -600,6 +602,8 @@ public abstract class BlockBehaviour implements FeatureElement { this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState()); this.lightBlock = this.owner.getLightBlock(this.asState()); @@ -31,7 +31,7 @@ index 7f46f33fa565fa1a3aedce5524f19be8ba420352..d35211b0cae66b1a40e89539507e5597 // Paper start - rewrite chunk system this.isConditionallyFullOpaque = this.canOcclude & this.useShapeForLightOcclusion; // Paper end - rewrite chunk system -@@ -654,6 +658,18 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -651,6 +655,18 @@ public abstract class BlockBehaviour implements FeatureElement { return block != Blocks.COBWEB && block != Blocks.BAMBOO_SAPLING && this.isSolid(); } @@ -51,10 +51,10 @@ index 7f46f33fa565fa1a3aedce5524f19be8ba420352..d35211b0cae66b1a40e89539507e5597 public boolean isSolid() { return this.legacySolid; diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java -index 738defb8cbd9c63dc85c479911ebe2f795d0a815..4c2c2efd5380ff1fa5ad7553b51babae20f516ae 100644 +index 2a2883b4c38b8ac6e014dab66da0c141f6ac2a64..4625bd55e1cb01dfb9921dcd033f05b4a8f9ad74 100644 --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java -@@ -466,7 +466,7 @@ public abstract class FlowingFluid extends Fluid { +@@ -467,7 +467,7 @@ public abstract class FlowingFluid extends Fluid { } private static boolean canHoldFluid(BlockGetter level, BlockPos pos, BlockState state, Fluid fluid) { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0108-Configurable-tripwire-dupe.patch b/leaf-server/minecraft-patches/features/0186-Configurable-tripwire-dupe.patch similarity index 80% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0108-Configurable-tripwire-dupe.patch rename to leaf-server/minecraft-patches/features/0186-Configurable-tripwire-dupe.patch index 34599abd..422c7853 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0108-Configurable-tripwire-dupe.patch +++ b/leaf-server/minecraft-patches/features/0186-Configurable-tripwire-dupe.patch @@ -9,15 +9,15 @@ Note: this is different from Paper's skip-tripwire-hook-placement-validation, th handles tripwire hook dupe diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java -index 9aace993c6c18f1a50610e4766225485984b8167..d62855ce6df9a52cdd8005a43a70353365a92230 100644 +index 8a3a8b0fdf9545a41501dc992c6982d9c8ce7b66..af6a189b618c11573cd63e69bcd7ad4467e82fa6 100644 --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -215,7 +215,7 @@ public class TripWireHookBlock extends Block { +@@ -201,7 +201,7 @@ public class TripWireHookBlock extends Block { BlockState blockState2 = blockStates[i2]; if (blockState2 != null) { BlockState blockState3 = level.getBlockState(blockPos1); - if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { + if (org.dreeam.leaf.config.modules.gameplay.ConfigurableTripWireDupe.enabled || blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { // Leaf - Configurable tripwire dupe - if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); // Paper - prevent tripwire from updating + if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); // Paper - prevent tripwire from updating } } diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0109-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch b/leaf-server/minecraft-patches/features/0187-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch similarity index 76% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0109-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch rename to leaf-server/minecraft-patches/features/0187-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch index 5538756e..bba660c0 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0109-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch +++ b/leaf-server/minecraft-patches/features/0187-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch @@ -12,35 +12,34 @@ We replaced the `blockEntityTickers` list with a custom list based on fastutil's 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 +index 5fe79a471b5a5f1474a1fcb305b323d2e3a0de87..817cc2e4f311a626681d94b748a01ae2e3048445 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 +@@ -104,7 +104,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl 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 +- public final List blockEntityTickers = Lists.newArrayList(); ++ public final org.dreeam.leaf.util.list.BlockEntityTickersList blockEntityTickers = new org.dreeam.leaf.util.list.BlockEntityTickersList(); // 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 +@@ -1506,13 +1506,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl 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; + for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters 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 ++ this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll // SparklyPaper - optimize block entity removals } 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 +@@ -1522,7 +1520,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl // Paper end - rewrite chunk system } } diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0110-Sepals-Rearrange-the-attackable-conditions.patch b/leaf-server/minecraft-patches/features/0188-Sepals-Rearrange-the-attackable-conditions.patch similarity index 100% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0110-Sepals-Rearrange-the-attackable-conditions.patch rename to leaf-server/minecraft-patches/features/0188-Sepals-Rearrange-the-attackable-conditions.patch diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0111-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch b/leaf-server/minecraft-patches/features/0189-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch similarity index 85% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0111-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch rename to leaf-server/minecraft-patches/features/0189-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch index ea9f51d9..abe673e6 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0111-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch +++ b/leaf-server/minecraft-patches/features/0189-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch @@ -6,10 +6,10 @@ Subject: [PATCH] SparklyPaper: Skip dirty stats copy when requesting player diff --git a/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java -index b26dbe807e5cb0a42f6c06b933397902310e5616..ce89060bd01b253af7577fd0e6c03fc95f046b91 100644 +index dfaead7716ac718bcdbf4c3021aed1b57676af50..d04de9dc0a9a47e6c17f1000844bdee49e41035f 100644 --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java -@@ -81,11 +81,15 @@ public class ServerStatsCounter extends StatsCounter { +@@ -100,11 +100,15 @@ public class ServerStatsCounter extends StatsCounter { this.dirty.add(stat); } @@ -25,7 +25,7 @@ index b26dbe807e5cb0a42f6c06b933397902310e5616..ce89060bd01b253af7577fd0e6c03fc9 public void parseLocal(DataFixer fixerUpper, String json) { try { -@@ -194,10 +198,12 @@ public class ServerStatsCounter extends StatsCounter { +@@ -146,10 +150,12 @@ public class ServerStatsCounter extends StatsCounter { public void sendStats(ServerPlayer player) { Object2IntMap> map = new Object2IntOpenHashMap<>(); diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0113-Optimize-checking-nearby-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0190-Optimize-checking-nearby-players-for-spawning.patch similarity index 89% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0113-Optimize-checking-nearby-players-for-spawning.patch rename to leaf-server/minecraft-patches/features/0190-Optimize-checking-nearby-players-for-spawning.patch index 6fde26d4..d7c1f9d3 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0113-Optimize-checking-nearby-players-for-spawning.patch +++ b/leaf-server/minecraft-patches/features/0190-Optimize-checking-nearby-players-for-spawning.patch @@ -5,10 +5,10 @@ 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 +index 560a857f3b61679bbf2ee93ac6da393052a1f320..a50fb16dc2e6230d346eea8ee76820ec56906446 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 +@@ -773,7 +773,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos, boolean reducedRange) { @@ -17,7 +17,7 @@ index 8986c059e7aadb58ae8d9ab7b848de10f9faa6b2..546b20f8998c71ca1a701de7efcedd8d // 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 +@@ -785,23 +785,35 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider final ServerPlayer[] raw = players.getRawDataUnchecked(); final int len = players.size(); @@ -33,11 +33,8 @@ index 8986c059e7aadb58ae8d9ab7b848de10f9faa6b2..546b20f8998c71ca1a701de7efcedd8d - // 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 @@ -45,15 +42,14 @@ index 8986c059e7aadb58ae8d9ab7b848de10f9faa6b2..546b20f8998c71ca1a701de7efcedd8d + final com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = serverPlayer.playerNaturallySpawnedEvent; if (event == null || event.isCancelled()) continue; - blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); +- } +- if (this.playerIsCloseEnoughForSpawning(serverPlayer, chunkPos, blockRange)) { + final int spawnRadius = event.getSpawnRadius(); + blockRangeSquared = (double) (spawnRadius * spawnRadius) * 256.0; // (radius << 4)^2 -+ // Paper end - PlayerNaturallySpawnCreaturesEvent + // 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; diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0114-Cache-supporting-block-check.patch b/leaf-server/minecraft-patches/features/0191-Cache-supporting-block-check.patch similarity index 92% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0114-Cache-supporting-block-check.patch rename to leaf-server/minecraft-patches/features/0191-Cache-supporting-block-check.patch index 133644d2..009ee89b 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0114-Cache-supporting-block-check.patch +++ b/leaf-server/minecraft-patches/features/0191-Cache-supporting-block-check.patch @@ -5,10 +5,10 @@ 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 +index a2e9306d9a5eef738f8225e98fb1cc1f4bbca504..cb17aaad72940ac94317a50cbe85b22c00e02a10 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 +@@ -1078,12 +1078,36 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.mainSupportingBlockPos.isPresent() && this.mainSupportingBlockPos.get().equals(pos); } @@ -45,7 +45,7 @@ index 4544dd876d3cbcdb9b774b4a1f0c4737f3124bc5..6ca446fd9ab38329ba505526a56f8e4f 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 +@@ -1100,6 +1124,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0115-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch b/leaf-server/minecraft-patches/features/0192-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch similarity index 100% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0115-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch rename to leaf-server/minecraft-patches/features/0192-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0116-Replace-brain-activity-maps-with-optimized-collectio.patch b/leaf-server/minecraft-patches/features/0193-Replace-brain-activity-maps-with-optimized-collectio.patch similarity index 88% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0116-Replace-brain-activity-maps-with-optimized-collectio.patch rename to leaf-server/minecraft-patches/features/0193-Replace-brain-activity-maps-with-optimized-collectio.patch index dbdcd2c0..68b85f21 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0116-Replace-brain-activity-maps-with-optimized-collectio.patch +++ b/leaf-server/minecraft-patches/features/0193-Replace-brain-activity-maps-with-optimized-collectio.patch @@ -5,10 +5,10 @@ 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 +index b2e17d387558875f45a8458cf874a5b056820432..e78cef4c0ee6cff7ec2f27ced12c96be67dc7a0e 100644 --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java -@@ -390,8 +390,8 @@ public class Brain { +@@ -399,8 +399,8 @@ public class Brain { for (Pair> pair : tasks) { this.availableBehaviorsByPriority diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0117-Remove-stream-in-villagers.patch b/leaf-server/minecraft-patches/features/0194-Remove-stream-in-villagers.patch similarity index 83% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0117-Remove-stream-in-villagers.patch rename to leaf-server/minecraft-patches/features/0194-Remove-stream-in-villagers.patch index 445dc443..d8ccd641 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0117-Remove-stream-in-villagers.patch +++ b/leaf-server/minecraft-patches/features/0194-Remove-stream-in-villagers.patch @@ -14,19 +14,19 @@ 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 +index 72cca4897f9697573fd6987a5f0d2df52761b8c3..04eea77cf84aaeb781608e48f2aa32f344689889 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(); +- ImmutableSet set = other.getVillagerData().profession().value().requestedItems(); +- ImmutableSet set1 = villager.getVillagerData().profession().value().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(); ++ ImmutableSet otherItems = other.getVillagerData().profession().value().requestedItems(); ++ ImmutableSet villagerItems = villager.getVillagerData().profession().value().requestedItems(); + Set result = new java.util.HashSet<>(); + + for (Item item : otherItems) { @@ -41,10 +41,10 @@ index 4d8523a43d60cd6b4fd5546ffb3a61417b2c475b..8921faa7b893aae9e91a6f8e36dcd751 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 +index 48384d7a9cb41506e0b5024baf806e56497e9d62..ffc46d3ffe6d3a577fbad381f1f7d82d78e33d2a 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 +@@ -972,7 +972,17 @@ public class Villager extends AbstractVillager implements ReputationEventHandler private int countFoodPointsInInventory() { SimpleContainer inventory = this.getInventory(); diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0118-Optimize-baby-villager-sensor.patch b/leaf-server/minecraft-patches/features/0195-Optimize-baby-villager-sensor.patch similarity index 100% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0118-Optimize-baby-villager-sensor.patch rename to leaf-server/minecraft-patches/features/0195-Optimize-baby-villager-sensor.patch diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0119-Only-player-pushable.patch b/leaf-server/minecraft-patches/features/0196-Only-player-pushable.patch similarity index 66% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0119-Only-player-pushable.patch rename to leaf-server/minecraft-patches/features/0196-Only-player-pushable.patch index 6b8b3ffa..e2c24394 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0119-Only-player-pushable.patch +++ b/leaf-server/minecraft-patches/features/0196-Only-player-pushable.patch @@ -6,10 +6,10 @@ 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 00233a7066d751821566b43993e8c45e7dad95d0..03c9edad5c2f5e902b7a766c6d0be61bf3c263ae 100644 +index eb40f810d4eb8d6a8cc130719b637a473f19cc82..9d6d8ba96acd688d07bfecc29ff9de95abcd839c 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3631,7 +3631,7 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf +@@ -3630,7 +3630,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.checkAutoSpinAttack(boundingBox, this.getBoundingBox()); } @@ -18,23 +18,21 @@ index 00233a7066d751821566b43993e8c45e7dad95d0..03c9edad5c2f5e902b7a766c6d0be61b // 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()) { -@@ -3769,7 +3769,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()) { +@@ -3773,7 +3773,12 @@ public abstract class LivingEntity extends Entity implements Attackable { + return; + } + // Paper end - don't run getEntities if we're not going to use its result +- List pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox()); ++ // Leaf start - Only player pushable ++ final AABB box = this.getBoundingBox(); ++ List pushableEntities = org.dreeam.leaf.config.modules.gameplay.OnlyPlayerPushable.enabled ++ ? getNearbyPushablePlayers(this, box, EntitySelector.pushableBy(this)) ++ : this.level().getPushableEntities(this, box); ++ // Leaf end - Only player pushable + if (!pushableEntities.isEmpty()) { + if (this.level() instanceof ServerLevel serverLevel) { // 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) { -@@ -3802,6 +3809,44 @@ public abstract class LivingEntity extends Entity implements Attackable, net.caf +@@ -3807,6 +3812,44 @@ public abstract class LivingEntity extends Entity implements Attackable { } } @@ -50,7 +48,7 @@ index 00233a7066d751821566b43993e8c45e7dad95d0..03c9edad5c2f5e902b7a766c6d0be61b + ); + + if (players == null) { -+ return new ArrayList<>(); ++ return new java.util.ArrayList<>(); + } + + List ret = null; @@ -64,7 +62,7 @@ index 00233a7066d751821566b43993e8c45e7dad95d0..03c9edad5c2f5e902b7a766c6d0be61b + final ServerPlayer player = raw[i]; + if (player != entity && box.intersects(player.getBoundingBox()) && conditions.test(player)) { + if (ret == null) { -+ ret = new ArrayList<>(len - i); ++ ret = new java.util.ArrayList<>(len - i); + ret.add(player); + } else { + ret.add(player); @@ -72,7 +70,7 @@ index 00233a7066d751821566b43993e8c45e7dad95d0..03c9edad5c2f5e902b7a766c6d0be61b + } + } + -+ return ret == null ? new ArrayList<>() : ret; ++ return ret == null ? new java.util.ArrayList<>() : ret; + } + // Leaf end - Only player pushable + @@ -80,10 +78,10 @@ index 00233a7066d751821566b43993e8c45e7dad95d0..03c9edad5c2f5e902b7a766c6d0be61b 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 +index 49500127eb3a471c41dc3ff32372ad6f20c6d69a..aee9711b76c76e64056b73f8581cce0ba40b0811 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 +@@ -247,7 +247,7 @@ public class ArmorStand extends LivingEntity { @Override protected void pushEntities() { diff --git a/leaf-server/minecraft-patches/features/0197-Remove-iterators-from-Inventory.patch b/leaf-server/minecraft-patches/features/0197-Remove-iterators-from-Inventory.patch new file mode 100644 index 00000000..c1b5a219 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0197-Remove-iterators-from-Inventory.patch @@ -0,0 +1,131 @@ +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 + + +diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java +index dd406c5becacbc2d05b062726a8af88a1d6faba9..4b46bc712e20bd5f841d2d7caaad52068969bdc1 100644 +--- a/net/minecraft/world/entity/player/Inventory.java ++++ b/net/minecraft/world/entity/player/Inventory.java +@@ -435,13 +435,16 @@ public class Inventory implements Container, Nameable { + } + } + +- for (EquipmentSlot equipmentSlot : EQUIPMENT_SLOT_MAPPING.values()) { ++ // Leaf start - Remove iterators from Inventory ++ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) { ++ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i); + ItemStack itemStack = this.equipment.get(equipmentSlot); + if (itemStack == stack) { + this.equipment.set(equipmentSlot, ItemStack.EMPTY); + return; + } + } ++ // Leaf end - Remove iterators from Inventory + } + + @Override +@@ -500,17 +503,21 @@ public class Inventory implements Container, Nameable { + + @Override + public boolean isEmpty() { +- for (ItemStack itemStack : this.items) { ++ // Leaf start - Remove iterators from Inventory ++ for (int i = 0; i < this.items.size(); i++) { ++ ItemStack itemStack = this.items.get(i); + if (!itemStack.isEmpty()) { + return false; + } + } + +- for (EquipmentSlot equipmentSlot : EQUIPMENT_SLOT_MAPPING.values()) { ++ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) { ++ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i); + if (!this.equipment.get(equipmentSlot).isEmpty()) { + return false; + } + } ++ // Leaf end - Remove iterators from Inventory + + return true; + } +@@ -557,31 +564,61 @@ public class Inventory implements Container, Nameable { + } + + public boolean contains(ItemStack stack) { +- for (ItemStack itemStack : this) { ++ // Leaf start - Remove iterators from Inventory ++ for (int i = 0; i < this.items.size(); i++) { ++ ItemStack itemStack = this.items.get(i); + if (!itemStack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack)) { + return true; + } + } ++ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) { ++ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i); ++ ItemStack itemStack = this.equipment.get(equipmentSlot); ++ if (!itemStack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack)) { ++ return true; ++ } ++ } ++ // Leaf end - Remove iterators from Inventory + + return false; + } + + public boolean contains(TagKey tag) { +- for (ItemStack itemStack : this) { ++ // Leaf start - Remove iterators from Inventory ++ for (int i = 0; i < this.items.size(); i++) { ++ ItemStack itemStack = this.items.get(i); + if (!itemStack.isEmpty() && itemStack.is(tag)) { + return true; + } + } ++ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) { ++ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i); ++ ItemStack itemStack = this.equipment.get(equipmentSlot); ++ if (!itemStack.isEmpty() && itemStack.is(tag)) { ++ return true; ++ } ++ } ++ // Leaf end - Remove iterators from Inventory + + return false; + } + + public boolean contains(Predicate predicate) { +- for (ItemStack itemStack : this) { ++ // Leaf start - Remove iterators from Inventory ++ for (int i = 0; i < this.items.size(); i++) { ++ ItemStack itemStack = this.items.get(i); ++ if (predicate.test(itemStack)) { ++ return true; ++ } ++ } ++ for (int i = 0; i < EQUIPMENT_SLOT_MAPPING.size(); i++) { ++ EquipmentSlot equipmentSlot = EQUIPMENT_SLOT_MAPPING.get(i); ++ ItemStack itemStack = this.equipment.get(equipmentSlot); + if (predicate.test(itemStack)) { + return true; + } + } ++ // Leaf end - Remove iterators from Inventory + + return false; + } +@@ -601,9 +638,12 @@ public class Inventory implements Container, Nameable { + } + + public void fillStackedContents(StackedItemContents contents) { +- for (ItemStack itemStack : this.items) { ++ // Leaf start - Remove iterators from Inventory ++ for (int i = 0; i < this.items.size(); i++) { ++ ItemStack itemStack = this.items.get(i); + contents.accountSimpleStack(itemStack); + } ++ // Leaf end - Remove iterators from Inventory + } + + public ItemStack removeFromSelected(boolean removeStack) { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0121-Alternative-Brain-Behaviour.patch b/leaf-server/minecraft-patches/features/0198-Alternative-Brain-Behaviour.patch similarity index 96% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0121-Alternative-Brain-Behaviour.patch rename to leaf-server/minecraft-patches/features/0198-Alternative-Brain-Behaviour.patch index b6b27059..1932ca40 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0121-Alternative-Brain-Behaviour.patch +++ b/leaf-server/minecraft-patches/features/0198-Alternative-Brain-Behaviour.patch @@ -7,7 +7,7 @@ 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 +index e78cef4c0ee6cff7ec2f27ced12c96be67dc7a0e..e3d0186e681168840836690acd402b774bc464b5 100644 --- a/net/minecraft/world/entity/ai/Brain.java +++ b/net/minecraft/world/entity/ai/Brain.java @@ -268,23 +268,52 @@ public class Brain { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0122-Cache-eligible-players-for-despawn-checks.patch b/leaf-server/minecraft-patches/features/0199-Cache-eligible-players-for-despawn-checks.patch similarity index 88% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0122-Cache-eligible-players-for-despawn-checks.patch rename to leaf-server/minecraft-patches/features/0199-Cache-eligible-players-for-despawn-checks.patch index cd9d210f..d5cf4906 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0122-Cache-eligible-players-for-despawn-checks.patch +++ b/leaf-server/minecraft-patches/features/0199-Cache-eligible-players-for-despawn-checks.patch @@ -5,10 +5,10 @@ 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 20ded514a74652685b2f785c7fe5fda19e36b2a5..5da07e22ef9dac7baca9d8450b7eae3f6fa141b1 100644 +index b9bff011c0ffb0efdaccc65847be69aad1a70681..d8390cb3901a40b97e99990d9f71f12c74f96607 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 +@@ -723,6 +723,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return this.structureManager; } @@ -17,7 +17,7 @@ index 20ded514a74652685b2f785c7fe5fda19e36b2a5..5da07e22ef9dac7baca9d8450b7eae3f public void tick(BooleanSupplier hasTimeLeft) { this.handlingTick = true; TickRateManager tickRateManager = this.tickRateManager(); -@@ -802,6 +804,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -790,6 +792,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR @@ -38,10 +38,10 @@ index 20ded514a74652685b2f785c7fe5fda19e36b2a5..5da07e22ef9dac7baca9d8450b7eae3f .forEach( entity -> { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 336215befa7eb4b20fc86f224a019080cea70113..e2b15968e89a532ec21c786f41b7f9322fd65a04 100644 +index 2ad0c935e16b92007475c681641770aa27f2b0c3..f9c247769e71afe7cb7ccb9680dfe34df706e7cd 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1576,6 +1576,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1518,6 +1518,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.containerMenu.broadcastChanges(); } @@ -56,10 +56,10 @@ index 336215befa7eb4b20fc86f224a019080cea70113..e2b15968e89a532ec21c786f41b7f932 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 54eeb0b112112bc5d3f4165c0ea43cf67931a739..05d5cde42b7011091ef4ee874c0d9d5586ae3f10 100644 +index d473c09e98eb5d3ef7b3e096197c7bf9a6219c56..77075bf43e7e2301e58aa6d9f8bfe934cce42f55 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 +@@ -705,7 +705,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()) { diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0123-Slightly-optimise-getNearestPlayer.patch b/leaf-server/minecraft-patches/features/0200-Slightly-optimise-getNearestPlayer.patch similarity index 100% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0123-Slightly-optimise-getNearestPlayer.patch rename to leaf-server/minecraft-patches/features/0200-Slightly-optimise-getNearestPlayer.patch diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0124-ShreddedPaper-Don-t-block-main-thread-in-Connection-.patch b/leaf-server/minecraft-patches/features/0201-ShreddedPaper-Don-t-block-main-thread-in-Connection-.patch similarity index 100% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0124-ShreddedPaper-Don-t-block-main-thread-in-Connection-.patch rename to leaf-server/minecraft-patches/features/0201-ShreddedPaper-Don-t-block-main-thread-in-Connection-.patch diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0125-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch b/leaf-server/minecraft-patches/features/0202-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch similarity index 50% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0125-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch rename to leaf-server/minecraft-patches/features/0202-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch index fb95a3e9..2a68bfcb 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0125-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch +++ b/leaf-server/minecraft-patches/features/0202-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch @@ -5,20 +5,19 @@ Subject: [PATCH] Use ensureCapacity to pre-populate the size of ticking chunks list output -diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 6735f9e23c8972b7cf1438a2f3b49d780c1ff78c..c80464d333bd37a9b8bc7cea2291c8c72e6f9bd6 100644 ---- a/net/minecraft/server/level/ServerChunkCache.java -+++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -585,7 +585,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - final ServerChunkCache.ChunkAndHolder[] raw = tickingChunks.getRawDataUnchecked(); +diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java +index a50fb16dc2e6230d346eea8ee76820ec56906446..4a2ef88cb75f4a10565ed819570b2885942b525c 100644 +--- a/net/minecraft/server/level/ChunkMap.java ++++ b/net/minecraft/server/level/ChunkMap.java +@@ -733,6 +733,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider final int size = tickingChunks.size(); -- final ChunkMap chunkMap = this.chunkMap; + Objects.checkFromToIndex(0, size, raw.length); + // Leaf start - Use ensureCapacity to pre-populate the size of ticking chunks list output + if (output instanceof ArrayList arrayList) { + arrayList.ensureCapacity(size); + } + // Leaf end - Use ensureCapacity to pre-populate the size of ticking chunks list output - for (int i = 0; i < size; ++i) { - final ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i]; + final LevelChunk levelChunk = raw[i]; + diff --git a/leaf-server/minecraft-patches/features/0203-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch b/leaf-server/minecraft-patches/features/0203-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch new file mode 100644 index 00000000..0527173e --- /dev/null +++ b/leaf-server/minecraft-patches/features/0203-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Sun, 16 Feb 2025 01:13:04 +0100 +Subject: [PATCH] Directly use the pre-filtered ticking chunks list as the + output + +This patch uses already pre filtered chunks, which completely skips the isChunkNearPlayer check + +diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java +index 4a2ef88cb75f4a10565ed819570b2885942b525c..b94375fb83fab6434060c2f7288dc7a366ed1391 100644 +--- a/net/minecraft/server/level/ChunkMap.java ++++ b/net/minecraft/server/level/ChunkMap.java +@@ -739,13 +739,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + } + // Leaf end - Use ensureCapacity to pre-populate the size of ticking chunks list output + for (int i = 0; i < size; ++i) { +- final LevelChunk levelChunk = raw[i]; +- +- if (!this.isChunkNearPlayer((ChunkMap)(Object)this, levelChunk.getPos(), levelChunk)) { +- continue; +- } +- +- output.add(levelChunk); ++ output.add(raw[i]); // Leaf - Directly use the pre-filtered ticking chunks list as the output + } + } +