remove world instance from BukkitChunkGeneratorWrapper

This commit is contained in:
dfsek
2021-12-24 00:08:45 -07:00
parent 5da0a861b6
commit 6729565a59
4 changed files with 41 additions and 16 deletions

View File

@@ -53,10 +53,10 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
@Override
@SuppressWarnings("try")
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
int chunkX, int chunkZ) {
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
BiomeProvider grid = world.getBiomeProvider();
BiomeProvider grid = configPack.getBiomeProvider();
int xOrig = (chunkX << 4);
int zOrig = (chunkZ << 4);
@@ -65,7 +65,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
long seed = world.getSeed();
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(world.getBiomeProvider(),
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(configPack.getBiomeProvider(),
chunkX,
chunkZ,
world.getMaxHeight(),

View File

@@ -18,7 +18,7 @@ import com.dfsek.terra.api.world.WritableWorld;
public interface ChunkGenerator {
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
int chunkX, int chunkZ);
BlockState getBlock(WorldProperties world, int x, int y, int z);

View File

@@ -19,6 +19,8 @@ package com.dfsek.terra.bukkit.generator;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.bukkit.world.BukkitWorldProperties;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.generator.BiomeProvider;
@@ -44,8 +46,6 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
private final ChunkGenerator delegate;
private final ConfigPack pack;
private final BlockState air;
private World world;
private ServerWorld terraWorld;
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack, BlockState air) {
this.delegate = delegate;
@@ -60,11 +60,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
@Override
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunkData) {
if(this.world == null) {
this.world = Bukkit.getWorld(worldInfo.getUID());
this.terraWorld = new BukkitServerWorld(world);
}
delegate.generateChunkData(new BukkitProtoChunk(chunkData), terraWorld, x, z);
delegate.generateChunkData(new BukkitProtoChunk(chunkData), new BukkitWorldProperties(worldInfo), x, z);
}
@Override
@@ -105,11 +101,6 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
//return pack.vanillaStructures();
}
public World getWorld() {
return world;
}
public ConfigPack getPack() {
return pack;
}

View File

@@ -0,0 +1,34 @@
package com.dfsek.terra.bukkit.world;
import com.dfsek.terra.api.world.info.WorldProperties;
import org.bukkit.generator.WorldInfo;
public class BukkitWorldProperties implements WorldProperties {
private final WorldInfo delegate;
public BukkitWorldProperties(WorldInfo delegate) {
this.delegate = delegate;
}
@Override
public Object getHandle() {
return delegate;
}
@Override
public long getSeed() {
return delegate.getSeed();
}
@Override
public int getMaxHeight() {
return delegate.getMaxHeight();
}
@Override
public int getMinHeight() {
return delegate.getMinHeight();
}
}