9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-20 15:29:33 +00:00
Files
SakuraMC/patches/server/0017-Add-utility-methods-to-EntitySlices.patch
Samsuik ae970e6a71 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly
2023-12-07 16:00:45 +00:00

64 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 3 Aug 2023 13:48:27 +0100
Subject: [PATCH] Add utility methods to EntitySlices
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
index 2d79633d86007c7d40eecf5f9271fa3f351b72b5..d917a19c838ed3d74322abd85e1f737e852b5d7b 100644
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
@@ -251,6 +251,12 @@ public final class ChunkEntitySlices {
return true;
}
+
+ // Sakura start
+ public Entity[] getSectionEntities(int sectionY) {
+ return this.allEntities.getSectionEntities(sectionY);
+ }
+ // Sakura end
public void getHardCollidingEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
this.hardCollidingEntities.getEntities(except, box, into, predicate);
@@ -429,6 +435,18 @@ public final class ChunkEntitySlices {
this.nonEmptyBitset[sectionIndex >>> 6] ^= (1L << (sectionIndex & (Long.SIZE - 1)));
}
}
+
+ // Sakura start
+ public Entity[] getSectionEntities(int sectionY) {
+ var list = entitiesBySection[sectionY - this.manager.minSection];
+
+ if (list != null) {
+ return list.storage;
+ }
+
+ return new Entity[0];
+ }
+ // Sakura end
public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
if (this.count == 0) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 8fd4d63fdbff9c454d903f4797ec9281df7266fc..9ef1d77dd87793577223402808ff7a6baad42ee4 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -228,6 +228,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api
+ // Sakura start
+ public Entity[] getSectionEntities(int chunkX, int chunkY, int chunkZ) {
+ var slices = ((ServerLevel)this).getEntityLookup().getChunk(chunkX, chunkZ);
+ if (slices == null) {
+ return new Entity[0];
+ }
+ return slices.getSectionEntities(chunkY);
+ }
+ // Sakura end
+
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper