From 106be22985e7ff632ace2ae3c6a2891dc9ae3f16 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Wed, 19 Jun 2024 19:16:11 +0800 Subject: [PATCH] refactor: there is no need for entity spawner to access other chunks --- .../api/world/generator/context/EntitySpawnContext.java | 6 +++--- .../allaymc/server/world/generator/AllayWorldGenerator.java | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Allay-API/src/main/java/org/allaymc/api/world/generator/context/EntitySpawnContext.java b/Allay-API/src/main/java/org/allaymc/api/world/generator/context/EntitySpawnContext.java index 4e48a7bca..e3cfa7390 100644 --- a/Allay-API/src/main/java/org/allaymc/api/world/generator/context/EntitySpawnContext.java +++ b/Allay-API/src/main/java/org/allaymc/api/world/generator/context/EntitySpawnContext.java @@ -8,9 +8,9 @@ * * @author daoge_cmd */ -public class EntitySpawnContext extends OtherChunkAccessibleContext { +public class EntitySpawnContext extends Context { - public EntitySpawnContext(UnsafeChunk currentChunk, ChunkAccessible chunkAccessor) { - super(currentChunk, chunkAccessor); + public EntitySpawnContext(UnsafeChunk currentChunk) { + super(currentChunk); } } diff --git a/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGenerator.java b/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGenerator.java index 2f1b959d1..781e6a009 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGenerator.java +++ b/Allay-Server/src/main/java/org/allaymc/server/world/generator/AllayWorldGenerator.java @@ -160,8 +160,7 @@ private void statusEmptyToNoised(Chunk chunk) { private void statusNoisedToFinished(Chunk chunk) { // 装饰地形 - var chunkAccessor = new WorldGeneratorChunkAccessor(chunk); - var populateContext = new PopulateContext(chunk.toUnsafeChunk(), chunkAccessor); + var populateContext = new PopulateContext(chunk.toUnsafeChunk(), new WorldGeneratorChunkAccessor(chunk)); for (var populator : populators) { if (!populator.apply(populateContext)) { log.error("Failed to populate chunk {} with populator {}", chunk, populator.getName()); @@ -177,7 +176,7 @@ private void statusNoisedToFinished(Chunk chunk) { } chunk.setState(ChunkState.LIGHTED); // 生成实体 - var entitySpawnContext = new EntitySpawnContext(chunk.toUnsafeChunk(), chunkAccessor); + var entitySpawnContext = new EntitySpawnContext(chunk.toUnsafeChunk()); for (var entitySpawner : entitySpawners) { if (!entitySpawner.apply(entitySpawnContext)) { log.error("Failed to spawn entity in chunk {} with entity spawner {}", chunk, entitySpawner.getName());