Move BukkitChunkData out of BukkitChunkGenerator

This commit is contained in:
dfsek
2021-07-22 14:19:04 -07:00
parent 2e2f9d854d
commit a753351137
3 changed files with 39 additions and 31 deletions

View File

@@ -0,0 +1,38 @@
package com.dfsek.terra.bukkit.generator;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.world.generator.ChunkData;
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
public class BukkitChunkData implements ChunkData {
private final ChunkGenerator.ChunkData delegate;
public BukkitChunkData(ChunkGenerator.ChunkData delegate) {
this.delegate = delegate;
}
@Override
public ChunkGenerator.ChunkData getHandle() {
return delegate;
}
@Override
public int getMaxHeight() {
return delegate.getMaxHeight();
}
@Override
public void setBlock(int x, int y, int z, @NotNull BlockState blockState) {
delegate.setBlock(x, y, z, ((BukkitBlockState) blockState).getHandle());
}
@Override
public @NotNull BlockState getBlock(int x, int y, int z) {
return BukkitBlockState.newInstance(delegate.getBlockData(x, y, z));
}
}

View File

@@ -18,34 +18,4 @@ public class BukkitChunkGenerator implements com.dfsek.terra.api.world.generator
return delegate;
}
public static class BukkitChunkData implements ChunkData {
private final ChunkGenerator.ChunkData delegate;
public BukkitChunkData(ChunkGenerator.ChunkData delegate) {
this.delegate = delegate;
}
@Override
public ChunkGenerator.ChunkData getHandle() {
return delegate;
}
@Override
public int getMaxHeight() {
return delegate.getMaxHeight();
}
@Override
public void setBlock(int x, int y, int z, @NotNull BlockState blockState) {
delegate.setBlock(x, y, z, ((BukkitBlockState) blockState).getHandle());
}
@Override
public @NotNull BlockState getBlock(int x, int y, int z) {
return BukkitBlockState.newInstance(delegate.getBlockData(x, y, z));
}
}
}

View File

@@ -72,7 +72,7 @@ public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements Gener
com.dfsek.terra.api.world.World bukkitWorld = BukkitAdapter.adapt(world);
if(needsLoad) load(bukkitWorld); // Load population data for world.
delegate.generateBiomes(bukkitWorld, random, x, z, new BukkitBiomeGrid(biome));
return (ChunkData) delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitChunkGenerator.BukkitChunkData(createChunkData(world))).getHandle();
return (ChunkData) delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitChunkData(createChunkData(world))).getHandle();
}
@Override