diff --git a/patches/server/0093-Remove-stream-in-YieldJobSite.patch b/patches/server/0093-Remove-stream-in-YieldJobSite.patch new file mode 100644 index 000000000..4704a8687 --- /dev/null +++ b/patches/server/0093-Remove-stream-in-YieldJobSite.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> +Date: Sat, 26 Oct 2024 14:04:54 +0800 +Subject: [PATCH] Remove stream in YieldJobSite + + +diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java +index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..572d266c3af268a5dbbc31272b5aa15d46442408 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java ++++ b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java +@@ -38,24 +38,25 @@ public class YieldJobSite { + if (optional.isEmpty()) { + return true; + } else { +- context.>get(mobs) +- .stream() +- .filter(mob -> mob instanceof Villager && mob != entity) +- .map(villager -> (Villager)villager) +- .filter(LivingEntity::isAlive) +- .filter(villager -> nearbyWantsJobsite(optional.get(), villager, blockPos)) +- .findFirst() +- .ifPresent(villager -> { +- walkTarget.erase(); +- lookTarget.erase(); +- potentialJobSite.erase(); +- if (villager.getBrain().getMemory(MemoryModuleType.JOB_SITE).isEmpty()) { +- BehaviorUtils.setWalkAndLookTargetMemories(villager, blockPos, speed, 1); +- villager.getBrain() +- .setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(world.dimension(), blockPos)); +- DebugPackets.sendPoiTicketCountPacket(world, blockPos); ++ // Leaf start - Remove stream in YieldJobSite ++ List mobsList = context.get(mobs); ++ for (LivingEntity mob : mobsList) { ++ if (mob instanceof Villager villager && mob != entity && villager.isAlive()) { ++ if (nearbyWantsJobsite(optional.get(), villager, blockPos)) { ++ walkTarget.erase(); ++ lookTarget.erase(); ++ potentialJobSite.erase(); ++ ++ if (villager.getBrain().getMemory(MemoryModuleType.JOB_SITE).isEmpty()) { ++ BehaviorUtils.setWalkAndLookTargetMemories(villager, blockPos, speed, 1); ++ villager.getBrain().setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(world.dimension(), blockPos)); ++ DebugPackets.sendPoiTicketCountPacket(world, blockPos); ++ } ++ break; + } +- }); ++ } ++ } ++ // Leaf end - Remove stream in YieldJobSite + return true; + } + } diff --git a/patches/server/0093-Replace-Entity-active-effects-map-with-optimized-col.patch b/patches/server/0094-Replace-Entity-active-effects-map-with-optimized-col.patch similarity index 100% rename from patches/server/0093-Replace-Entity-active-effects-map-with-optimized-col.patch rename to patches/server/0094-Replace-Entity-active-effects-map-with-optimized-col.patch diff --git a/patches/server/0094-Replace-brain-maps-with-optimized-collection.patch b/patches/server/0095-Replace-brain-maps-with-optimized-collection.patch similarity index 100% rename from patches/server/0094-Replace-brain-maps-with-optimized-collection.patch rename to patches/server/0095-Replace-brain-maps-with-optimized-collection.patch diff --git a/patches/server/0095-Reduce-worldgen-allocations.patch b/patches/server/0096-Reduce-worldgen-allocations.patch similarity index 100% rename from patches/server/0095-Reduce-worldgen-allocations.patch rename to patches/server/0096-Reduce-worldgen-allocations.patch diff --git a/patches/server/0096-Fix-MC-183518.patch b/patches/server/0097-Fix-MC-183518.patch similarity index 100% rename from patches/server/0096-Fix-MC-183518.patch rename to patches/server/0097-Fix-MC-183518.patch diff --git a/patches/server/0097-Use-caffeine-cache-kickPermission-instead-of-using-g.patch b/patches/server/0098-Use-caffeine-cache-kickPermission-instead-of-using-g.patch similarity index 100% rename from patches/server/0097-Use-caffeine-cache-kickPermission-instead-of-using-g.patch rename to patches/server/0098-Use-caffeine-cache-kickPermission-instead-of-using-g.patch diff --git a/patches/server/0098-Do-not-place-player-if-the-server-is-full.patch b/patches/server/0099-Do-not-place-player-if-the-server-is-full.patch similarity index 100% rename from patches/server/0098-Do-not-place-player-if-the-server-is-full.patch rename to patches/server/0099-Do-not-place-player-if-the-server-is-full.patch diff --git a/patches/server/0099-Fix-MC-200418.patch b/patches/server/0100-Fix-MC-200418.patch similarity index 100% rename from patches/server/0099-Fix-MC-200418.patch rename to patches/server/0100-Fix-MC-200418.patch diff --git a/patches/server/0100-Fix-MC-119417.patch b/patches/server/0101-Fix-MC-119417.patch similarity index 100% rename from patches/server/0100-Fix-MC-119417.patch rename to patches/server/0101-Fix-MC-119417.patch diff --git a/patches/server/0101-Fix-MC-223153.patch b/patches/server/0102-Fix-MC-223153.patch similarity index 100% rename from patches/server/0101-Fix-MC-223153.patch rename to patches/server/0102-Fix-MC-223153.patch diff --git a/patches/server/0102-Optimize-LeavesProtocolManager-init-protocol.patch b/patches/server/0103-Optimize-LeavesProtocolManager-init-protocol.patch similarity index 100% rename from patches/server/0102-Optimize-LeavesProtocolManager-init-protocol.patch rename to patches/server/0103-Optimize-LeavesProtocolManager-init-protocol.patch diff --git a/patches/server/0103-Cache-CraftEntityType-minecraftToBukkit-convert.patch b/patches/server/0104-Cache-CraftEntityType-minecraftToBukkit-convert.patch similarity index 100% rename from patches/server/0103-Cache-CraftEntityType-minecraftToBukkit-convert.patch rename to patches/server/0104-Cache-CraftEntityType-minecraftToBukkit-convert.patch diff --git a/patches/server/0104-Configurable-player-knockback-zombie.patch b/patches/server/0105-Configurable-player-knockback-zombie.patch similarity index 100% rename from patches/server/0104-Configurable-player-knockback-zombie.patch rename to patches/server/0105-Configurable-player-knockback-zombie.patch diff --git a/patches/server/0105-Hide-specified-item-components-to-clients.patch b/patches/server/0106-Hide-specified-item-components-to-clients.patch similarity index 100% rename from patches/server/0105-Hide-specified-item-components-to-clients.patch rename to patches/server/0106-Hide-specified-item-components-to-clients.patch diff --git a/patches/server/0106-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch b/patches/server/0107-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch similarity index 100% rename from patches/server/0106-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch rename to patches/server/0107-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch diff --git a/patches/server/0107-Paper-PR-Reduce-work-done-in-CraftMapCanvas.drawImag.patch b/patches/server/0108-Paper-PR-Reduce-work-done-in-CraftMapCanvas.drawImag.patch similarity index 100% rename from patches/server/0107-Paper-PR-Reduce-work-done-in-CraftMapCanvas.drawImag.patch rename to patches/server/0108-Paper-PR-Reduce-work-done-in-CraftMapCanvas.drawImag.patch diff --git a/patches/server/0108-Paper-PR-Throttle-failed-spawn-attempts.patch b/patches/server/0109-Paper-PR-Throttle-failed-spawn-attempts.patch similarity index 100% rename from patches/server/0108-Paper-PR-Throttle-failed-spawn-attempts.patch rename to patches/server/0109-Paper-PR-Throttle-failed-spawn-attempts.patch diff --git a/patches/server/0109-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch b/patches/server/0110-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch similarity index 100% rename from patches/server/0109-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch rename to patches/server/0110-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch diff --git a/patches/server/0110-Dont-send-useless-entity-packets.patch b/patches/server/0111-Dont-send-useless-entity-packets.patch similarity index 100% rename from patches/server/0110-Dont-send-useless-entity-packets.patch rename to patches/server/0111-Dont-send-useless-entity-packets.patch diff --git a/patches/server/0111-Don-t-spawn-if-lastSpawnState-is-null.patch b/patches/server/0112-Don-t-spawn-if-lastSpawnState-is-null.patch similarity index 100% rename from patches/server/0111-Don-t-spawn-if-lastSpawnState-is-null.patch rename to patches/server/0112-Don-t-spawn-if-lastSpawnState-is-null.patch diff --git a/patches/server/0112-Multithreaded-Tracker.patch b/patches/server/0113-Multithreaded-Tracker.patch similarity index 100% rename from patches/server/0112-Multithreaded-Tracker.patch rename to patches/server/0113-Multithreaded-Tracker.patch diff --git a/patches/server/0113-Nitori-Async-playerdata-Save.patch b/patches/server/0114-Nitori-Async-playerdata-Save.patch similarity index 100% rename from patches/server/0113-Nitori-Async-playerdata-Save.patch rename to patches/server/0114-Nitori-Async-playerdata-Save.patch diff --git a/patches/server/0114-Change-max-stack-count.patch b/patches/server/0115-Change-max-stack-count.patch similarity index 100% rename from patches/server/0114-Change-max-stack-count.patch rename to patches/server/0115-Change-max-stack-count.patch diff --git a/patches/server/0115-Reduce-object-complexity-to-make-block-isValid-calls.patch b/patches/server/0116-Reduce-object-complexity-to-make-block-isValid-calls.patch similarity index 100% rename from patches/server/0115-Reduce-object-complexity-to-make-block-isValid-calls.patch rename to patches/server/0116-Reduce-object-complexity-to-make-block-isValid-calls.patch diff --git a/patches/server/0116-Optimize-nearby-alive-players-for-spawning.patch b/patches/server/0117-Optimize-nearby-alive-players-for-spawning.patch similarity index 100% rename from patches/server/0116-Optimize-nearby-alive-players-for-spawning.patch rename to patches/server/0117-Optimize-nearby-alive-players-for-spawning.patch diff --git a/patches/server/0117-Cache-blockstate-cache.patch b/patches/server/0118-Cache-blockstate-cache.patch similarity index 100% rename from patches/server/0117-Cache-blockstate-cache.patch rename to patches/server/0118-Cache-blockstate-cache.patch diff --git a/patches/server/0118-Fix-MC-177381.patch b/patches/server/0119-Fix-MC-177381.patch similarity index 100% rename from patches/server/0118-Fix-MC-177381.patch rename to patches/server/0119-Fix-MC-177381.patch diff --git a/patches/server/0119-Asynchronous-locator.patch b/patches/server/0120-Asynchronous-locator.patch similarity index 100% rename from patches/server/0119-Asynchronous-locator.patch rename to patches/server/0120-Asynchronous-locator.patch diff --git a/patches/server/0120-Virtual-thread-for-chat-executor.patch b/patches/server/0121-Virtual-thread-for-chat-executor.patch similarity index 100% rename from patches/server/0120-Virtual-thread-for-chat-executor.patch rename to patches/server/0121-Virtual-thread-for-chat-executor.patch diff --git a/patches/server/0122-Use-QuickSort-in-NearestLivingEntitySensor.patch b/patches/server/0122-Use-QuickSort-in-NearestLivingEntitySensor.patch new file mode 100644 index 000000000..2d665cf53 --- /dev/null +++ b/patches/server/0122-Use-QuickSort-in-NearestLivingEntitySensor.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> +Date: Sat, 26 Oct 2024 15:00:21 +0800 +Subject: [PATCH] Use QuickSort in NearestLivingEntitySensor + + +diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java +index 5a059e1ec232d82e8e891ae78fea962bec2f878e..490c5322f8286f92f9ba4583f59ed60618ad33e5 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java ++++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java +@@ -16,10 +16,16 @@ public class NearestLivingEntitySensor extends Sensor + protected void doTick(ServerLevel world, T entity) { + AABB aABB = entity.getBoundingBox().inflate((double)this.radiusXZ(), (double)this.radiusY(), (double)this.radiusXZ()); + List list = world.getEntitiesOfClass(LivingEntity.class, aABB, e -> e != entity && e.isAlive()); +- list.sort(Comparator.comparingDouble(entity::distanceToSqr)); ++ // Leaf start - Use QuickSort in NearestLivingEntitySensor ++ LivingEntity[] sortArray = list.toArray(new LivingEntity[]{}); ++ it.unimi.dsi.fastutil.objects.ObjectArrays.quickSort(sortArray, Comparator.comparingDouble(entity::distanceToSqr)); ++ List sortedList = java.util.Arrays.asList(sortArray); ++ // Leaf end - Use QuickSort in NearestLivingEntitySensor + Brain brain = entity.getBrain(); +- brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list); +- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(entity, list)); ++ // Leaf start - Use QuickSort in NearestLivingEntitySensor ++ brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, sortedList); ++ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(entity, sortedList)); ++ // Leaf end - Use QuickSort in NearestLivingEntitySensor + } + + protected int radiusXZ() {