diff --git a/gale-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch b/gale-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch index 96f847f7..855578f8 100644 --- a/gale-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch +++ b/gale-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch @@ -288,7 +288,7 @@ this.tickingBlockEntities = true; if (!this.pendingBlockEntityTickers.isEmpty()) { this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); -@@ -2127,6 +_,13 @@ +@@ -2127,6 +_,22 @@ public BiomeManager getBiomeManager() { return this.biomeManager; } @@ -300,5 +300,18 @@ + } + // Gale end - Cache - BiomeManager.getBiome() ++ // Gale start - use reusable entity list ++ @Override ++ public List getEntities(@Nullable Entity except, AABB area) { ++ List list = org.galemc.gale.util.entity.EntityCollectionUtil.getEntityList(); ++ this.getEntities().get(net.minecraft.world.level.entity.EntityTypeTest.forClass(Entity.class), area, (net.minecraft.util.AbortableIterationConsumer) entity -> { ++ if (entity != except && !entity.isSpectator()) { ++ list.add(entity); ++ } ++ return net.minecraft.util.AbortableIterationConsumer.Continuation.CONTINUE; ++ }); ++ return list; ++ } ++ // Gale end - use reusable entity list public final boolean isDebug() { return this.isDebug; diff --git a/gale-server/src/main/java/org/galemc/gale/util/entity/EntityCollectionUtil.java b/gale-server/src/main/java/org/galemc/gale/util/entity/EntityCollectionUtil.java new file mode 100644 index 00000000..29b1fafa --- /dev/null +++ b/gale-server/src/main/java/org/galemc/gale/util/entity/EntityCollectionUtil.java @@ -0,0 +1,19 @@ +package org.galemc.gale.util.entity; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.world.entity.Entity; + +public final class EntityCollectionUtil { + + private static final int EXPECTED_ENTITIES = 64; + + private static final List ENTITY_LIST = new ArrayList<>(EXPECTED_ENTITIES); + + private EntityCollectionUtil() {} + + public static List getEntityList() { + ENTITY_LIST.clear(); + return ENTITY_LIST; + } +}