mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-21 15:59:26 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@20ec622 use correct types for preloading CraftRegistry PaperMC/Paper@627cc64 Adjust HAProxy's existance to log for console masters (#11433) PaperMC/Paper@01c4820 Call EntityDropItemEvent when a container item drops its contents (#11441) PaperMC/Paper@9c76642 Deprecate for removal Block#isValidTool (#11439) PaperMC/Paper@dd6d184 Remove redundant fillUsableCommands call (#11425) PaperMC/Paper@f33611c fix ItemStack#removeEnchantments creating non-stackable items (#11442) PaperMC/Paper@8f56db8 Add enchantWithLevels with tag specification (#11438) PaperMC/Paper@b7ab22d Fix console completions on invalid commands (#7603) PaperMC/Paper@41bc31b Update paperweight to 1.7.3 (#11445) PaperMC/Paper@e17eb6b Improve entity effect API (#11444) PaperMC/Paper@7b03141 Add startingBrewTime (#11406) PaperMC/Paper@355b1cb Add API for explosions to damage the explosion cause (#11180) PaperMC/Paper@6d7a438 Call bucket events for cauldrons (#7486) PaperMC/Paper@f9c7f2a Begin switching to JSpecify annotations (#11448) PaperMC/Paper@e3c8a8e Add PlayerInsertLecternBookEvent [1.20 port] (#7305) PaperMC/Paper@b410fe8 Configurable per-world void damage offset/damage(#11436) PaperMC/Paper@ea00be3 Do not NPE on uuid resolution in player profile (#11449) PaperMC/Paper@ba3c29b Finish converting all events to jspecify annotations PaperMC/Paper@e7e1ab5 Finish converting most of the undeprecated api to jspecify PaperMC/Paper@69ffbec Fix hex color check PaperMC/Paper@709f0f2 Use components properly in ProfileWhitelistVerifyEvent (#11456) PaperMC/Paper@fb76840 [ci skip] Add section on nullability annotations (#11461)
133 lines
8.2 KiB
Diff
133 lines
8.2 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/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
|
index f3832bf2064117ef2fe804ae3fd679b1f2b0343b..9051dc762e48191fd56d26e0d0499ef12b10a240 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
|
|
@@ -336,10 +336,16 @@ public final class ChunkEntitySlices {
|
|
this.allEntities.getEntities(except, box, into, predicate);
|
|
}
|
|
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
+ public boolean getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
+ final int maxCount) {
|
|
+ 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) {
|
|
- return this.allEntities.getEntitiesWithEnderDragonPartsLimited(except, box, into, predicate, maxCount);
|
|
+ final int maxCount, final int maxSearch) {
|
|
+ return this.allEntities.getEntitiesWithEnderDragonPartsLimited(except, box, into, predicate, maxCount, maxSearch);
|
|
+ // Sakura end - add maxSearch to getEntities
|
|
}
|
|
|
|
public boolean getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
@@ -693,8 +699,16 @@ public final class ChunkEntitySlices {
|
|
}
|
|
}
|
|
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
public boolean getEntitiesWithEnderDragonPartsLimited(final Entity except, final AABB box, final List<Entity> into,
|
|
final Predicate<? super Entity> predicate, final int maxCount) {
|
|
+ return this.getEntitiesWithEnderDragonPartsLimited(except, box, into, predicate, maxCount, Integer.MAX_VALUE);
|
|
+ }
|
|
+
|
|
+ public boolean getEntitiesWithEnderDragonPartsLimited(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;
|
|
}
|
|
@@ -716,8 +730,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/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
|
index efc0c1acc8239dd7b00211a1d3bfd3fc3b2c810c..0ffbc8b459c3475ff0a9c307cb7bd144045f5f1c 100644
|
|
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
|
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
|
@@ -801,8 +801,15 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
|
|
}
|
|
}
|
|
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate,
|
|
final int maxCount) {
|
|
+ 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;
|
|
@@ -834,7 +841,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;
|
|
}
|
|
}
|
|
@@ -1080,4 +1087,4 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
|
|
@Override
|
|
public void onRemove(final Entity.RemovalReason reason) {}
|
|
}
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index c3260ad0ddb40fbde9c1aaf25c0a2be901357dcc..75d11642b7246bae4073feec09c0cf21c24622ca 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -1685,10 +1685,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
this.getEntities(filter, box, predicate, result, Integer.MAX_VALUE);
|
|
}
|
|
|
|
- // Paper start - rewrite chunk system
|
|
+ // Sakura start - add maxSearch to getEntities
|
|
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) {
|
|
+ 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
|
|
this.getProfiler().incrementCounter("getEntities");
|
|
|
|
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
|
|
@@ -1703,7 +1711,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
|
|
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
|
|
return;
|
|
} else {
|
|
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate);
|