mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-23 08:49:25 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a24f9b2 1.21.6 dev PaperMC/Paper@457a0a6 Bump version string and protocol version to 1.21.6 release PaperMC/Paper@245b547 Update base to 1.21.6 PaperMC/Paper@b28d77b Update Moonrise to 1.21.6 PaperMC/Paper@8318dcb Update DataConverter to 1.21.6-rc1 PaperMC/Paper@d2b1158 Set correct world access on BSL snapshots PaperMC/Paper@023e6c2 Ensure waypoints are per world PaperMC/Paper@40d5d31 Fix recursively converting JSON Text Components PaperMC/Paper@1fcc416 Implement FeatureHooks#isChunkSent for Moonrise chunk system PaperMC/Paper@e4d7178 Implement WaypointTransmitter#isChunkVisible PaperMC/Paper@8980ead Directly walk text component after converting from JSON PaperMC/Paper@5613ed6 Provide env environment variable and copy spigots sys prop for overriding default repository PaperMC/Paper@62b7f86 Avoid and discourage use of Maven Central as a CDN (#12689) PaperMC/Paper@f5534cb [ci skip] Run generators (#12691) PaperMC/Paper@4781d28 Re-add Log4j Javadocs (#12693) PaperMC/Paper@74fbcce Check type of Material in get/set stats (#12607) PaperMC/Paper@4b3f967 Improve Fix MC-44654 (#12703) PaperMC/Paper@a7dd263 Enable spigot obfuscation support (#12695) PaperMC/Paper@6a51c44 Cleanup Primed TNT Fix (#12704) PaperMC/Paper@839c6a1 Fix #11169 (#12706) PaperMC/Paper@c77d5f9 Fix MC-297591 PaperMC/Paper@219f86e Implement chunk unload delay config option PaperMC/Paper@e4eb69b Do not allow ticket level decreases to be processed asynchronously PaperMC/Paper@71b0c76 Adds support for vanilla negative explosions (#12705) PaperMC/Paper@3750927 [ci skip] Fix PermissionManager#clearPermissions() docs bad wording (#12657) PaperMC/Paper@d61a51e Add ItemType#getBurnDuration() (#12604) PaperMC/Paper@29fc853 Allow empty paths in namespaced keys (#12687) PaperMC/Paper@4419afb fix: Safely handle nanosecond overflow in ClickCallback (#12686) PaperMC/Paper@5652882 Add `isProxyEnabled` method to ServerConfiguration (#12664) PaperMC/Paper@c0dda0e Add `isForceDefaultGameMode` method (#12673) PaperMC/Paper@e714de6 Fix excess slot updates PaperMC/Paper@6d0821d [ci skip] Fix docs for Spawner class and cleanup (#12710) PaperMC/Paper@cceffe3 Release ItemType and BlockType (#12708) PaperMC/Paper@186e9e3 Relocate CommandMap#registerServerAliases() call to after lifecycle events have been run (#12601) PaperMC/Paper@5edcf6d Cleanup/command dispatching (#12713) PaperMC/Paper@803baf0 Support hidden entities in Waypoints (#12715) PaperMC/Paper@1814d8b build: publish to fill (#12717) PaperMC/Paper@e454fef Add support for private constructors in plugin main classes (#12652) PaperMC/Paper@d0e808f Move player to correct position in vehicle move packet handler PaperMC/Paper@46b4b0b Improve keepalive ping system PaperMC/Paper@38c1ddb Add and use FeatureHooks.getAllEntities PaperMC/Paper@2f083ac Ensure player entity schedulers are ticked when they are dead PaperMC/Paper@7c90c7c Optimise EntityScheduler ticking PaperMC/Paper@aa6ee44 Re-add global region scheduler tick erroneously removed in last commit PaperMC/Paper@d7510ef Fix #12722 (#12726) PaperMC/Paper@0caf75f Fix #12721 (#12725) PaperMC/Paper@bee2879 Adventure 4.23.0 (#12690) PaperMC/Paper@692e93a Fix MC-299110 PaperMC/Paper@ea10fa4 Don't mutate the position of Items for MC-4 Fix (#12702) PaperMC/Paper@aa6cd74 Remove unnecesary item check for ServerboundPlayerActionPacket RELEASE_USE_ITEM (#12668) PaperMC/Paper@c9e89f4 Expose arrow velocity in EntityShootBowEvent for mobs (#12688) PaperMC/Paper@7ec3174 Jump out of experimental phase PaperMC/Paper@4e1a255 Update try catch for command handling
118 lines
7.4 KiB
Diff
118 lines
7.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Thu, 27 Jun 2024 17:02:32 +0100
|
|
Subject: [PATCH] Add maxSearch to getEntities
|
|
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
|
index bd2055bc89c5672b514f1f7b1ad320a2fba7cbe2..7678696aa2fa74358a374a501a6b7f76f4805945 100644
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
|
@@ -336,7 +336,14 @@ public final class ChunkEntitySlices {
|
|
|
|
public boolean getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
final int maxCount) {
|
|
- return this.allEntities.getEntitiesLimited(except, box, into, predicate, maxCount);
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
+ return this.getEntities(except, box, into, predicate, maxCount, Integer.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+ public boolean getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
+ final int maxCount, final int maxSearch) {
|
|
+ return this.allEntities.getEntitiesLimited(except, box, into, predicate, maxCount, maxSearch);
|
|
+ // Sakura end - add maxSearch to getEntities
|
|
}
|
|
|
|
public <T extends Entity> void getEntities(final EntityType<?> type, final AABB box, final List<? super T> into,
|
|
@@ -574,6 +581,13 @@ public final class ChunkEntitySlices {
|
|
|
|
public boolean getEntitiesLimited(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
final int maxCount) {
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
+ return this.getEntitiesLimited(except, box, into, predicate, maxCount, Integer.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+ public boolean getEntitiesLimited(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
+ final int maxCount, final int maxSearch) {
|
|
+ // Sakura end - add maxSearch to getEntities
|
|
if (this.count == 0) {
|
|
return false;
|
|
}
|
|
@@ -595,8 +609,14 @@ public final class ChunkEntitySlices {
|
|
|
|
final Entity[] storage = list.storage;
|
|
|
|
- for (int i = 0, len = Math.min(storage.length, list.size()); i < len; ++i) {
|
|
- final Entity entity = storage[i];
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
+ final int len = Math.min(storage.length, list.size());
|
|
+ final int offset = this.slices.world.random.nextInt(len);
|
|
+ for (int i = 0; i < len; ++i) {
|
|
+ final int pos = (i + offset) % len;
|
|
+ final Entity entity = storage[pos];
|
|
+ if (i > maxSearch) break;
|
|
+ // Sakura end - add maxSearch to getEntities
|
|
|
|
if (entity == null || entity == except || !entity.getBoundingBox().intersects(box)) {
|
|
continue;
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
|
index 2d24d03bbdb5ee0d862cbfff2219f58afffafe12..1bf06038d51efcc103fad23670686c30d676dc0b 100644
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
|
@@ -726,6 +726,13 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
|
|
|
|
public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
final int maxCount) {
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
+ this.getEntities(except, box, into, predicate, maxCount, Integer.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+ public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
+ final int maxCount, final int maxSearch) {
|
|
+ // Sakura end - add maxSearch to getEntities
|
|
final int minChunkX = (Mth.floor(box.minX) - 2) >> 4;
|
|
final int minChunkZ = (Mth.floor(box.minZ) - 2) >> 4;
|
|
final int maxChunkX = (Mth.floor(box.maxX) + 2) >> 4;
|
|
@@ -757,7 +764,7 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
|
|
continue;
|
|
}
|
|
|
|
- if (chunk.getEntities(except, box, into, predicate, maxCount)) {
|
|
+ if (chunk.getEntities(except, box, into, predicate, maxCount, maxSearch)) { // Sakura - add maxSearch to getEntities
|
|
return;
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index c24f09cf9959310353bd0fc5a5ff7498c6ea47a0..ca5e2ec53590b731aedf33dfd69e728992f52b91 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -1772,10 +1772,18 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE);
|
|
}
|
|
|
|
- // Paper start - rewrite chunk system
|
|
public <T extends Entity> void getEntities(final EntityTypeTest<Entity, T> entityTypeTest,
|
|
final AABB boundingBox, final Predicate<? super T> predicate,
|
|
final List<? super T> into, final int maxCount) {
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
+ this.getEntities(entityTypeTest, boundingBox, predicate, into, maxCount, Integer.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+ // Paper start - rewrite chunk system
|
|
+ public <T extends Entity> void getEntities(final EntityTypeTest<Entity, T> entityTypeTest,
|
|
+ final AABB boundingBox, final Predicate<? super T> predicate,
|
|
+ final List<? super T> into, final int maxCount, final int maxSearch) {
|
|
+ // Sakura end - add maxSearch to getEntities
|
|
Profiler.get().incrementCounter("getEntities");
|
|
|
|
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
|
|
@@ -1792,7 +1800,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
|
|
if (entityTypeTest == null) {
|
|
if (maxCount != Integer.MAX_VALUE) {
|
|
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount);
|
|
+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount, maxSearch); // Sakura - add maxSearch to getEntities
|
|
ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
|
return;
|
|
} else {
|