Skip to content

Commit

Permalink
refactor: there is no need for entity spawner to access other chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jun 19, 2024
1 parent 77dc998 commit 106be22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit 106be22

Please sign in to comment.