mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-11-30 12:54:33 +01:00
More attractive nether.
This commit is contained in:
parent
7b345253c7
commit
d49b9dc9cd
@ -3,6 +3,7 @@ package world.bentobox.boxed;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
@ -187,9 +188,10 @@ public class Boxed extends GameModeAddon {
|
||||
// Set world name
|
||||
worldName2 = env.equals(World.Environment.NETHER) ? worldName2 + NETHER : worldName2;
|
||||
worldName2 = env.equals(World.Environment.THE_END) ? worldName2 + THE_END : worldName2;
|
||||
World w = WorldCreator.name(worldName2).type(WorldType.FLAT).environment(env).generator(chunkGenerator2).createWorld();
|
||||
World w = WorldCreator.name(worldName2).type(WorldType.FLAT).environment(env).generator(chunkGenerator2).seed(settings.getSeed()).createWorld();
|
||||
// Backup world
|
||||
WorldCreator.name(worldName2 + "_bak").type(WorldType.FLAT).environment(env).generator(chunkGenerator2).createWorld();
|
||||
World b = WorldCreator.name(worldName2 + "_bak").type(WorldType.FLAT).environment(env).generator(chunkGenerator2).seed(settings.getSeed()).createWorld();
|
||||
b.setDifficulty(Difficulty.PEACEFUL); // No damage wanted in this world.
|
||||
// Set spawn rates
|
||||
if (w != null) {
|
||||
setSpawnRates(w);
|
||||
|
@ -24,6 +24,9 @@ public class DeleteGen extends ChunkGenerator {
|
||||
public DeleteGen(Boxed addon) {
|
||||
backMap = new HashMap<>();
|
||||
backMap.put(addon.getOverWorld(), Bukkit.getWorld(addon.getOverWorld().getName() + "_bak"));
|
||||
if (addon.getNetherWorld() != null) {
|
||||
backMap.put(addon.getNetherWorld(), Bukkit.getWorld(addon.getNetherWorld().getName() + "_bak"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,66 +20,70 @@ import world.bentobox.boxed.Boxed;
|
||||
*/
|
||||
public class NetherBiomeGenerator implements BiomeGenerator {
|
||||
|
||||
private static final double ONE = 0.05;
|
||||
private static final double TWO = 0.25;
|
||||
private static final double THREE = 0.5;
|
||||
private static final double FOUR = 0.75;
|
||||
private static final double FIVE = 1.0;
|
||||
private static final double SIX = 1.25;
|
||||
private static final double SEVEN = 1.50;
|
||||
private static final double ONE = 0.03;
|
||||
private static final double TWO = 0.13;
|
||||
private static final double THREE = 0.25;
|
||||
private static final double FOUR = 0.5;
|
||||
private static final double FIVE = 0.75;
|
||||
private static final double SIX = 1.0;
|
||||
private static final double SEVEN = 1.25;
|
||||
private static final double EIGHT = 1.75;
|
||||
private static final double LAST = 2.0;
|
||||
|
||||
|
||||
private static final TreeMap<Double, Biome> NORTH_EAST = new TreeMap<>();
|
||||
static {
|
||||
NORTH_EAST.put(ONE, Biome.BASALT_DELTAS);
|
||||
NORTH_EAST.put(TWO, Biome.CRIMSON_FOREST);
|
||||
NORTH_EAST.put(THREE, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_EAST.put(FOUR, Biome.WARPED_FOREST);
|
||||
NORTH_EAST.put(FIVE, Biome.BASALT_DELTAS);
|
||||
NORTH_EAST.put(SIX, Biome.CRIMSON_FOREST);
|
||||
NORTH_EAST.put(SEVEN, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_EAST.put(EIGHT, Biome.WARPED_FOREST);
|
||||
NORTH_EAST.put(LAST, Biome.NETHER_WASTES);
|
||||
double f = 0.01;
|
||||
NORTH_EAST.put(ONE + f, Biome.NETHER_WASTES);
|
||||
NORTH_EAST.put(TWO + f, Biome.CRIMSON_FOREST);
|
||||
NORTH_EAST.put(THREE + f, Biome.NETHER_WASTES);
|
||||
NORTH_EAST.put(FOUR + f, Biome.WARPED_FOREST);
|
||||
NORTH_EAST.put(FIVE + f, Biome.NETHER_WASTES);
|
||||
NORTH_EAST.put(SIX + f, Biome.CRIMSON_FOREST);
|
||||
NORTH_EAST.put(SEVEN + f, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_EAST.put(EIGHT + f, Biome.BASALT_DELTAS);
|
||||
NORTH_EAST.put(LAST + f, Biome.NETHER_WASTES);
|
||||
}
|
||||
private static final TreeMap<Double, Biome> SOUTH_EAST = new TreeMap<>();
|
||||
static {
|
||||
SOUTH_EAST.put(ONE, Biome.NETHER_WASTES);
|
||||
SOUTH_EAST.put(TWO, Biome.BASALT_DELTAS);
|
||||
SOUTH_EAST.put(THREE, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_EAST.put(FOUR, Biome.WARPED_FOREST);
|
||||
SOUTH_EAST.put(FIVE, Biome.NETHER_WASTES);
|
||||
SOUTH_EAST.put(SIX, Biome.BASALT_DELTAS);
|
||||
SOUTH_EAST.put(SEVEN, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_EAST.put(EIGHT, Biome.WARPED_FOREST);
|
||||
SOUTH_EAST.put(LAST, Biome.CRIMSON_FOREST);
|
||||
double f = -0.01;
|
||||
SOUTH_EAST.put(ONE + f, Biome.NETHER_WASTES);
|
||||
SOUTH_EAST.put(TWO + f, Biome.BASALT_DELTAS);
|
||||
SOUTH_EAST.put(THREE + f, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_EAST.put(FOUR + f, Biome.WARPED_FOREST);
|
||||
SOUTH_EAST.put(FIVE + f, Biome.NETHER_WASTES);
|
||||
SOUTH_EAST.put(SIX + f, Biome.BASALT_DELTAS);
|
||||
SOUTH_EAST.put(SEVEN + f, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_EAST.put(EIGHT + f, Biome.WARPED_FOREST);
|
||||
SOUTH_EAST.put(LAST + f, Biome.CRIMSON_FOREST);
|
||||
}
|
||||
|
||||
private static final TreeMap<Double, Biome> NORTH_WEST = new TreeMap<>();
|
||||
static {
|
||||
NORTH_WEST.put(ONE, Biome.NETHER_WASTES);
|
||||
NORTH_WEST.put(TWO, Biome.NETHER_WASTES);
|
||||
NORTH_WEST.put(THREE, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_WEST.put(FOUR, Biome.WARPED_FOREST);
|
||||
NORTH_WEST.put(FIVE, Biome.BASALT_DELTAS);
|
||||
NORTH_WEST.put(SIX, Biome.CRIMSON_FOREST);
|
||||
NORTH_WEST.put(SEVEN, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_WEST.put(EIGHT, Biome.WARPED_FOREST);
|
||||
NORTH_WEST.put(LAST, Biome.NETHER_WASTES);
|
||||
double f = 0.02;
|
||||
NORTH_WEST.put(ONE + f, Biome.NETHER_WASTES);
|
||||
NORTH_WEST.put(TWO + f, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_WEST.put(THREE + f, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_WEST.put(FOUR + f, Biome.BASALT_DELTAS);
|
||||
NORTH_WEST.put(FIVE + f, Biome.NETHER_WASTES);
|
||||
NORTH_WEST.put(SIX + f, Biome.CRIMSON_FOREST);
|
||||
NORTH_WEST.put(SEVEN + f, Biome.SOUL_SAND_VALLEY);
|
||||
NORTH_WEST.put(EIGHT + f, Biome.WARPED_FOREST);
|
||||
NORTH_WEST.put(LAST + f, Biome.NETHER_WASTES);
|
||||
}
|
||||
|
||||
private static final TreeMap<Double, Biome> SOUTH_WEST = new TreeMap<>();
|
||||
static {
|
||||
SOUTH_WEST.put(ONE, Biome.NETHER_WASTES);
|
||||
SOUTH_WEST.put(TWO, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_WEST.put(THREE, Biome.WARPED_FOREST);
|
||||
SOUTH_WEST.put(FOUR, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_WEST.put(FIVE, Biome.BASALT_DELTAS);
|
||||
SOUTH_WEST.put(SIX, Biome.CRIMSON_FOREST);
|
||||
SOUTH_WEST.put(SEVEN, Biome.WARPED_FOREST);
|
||||
SOUTH_WEST.put(EIGHT, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_WEST.put(LAST, Biome.NETHER_WASTES);
|
||||
double f = -0.01;
|
||||
SOUTH_WEST.put(ONE + f, Biome.NETHER_WASTES);
|
||||
SOUTH_WEST.put(TWO + f, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_WEST.put(THREE + f, Biome.NETHER_WASTES);
|
||||
SOUTH_WEST.put(FOUR + f, Biome.SOUL_SAND_VALLEY);
|
||||
SOUTH_WEST.put(FIVE + f, Biome.NETHER_WASTES);
|
||||
SOUTH_WEST.put(SIX + f, Biome.CRIMSON_FOREST);
|
||||
SOUTH_WEST.put(SEVEN + f, Biome.WARPED_FOREST);
|
||||
SOUTH_WEST.put(EIGHT + f, Biome.BASALT_DELTAS);
|
||||
SOUTH_WEST.put(LAST + f, Biome.NETHER_WASTES);
|
||||
}
|
||||
private static final Map<BlockFace, SortedMap<Double, Biome>> QUADRANTS;
|
||||
static {
|
||||
|
@ -1,11 +1,16 @@
|
||||
package world.bentobox.boxed.generators;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.util.noise.PerlinNoiseGenerator;
|
||||
import org.bukkit.util.noise.NoiseGenerator;
|
||||
import org.bukkit.util.noise.SimplexNoiseGenerator;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
import nl.rutgerkok.worldgeneratorapi.BaseNoiseGenerator;
|
||||
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
|
||||
@ -18,23 +23,56 @@ import world.bentobox.boxed.Boxed;
|
||||
*/
|
||||
public class NetherGenerator implements BaseNoiseGenerator {
|
||||
|
||||
private final PerlinNoiseGenerator mainNoiseGenerator;
|
||||
private final BiomeNoise DEFAULT_NOISE = new BiomeNoise(10D, 0D, 2D);
|
||||
private final NoiseGenerator mainNoiseGenerator;
|
||||
private final Boxed addon;
|
||||
private final YamlConfiguration config;
|
||||
private final Map<Biome, BiomeNoise> biomeNoiseMap;
|
||||
|
||||
|
||||
public NetherGenerator(Boxed addon, long seed) {
|
||||
this.addon = addon;
|
||||
// Initialize the noise generator based on the world seed
|
||||
this.mainNoiseGenerator = new PerlinNoiseGenerator(seed);
|
||||
this.mainNoiseGenerator = new SimplexNoiseGenerator(seed);
|
||||
// Load the config
|
||||
File biomeFile = new File(addon.getDataFolder(), "biomes.yml");
|
||||
if (!biomeFile.exists()) {
|
||||
addon.saveResource("biomes.yml", true);
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(biomeFile);
|
||||
biomeNoiseMap = new EnumMap<>(Biome.class);
|
||||
if (config.isConfigurationSection("nether.biomes")) {
|
||||
for (String key : config.getConfigurationSection("nether.biomes").getKeys(false)) {
|
||||
double noiseScaleHorizontal = config.getDouble("nether.biomes." + key + ".scale", 10D);
|
||||
double height = config.getDouble("nether.biomes." + key + ".height", 0D);
|
||||
double noiseScaleVertical = config.getDouble("nether.biomes." + key + ".vscale", 2D);
|
||||
Enums.getIfPresent(Biome.class, key).toJavaUtil()
|
||||
.ifPresent(biome -> biomeNoiseMap.put(biome, new BiomeNoise(noiseScaleHorizontal, height, noiseScaleVertical)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BiomeNoise {
|
||||
double noiseScaleHorizontal = 10D;
|
||||
double height = 0D;
|
||||
double noiseScaleVertical = 2D;
|
||||
/**
|
||||
* @param noiseScaleHorizontal
|
||||
* @param height
|
||||
* @param noiseScaleVertical
|
||||
*/
|
||||
public BiomeNoise(double noiseScaleHorizontal, double height, double noiseScaleVertical) {
|
||||
this.noiseScaleHorizontal = noiseScaleHorizontal;
|
||||
this.height = height;
|
||||
this.noiseScaleVertical = noiseScaleVertical;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BiomeNoise [noiseScaleHorizontal=" + noiseScaleHorizontal + ", height=" + height
|
||||
+ ", noiseScaleVertical=" + noiseScaleVertical + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public TerrainSettings getTerrainSettings() {
|
||||
TerrainSettings ts = new TerrainSettings();
|
||||
@ -47,33 +85,39 @@ public class NetherGenerator implements BaseNoiseGenerator {
|
||||
public void getNoise(BiomeGenerator biomeGenerator, double[] buffer, int scaledX, int scaledZ) {
|
||||
// Repeat on an island boundary
|
||||
int dist = addon.getSettings().getIslandDistance();
|
||||
double noiseScaleHorizontal = 10D;
|
||||
double height = 8D;
|
||||
|
||||
Biome biome = biomeGenerator.getZoomedOutBiome(scaledX, scaledZ);
|
||||
|
||||
if (biome == null) {
|
||||
// edge of island
|
||||
biome = Biome.NETHER_WASTES;
|
||||
height = 6;
|
||||
} else {
|
||||
noiseScaleHorizontal = config.getDouble("nether.biomes." + biome.name() + ".scale", 10D);
|
||||
height = config.getDouble("nether.biomes." + biome.name() + ".height", 8D);
|
||||
return;
|
||||
}
|
||||
BiomeNoise bm = this.biomeNoiseMap.getOrDefault(biome, DEFAULT_NOISE);
|
||||
double x = ((((double)scaledX*4) % dist) / 4) / bm.noiseScaleHorizontal;
|
||||
double z = ((((double)scaledZ*4) % dist) / 4) / bm.noiseScaleHorizontal;
|
||||
for (int y = 0; y < 16; y++) {
|
||||
double noise = this.mainNoiseGenerator.noise(x, y / Math.max(0.5, bm.noiseScaleVertical), z);
|
||||
double heightOffset = y < 12 && bm.height != 0 ? bm.height - y : 0;
|
||||
buffer[y] = noise + heightOffset;
|
||||
}
|
||||
double x = ((((double)scaledX*4) % dist) / 4) / noiseScaleHorizontal;
|
||||
double z = ((((double)scaledZ*4) % dist) / 4) / noiseScaleHorizontal;
|
||||
|
||||
|
||||
/*
|
||||
for (int y = 0; y < buffer.length; y++) {
|
||||
double noise = this.mainNoiseGenerator.noise(x, y, z);
|
||||
double heightOffset = height - y;
|
||||
buffer[y] = noise + heightOffset;
|
||||
}
|
||||
// Ceiling
|
||||
|
||||
x = ((((double)scaledX*4) % dist) / 4);
|
||||
z = ((((double)scaledZ*4) % dist) / 4);
|
||||
for (int y = 15; y > height + 2; y--) {
|
||||
double noise = this.mainNoiseGenerator.noise(x, y, z);
|
||||
double noise = this.mainNoiseGenerator.noise(x, y, z) * 2;
|
||||
double heightOffset = y - height;
|
||||
buffer[y] = noise + heightOffset;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,24 @@
|
||||
nether:
|
||||
biomes:
|
||||
NETHER_WASTES:
|
||||
height: 8
|
||||
scale: 5
|
||||
height: 0
|
||||
vscale: 2
|
||||
scale: 8
|
||||
BASALT_DELTAS:
|
||||
height: 8
|
||||
height: 0
|
||||
vscale: 1
|
||||
scale: 1
|
||||
CRIMSON_FOREST:
|
||||
height: 9
|
||||
height: 10
|
||||
vscale: 10
|
||||
scale: 10
|
||||
SOUL_SAND_VALLEY:
|
||||
height: 9
|
||||
height: 8
|
||||
vscale: 16
|
||||
scale: 16
|
||||
WARPED_FOREST:
|
||||
height: 10
|
||||
height: 9
|
||||
vscale: 10
|
||||
scale: 10
|
||||
biomes:
|
||||
BADLANDS_PLATEAU:
|
||||
|
Loading…
Reference in New Issue
Block a user