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@691d452 Fix bundled spark permission check (#11355) PaperMC/Paper@012c527 Update Velocity natives (#11347) PaperMC/Paper@953e6e9 Fire BlockExpEvent on grindstone use (#11346) PaperMC/Paper@10f5879 Change condition check order of entity tracking Y (#11348) PaperMC/Paper@805a974 Improve console completion with brig suggestions (#9251) PaperMC/Paper@e0021b1 Fix allowSpiderWorldBorderClimbing world config (#11321) PaperMC/Paper@3db4758 Check dead flag in isAlive() (#11330) PaperMC/Paper@21f125f Revert velocity natives to 3.1.2 (#11368) PaperMC/Paper@0e82527 Fix NPE while trying to respawn an already disconnected player (#11353) PaperMC/Paper@5d91bef Fix shulkerbox loot table replenish (#11366) PaperMC/Paper@a8e6a93 Deprecate for removal all OldEnum-related methods (#11371) PaperMC/Paper@925c3b9 Add FeatureFlag API (#8952) PaperMC/Paper@426f992 Enchantment is data-driven, so not FeatureDependant (#11377) PaperMC/Paper@1ba1be7 Update Velocity natives again PaperMC/Paper@7632de5 Tag Lifecycle Events (#10993) PaperMC/Paper@b09eaf2 Add Item serialization as json api (#11235) PaperMC/Paper@971a7a5 Add Decorated Pot Cracked API (#11365) PaperMC/Paper@61fe23c deprecate isEnabledByFeature in Item/BlockType PaperMC/Paper@e945cfe Fix PaperServerListPingEvent#getPlayerSample not being populated or used (#11387) PaperMC/Paper@4ff58c4 Update spark PaperMC/Paper@d1a72ea Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11405) PaperMC/Paper@0a53f1d Set default drop behavior for player deaths (#11380) PaperMC/Paper@951e7dd Fix TrialSpawner forgetting assigned mob when placed by player (#11381) PaperMC/Paper@13a2395 Fix enable-player-collisions playing sounds when set to false (#11390) PaperMC/Paper@1348e44 Prevent NPE when serializing unresolved profile (#11407) PaperMC/Paper@2aaf436 Validate slot in PlayerInventory#setSlot (#11399) PaperMC/Paper@5c82955 Only mark decorations dirty if a removal actually occurs (#11413) PaperMC/Paper@c5a1066 Remove wall-time / unused skip tick protection (#11412)
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 eaafb99543869234e6bb8eb227bf9a0d6e8346d0..ec47e7da3c06ee74e0c134e4a881ab373fc68af8 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -1668,10 +1668,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) {
|
|
@@ -1686,7 +1694,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);
|