Tweaks to the world generator

This commit is contained in:
MattBDev
2020-02-11 16:13:03 -05:00
parent 1516edbeca
commit f79f2ac29e
5 changed files with 60 additions and 24 deletions

View File

@ -129,7 +129,10 @@ public class BukkitPlotGenerator extends ChunkGenerator
if (result.getChunkData() != null) {
for (int chunkX = 0; chunkX < 16; chunkX++) {
for (int chunkZ = 0; chunkZ < 16; chunkZ++) {
biome.setBiome(chunkX, chunkZ, Biome.PLAINS);
for (int y = 0; y < world.getMaxHeight(); y++) {
biome.setBiome(chunkX, y, chunkZ, Biome.PLAINS);
}
}
}
return result.getChunkData();
@ -178,18 +181,31 @@ public class BukkitPlotGenerator extends ChunkGenerator
ChunkManager.postProcessChunk(loc, result);
}
/**
* Allow spawning everywhere.
*
* @param world Ignored
* @param x Ignored
* @param z Ignored
* @return always true
*/
@Override public boolean canSpawn(@NotNull final World world, final int x, final int z) {
@Override
public boolean canSpawn(@NotNull final World world, final int x, final int z) {
return true;
}
public boolean shouldGenerateCaves() {
return false;
}
public boolean shouldGenerateDecorations() {
return false;
}
public boolean isParallelCapable() {
return true;
}
public boolean shouldGenerateMobs() {
return false;
}
public boolean shouldGenerateStructures() {
return false;
}
@Override public String toString() {
if (this.platformGenerator == this) {
return this.plotGenerator.getName();

View File

@ -9,7 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import lombok.RequiredArgsConstructor;
import java.util.Random;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
@ -17,13 +17,16 @@ import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
import java.util.Random;
@RequiredArgsConstructor final class DelegatePlotGenerator extends IndependentPlotGenerator {
final class DelegatePlotGenerator extends IndependentPlotGenerator {
private final ChunkGenerator chunkGenerator;
private final String world;
public DelegatePlotGenerator(ChunkGenerator chunkGenerator, String world) {
this.chunkGenerator = chunkGenerator;
this.world = world;
}
@Override public void initialize(PlotArea area) {
}
@ -44,13 +47,24 @@ import java.util.Random;
try {
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
@Override public void setBiome(@Range(from = 0, to = 15) int x,
@Range(from = 0, to = 15) int z, Biome biome) {
@Range(from = 0, to = 15) int z, @NotNull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome));
}
//do not annotate with Override until we discontinue support for 1.4.4
public void setBiome(int x, int y, int z, @NotNull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome));
}
@Override @NotNull public Biome getBiome(int x, int z) {
return Biome.FOREST;
}
@Override
public @NotNull Biome getBiome(int x, int y, int z) {
return Biome.FOREST;
}
};
chunkGenerator.generateChunkData(world, random, chunkX, chunkZ, grid);
return;

View File

@ -7,19 +7,21 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import lombok.RequiredArgsConstructor;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
@RequiredArgsConstructor final class BlockStatePopulator extends BlockPopulator {
final class BlockStatePopulator extends BlockPopulator {
private final IndependentPlotGenerator plotGenerator;
private LocalBlockQueue queue;
public BlockStatePopulator(IndependentPlotGenerator plotGenerator) {
this.plotGenerator = plotGenerator;
}
@Override public void populate(@NotNull final World world, @NotNull final Random random,
@NotNull final Chunk source) {
if (this.queue == null) {

View File

@ -417,10 +417,16 @@ import java.util.Set;
public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
@NonNull final BiomeType biomeType) {
final World world = getWorld(worldName);
if (world == null) {
PlotSquared.log("An error occurred setting the biome because the world was null.");
return;
}
final Biome biome = BukkitAdapter.adapt(biomeType);
for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
world.setBiome(x, z, biome);
for (int y = 0; y < world.getMaxHeight(); y++) {
world.setBiome(x, y, z, biome);
}
}
}
}