mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-09-29 04:07:42 +02:00
Enable Nether biomes via biomes.yml config.
This commit is contained in:
parent
8f109d57ff
commit
04ab9ae381
@ -0,0 +1,140 @@
|
|||||||
|
package world.bentobox.boxed.generators;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.google.common.base.Enums;
|
||||||
|
|
||||||
|
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
|
||||||
|
import world.bentobox.boxed.Boxed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author tastybento
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator {
|
||||||
|
|
||||||
|
private static final Map<Environment, String> ENV_MAP;
|
||||||
|
static {
|
||||||
|
Map<Environment, String> e = new EnumMap<>(Environment.class);
|
||||||
|
e.put(Environment.NORMAL, "distribution.overworld");
|
||||||
|
e.put(Environment.NETHER, "distribution.nether");
|
||||||
|
e.put(Environment.THE_END, "distribution.the_end");
|
||||||
|
ENV_MAP = Collections.unmodifiableMap(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final SortedMap<Double, Biome> northEast;
|
||||||
|
private final SortedMap<Double, Biome> southEast;
|
||||||
|
private final SortedMap<Double, Biome> northWest;
|
||||||
|
private final SortedMap<Double, Biome> southWest;
|
||||||
|
|
||||||
|
protected final Map<BlockFace, SortedMap<Double, Biome>> quadrants;
|
||||||
|
|
||||||
|
private final Boxed addon;
|
||||||
|
protected final int dist;
|
||||||
|
private final int offsetX;
|
||||||
|
private final int offsetZ;
|
||||||
|
private final Biome defaultBiome;
|
||||||
|
|
||||||
|
|
||||||
|
public AbstractBoxedBiomeGenerator(Boxed boxed, Environment env, Biome defaultBiome) {
|
||||||
|
this.addon = boxed;
|
||||||
|
this.defaultBiome = defaultBiome;
|
||||||
|
dist = addon.getSettings().getIslandDistance();
|
||||||
|
offsetX = addon.getSettings().getIslandXOffset();
|
||||||
|
offsetZ = addon.getSettings().getIslandZOffset();
|
||||||
|
// Load the config
|
||||||
|
File biomeFile = new File(addon.getDataFolder(), "biomes.yml");
|
||||||
|
if (!biomeFile.exists()) {
|
||||||
|
addon.saveResource("biomes.yml", true);
|
||||||
|
}
|
||||||
|
YamlConfiguration config = YamlConfiguration.loadConfiguration(biomeFile);
|
||||||
|
northEast = loadQuad(config, ENV_MAP.get(env) + ".north-east");
|
||||||
|
southEast = loadQuad(config, ENV_MAP.get(env) + ".south-east");
|
||||||
|
northWest = loadQuad(config, ENV_MAP.get(env) + ".north-west");
|
||||||
|
southWest = loadQuad(config, ENV_MAP.get(env) + ".south-west");
|
||||||
|
|
||||||
|
quadrants = new EnumMap<>(BlockFace.class);
|
||||||
|
quadrants.put(BlockFace.NORTH_EAST, northEast);
|
||||||
|
quadrants.put(BlockFace.NORTH_WEST, northWest);
|
||||||
|
quadrants.put(BlockFace.SOUTH_EAST, southEast);
|
||||||
|
quadrants.put(BlockFace.SOUTH_WEST, southWest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private SortedMap<Double, Biome> loadQuad(YamlConfiguration config, String string) {
|
||||||
|
SortedMap<Double, Biome> result = new TreeMap<>();
|
||||||
|
if (config.contains(string)) {
|
||||||
|
for (String ring : config.getStringList(string)) {
|
||||||
|
String[] split = ring.split(":");
|
||||||
|
if (split.length == 2 && NumberUtils.isNumber(split[0])) {
|
||||||
|
try {
|
||||||
|
double d = Double.parseDouble(split[0]);
|
||||||
|
Biome biome = Enums.getIfPresent(Biome.class, split[1].toUpperCase(Locale.ENGLISH)).orNull();
|
||||||
|
if (biome == null) {
|
||||||
|
addon.logError(split[1].toUpperCase(Locale.ENGLISH) + " is an unknown biome on this server.");
|
||||||
|
} else {
|
||||||
|
result.put(d, biome);
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
addon.logError(string + ": " + split[0] + " does not seem to be a double. For integers add a .0 to the end");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addon.logError(ring + " must be in the format ratio:biome where ratio is a double.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome getZoomedOutBiome(int x, int y, int z) {
|
||||||
|
/*
|
||||||
|
* The given x, y and z coordinates are scaled down by a factor of 4. So when Minecraft
|
||||||
|
* wants to know the biome at x=112, it will ask the biome generator for a biome at x=112/4=28.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Biomes go around the island centers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Vector s = new Vector(x * 4, 0, z * 4);
|
||||||
|
Vector l = getClosestIsland(s);
|
||||||
|
double dis = l.distanceSquared(s);
|
||||||
|
double d = dis / (dist * dist);
|
||||||
|
Vector direction = s.subtract(l);
|
||||||
|
if (direction.getBlockX() <= 0 && direction.getBlockZ() <= 0) {
|
||||||
|
return getBiome(BlockFace.NORTH_WEST, d);
|
||||||
|
} else if (direction.getBlockX() > 0 && direction.getBlockZ() <= 0) {
|
||||||
|
return getBiome(BlockFace.NORTH_EAST, d);
|
||||||
|
} else if (direction.getBlockX() <= 0 && direction.getBlockZ() > 0) {
|
||||||
|
return getBiome(BlockFace.SOUTH_WEST, d);
|
||||||
|
}
|
||||||
|
return getBiome(BlockFace.SOUTH_EAST, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Biome getBiome(BlockFace dir, double d) {
|
||||||
|
Entry<Double, Biome> en = ((TreeMap<Double, Biome>) quadrants.get(dir)).ceilingEntry(d);
|
||||||
|
return en == null ? defaultBiome : en.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getClosestIsland(Vector v) {
|
||||||
|
int d = dist * 2;
|
||||||
|
long x = Math.round((double) v.getBlockX() / d) * d + offsetX;
|
||||||
|
long z = Math.round((double) v.getBlockZ() / d) * d + offsetZ;
|
||||||
|
return new Vector(x, 0, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,131 +1,18 @@
|
|||||||
package world.bentobox.boxed.generators;
|
package world.bentobox.boxed.generators;
|
||||||
|
|
||||||
import java.io.File;
|
import org.bukkit.World.Environment;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import com.google.common.base.Enums;
|
|
||||||
|
|
||||||
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
|
|
||||||
import world.bentobox.boxed.Boxed;
|
import world.bentobox.boxed.Boxed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BoxedBiomeGenerator implements BiomeGenerator {
|
public class BoxedBiomeGenerator extends AbstractBoxedBiomeGenerator {
|
||||||
|
|
||||||
private final SortedMap<Double, Biome> northEast;
|
|
||||||
private final SortedMap<Double, Biome> southEast;
|
|
||||||
private final SortedMap<Double, Biome> northWest;
|
|
||||||
private final SortedMap<Double, Biome> southWest;
|
|
||||||
|
|
||||||
private final Map<BlockFace, SortedMap<Double, Biome>> quadrants;
|
|
||||||
|
|
||||||
private final Boxed addon;
|
|
||||||
private final int dist;
|
|
||||||
private final int offsetX;
|
|
||||||
private final int offsetZ;
|
|
||||||
|
|
||||||
|
|
||||||
public BoxedBiomeGenerator(Boxed boxed) {
|
public BoxedBiomeGenerator(Boxed boxed) {
|
||||||
this.addon = boxed;
|
super(boxed, Environment.NORMAL, Biome.OCEAN);
|
||||||
dist = addon.getSettings().getIslandDistance();
|
|
||||||
offsetX = addon.getSettings().getIslandXOffset();
|
|
||||||
offsetZ = addon.getSettings().getIslandZOffset();
|
|
||||||
// Load the config
|
|
||||||
File biomeFile = new File(addon.getDataFolder(), "biomes.yml");
|
|
||||||
if (!biomeFile.exists()) {
|
|
||||||
addon.saveResource("biomes.yml", true);
|
|
||||||
}
|
|
||||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(biomeFile);
|
|
||||||
northEast = loadQuad(config, "distribution.overworld.north-east");
|
|
||||||
southEast = loadQuad(config, "distribution.overworld.south-east");
|
|
||||||
northWest = loadQuad(config, "distribution.overworld.north-west");
|
|
||||||
southWest = loadQuad(config, "distribution.overworld.south-west");
|
|
||||||
|
|
||||||
quadrants = new EnumMap<>(BlockFace.class);
|
|
||||||
quadrants.put(BlockFace.NORTH_EAST, northEast);
|
|
||||||
quadrants.put(BlockFace.NORTH_WEST, northWest);
|
|
||||||
quadrants.put(BlockFace.SOUTH_EAST, southEast);
|
|
||||||
quadrants.put(BlockFace.SOUTH_WEST, southWest);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private SortedMap<Double, Biome> loadQuad(YamlConfiguration config, String string) {
|
|
||||||
SortedMap<Double, Biome> result = new TreeMap<>();
|
|
||||||
if (config.contains(string)) {
|
|
||||||
for (String ring : config.getStringList(string)) {
|
|
||||||
String[] split = ring.split(":");
|
|
||||||
if (split.length == 2 && NumberUtils.isNumber(split[0])) {
|
|
||||||
try {
|
|
||||||
double d = Double.parseDouble(split[0]);
|
|
||||||
Biome biome = Enums.getIfPresent(Biome.class, split[1].toUpperCase(Locale.ENGLISH)).orNull();
|
|
||||||
if (biome == null) {
|
|
||||||
addon.logError(split[1].toUpperCase(Locale.ENGLISH) + " is an unknown biome on this server.");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
addon.log(string + " " + biome + " " + d);
|
|
||||||
result.put(d, biome);
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
addon.logError(string + ": " + split[0] + " does not seem to be a double. For integers add a .0 to the end");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
addon.logError(ring + " must be in the format ratio:biome where ratio is a double.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Biome getZoomedOutBiome(int x, int y, int z) {
|
|
||||||
/*
|
|
||||||
* The given x, y and z coordinates are scaled down by a factor of 4. So when Minecraft
|
|
||||||
* wants to know the biome at x=112, it will ask the biome generator for a biome at x=112/4=28.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Biomes go around the island centers
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
Vector s = new Vector(x * 4, 0, z * 4);
|
|
||||||
Vector l = getClosestIsland(s);
|
|
||||||
double dis = l.distanceSquared(s);
|
|
||||||
double d = dis / (dist * dist);
|
|
||||||
Vector direction = s.subtract(l);
|
|
||||||
if (direction.getBlockX() <= 0 && direction.getBlockZ() <= 0) {
|
|
||||||
return getBiome(BlockFace.NORTH_WEST, d);
|
|
||||||
} else if (direction.getBlockX() > 0 && direction.getBlockZ() <= 0) {
|
|
||||||
return getBiome(BlockFace.NORTH_EAST, d);
|
|
||||||
} else if (direction.getBlockX() <= 0 && direction.getBlockZ() > 0) {
|
|
||||||
return getBiome(BlockFace.SOUTH_WEST, d);
|
|
||||||
}
|
|
||||||
return getBiome(BlockFace.SOUTH_EAST, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Biome getBiome(BlockFace dir, double d) {
|
|
||||||
Entry<Double, Biome> en = ((TreeMap<Double, Biome>) quadrants.get(dir)).ceilingEntry(d);
|
|
||||||
return en == null ? Biome.OCEAN : en.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector getClosestIsland(Vector v) {
|
|
||||||
int d = dist * 2;
|
|
||||||
long x = Math.round((double) v.getBlockX() / d) * d + offsetX;
|
|
||||||
long z = Math.round((double) v.getBlockZ() / d) * d + offsetZ;
|
|
||||||
return new Vector(x, 0, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,11 @@ public class BoxedChunkGenerator {
|
|||||||
private final WorldRef wordRef;
|
private final WorldRef wordRef;
|
||||||
private final Boxed addon;
|
private final Boxed addon;
|
||||||
private WorldRef wordRefNether;
|
private WorldRef wordRefNether;
|
||||||
private WorldRef wordRefEnd;
|
|
||||||
|
|
||||||
public BoxedChunkGenerator(Boxed addon) {
|
public BoxedChunkGenerator(Boxed addon) {
|
||||||
this.addon = addon;
|
this.addon = addon;
|
||||||
wordRef = WorldRef.ofName(addon.getSettings().getWorldName());
|
wordRef = WorldRef.ofName(addon.getSettings().getWorldName());
|
||||||
wordRefNether = WorldRef.ofName(addon.getSettings().getWorldName() + "_nether");
|
wordRefNether = WorldRef.ofName(addon.getSettings().getWorldName() + "_nether");
|
||||||
wordRefEnd = WorldRef.ofName(addon.getSettings().getWorldName() + "_end");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkGenerator getGenerator() {
|
public ChunkGenerator getGenerator() {
|
||||||
|
@ -1,149 +1,18 @@
|
|||||||
package world.bentobox.boxed.generators;
|
package world.bentobox.boxed.generators;
|
||||||
|
|
||||||
import java.util.Collections;
|
import org.bukkit.World.Environment;
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
|
|
||||||
import world.bentobox.boxed.Boxed;
|
import world.bentobox.boxed.Boxed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NetherBiomeGenerator implements BiomeGenerator {
|
public class NetherBiomeGenerator extends AbstractBoxedBiomeGenerator {
|
||||||
|
|
||||||
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 {
|
|
||||||
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 {
|
|
||||||
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 {
|
|
||||||
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 {
|
|
||||||
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 {
|
|
||||||
Map<BlockFace, SortedMap<Double, Biome>> q = new EnumMap<>(BlockFace.class);
|
|
||||||
q.put(BlockFace.NORTH_EAST, NORTH_EAST);
|
|
||||||
q.put(BlockFace.NORTH_WEST, NORTH_WEST);
|
|
||||||
q.put(BlockFace.SOUTH_EAST, SOUTH_EAST);
|
|
||||||
q.put(BlockFace.SOUTH_WEST, SOUTH_WEST);
|
|
||||||
QUADRANTS = Collections.unmodifiableMap(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private final Boxed addon;
|
|
||||||
private final int dist;
|
|
||||||
private final int offsetX;
|
|
||||||
private final int offsetZ;
|
|
||||||
|
|
||||||
|
|
||||||
public NetherBiomeGenerator(Boxed boxed) {
|
public NetherBiomeGenerator(Boxed boxed) {
|
||||||
this.addon = boxed;
|
super(boxed, Environment.NETHER, Biome.NETHER_WASTES);
|
||||||
dist = addon.getSettings().getIslandDistance();
|
|
||||||
offsetX = addon.getSettings().getIslandXOffset();
|
|
||||||
offsetZ = addon.getSettings().getIslandZOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Biome getZoomedOutBiome(int x, int y, int z) {
|
|
||||||
/*
|
|
||||||
* The given x, y and z coordinates are scaled down by a factor of 4. So when Minecraft
|
|
||||||
* wants to know the biome at x=112, it will ask the biome generator for a biome at x=112/4=28.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Biomes go around the island centers
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
Vector s = new Vector(x * 4, 0, z * 4);
|
|
||||||
Vector l = getClosestIsland(s);
|
|
||||||
double dis = l.distanceSquared(s);
|
|
||||||
double d = dis / (dist * dist);
|
|
||||||
Vector direction = s.subtract(l);
|
|
||||||
if (direction.getBlockX() <= 0 && direction.getBlockZ() <= 0) {
|
|
||||||
return getBiome(BlockFace.NORTH_WEST, d);
|
|
||||||
} else if (direction.getBlockX() > 0 && direction.getBlockZ() <= 0) {
|
|
||||||
return getBiome(BlockFace.NORTH_EAST, d);
|
|
||||||
} else if (direction.getBlockX() <= 0 && direction.getBlockZ() > 0) {
|
|
||||||
return getBiome(BlockFace.SOUTH_WEST, d);
|
|
||||||
}
|
|
||||||
return getBiome(BlockFace.SOUTH_EAST, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Biome getBiome(BlockFace dir, double d) {
|
|
||||||
Entry<Double, Biome> en = ((TreeMap<Double, Biome>) QUADRANTS.get(dir)).ceilingEntry(d);
|
|
||||||
return en == null ? Biome.NETHER_WASTES : en.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector getClosestIsland(Vector v) {
|
|
||||||
int d = dist * 2;
|
|
||||||
long x = Math.round((double) v.getBlockX() / d) * d + offsetX;
|
|
||||||
long z = Math.round((double) v.getBlockZ() / d) * d + offsetZ;
|
|
||||||
return new Vector(x, 0, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,23 +100,6 @@ public class NetherGenerator implements BaseNoiseGenerator {
|
|||||||
double heightOffset = y < 12 && bm.height != 0 ? bm.height - y : 0;
|
double heightOffset = y < 12 && bm.height != 0 ? bm.height - y : 0;
|
||||||
buffer[y] = noise + heightOffset;
|
buffer[y] = noise + heightOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
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) * 2;
|
|
||||||
double heightOffset = y - height;
|
|
||||||
buffer[y] = noise + heightOffset;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -49,6 +49,47 @@ distribution:
|
|||||||
- 0.9:MOUNTAIN_EDGE
|
- 0.9:MOUNTAIN_EDGE
|
||||||
- 1.1:ICE_SPIKES
|
- 1.1:ICE_SPIKES
|
||||||
- 20.0:COLD_OCEAN
|
- 20.0:COLD_OCEAN
|
||||||
|
nether:
|
||||||
|
north-east:
|
||||||
|
- 0.03:NETHER_WASTES
|
||||||
|
- 0.14:CRIMSON_FOREST
|
||||||
|
- 0.26:NETHER_WASTES
|
||||||
|
- 0.51:WARPED_FOREST
|
||||||
|
- 0.76:NETHER_WASTES
|
||||||
|
- 1.1:CRIMSON_FOREST
|
||||||
|
- 1.36:SOUL_SAND_VALLEY
|
||||||
|
- 1.6:BASALT_DELTAS
|
||||||
|
- 2.1:NETHER_WASTES
|
||||||
|
south-east:
|
||||||
|
- 0.03:NETHER_WASTES
|
||||||
|
- 0.05:CRIMSON_FOREST
|
||||||
|
- 0.23:NETHER_WASTES
|
||||||
|
- 0.48:WARPED_FOREST
|
||||||
|
- 0.70:NETHER_WASTES
|
||||||
|
- 1.0:CRIMSON_FOREST
|
||||||
|
- 1.2:SOUL_SAND_VALLEY
|
||||||
|
- 1.9:BASALT_DELTAS
|
||||||
|
- 2.0:NETHER_WASTES
|
||||||
|
north-west:
|
||||||
|
- 0.03:NETHER_WASTES
|
||||||
|
- 0.15:CRIMSON_FOREST
|
||||||
|
- 0.20:NETHER_WASTES
|
||||||
|
- 0.3:WARPED_FOREST
|
||||||
|
- 0.5:NETHER_WASTES
|
||||||
|
- 1.0:CRIMSON_FOREST
|
||||||
|
- 1.25:SOUL_SAND_VALLEY
|
||||||
|
- 1.5:BASALT_DELTAS
|
||||||
|
- 2.0:NETHER_WASTES
|
||||||
|
south-west:
|
||||||
|
- 0.03:NETHER_WASTES
|
||||||
|
- 0.11:CRIMSON_FOREST
|
||||||
|
- 0.22:NETHER_WASTES
|
||||||
|
- 0.51:WARPED_FOREST
|
||||||
|
- 0.73:NETHER_WASTES
|
||||||
|
- 1.1:CRIMSON_FOREST
|
||||||
|
- 1.26:SOUL_SAND_VALLEY
|
||||||
|
- 1.54:BASALT_DELTAS
|
||||||
|
- 2.1:NETHER_WASTES
|
||||||
nether:
|
nether:
|
||||||
biomes:
|
biomes:
|
||||||
NETHER_WASTES:
|
NETHER_WASTES:
|
||||||
|
Loading…
Reference in New Issue
Block a user