mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-12-10 14:33:32 +01:00
Added biomes
This commit is contained in:
parent
f022d072c3
commit
2446ed5340
@ -16,6 +16,7 @@ import world.bentobox.bentobox.api.commands.island.DefaultPlayerCommand;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.boxed.generators.BasicWorldGenerator;
|
||||
import world.bentobox.boxed.generators.BoxedBiomeGenerator;
|
||||
import world.bentobox.boxed.generators.DeleteGen;
|
||||
import world.bentobox.boxed.listeners.AdvancementListener;
|
||||
import world.bentobox.boxed.listeners.EnderPearlListener;
|
||||
@ -52,6 +53,7 @@ public class Boxed extends GameModeAddon {
|
||||
generator.setBaseNoiseGenerator(new BasicWorldGenerator(this, wordRef, getSettings().getSeed()));
|
||||
generator.getWorldDecorator().withoutDefaultDecorations(DecorationType.SURFACE_STRUCTURES);
|
||||
generator.getWorldDecorator().withoutDefaultDecorations(DecorationType.STRONGHOLDS);
|
||||
generator.setBiomeGenerator(new BoxedBiomeGenerator(this));
|
||||
});
|
||||
// Register commands
|
||||
playerCommand = new DefaultPlayerCommand(this)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package world.bentobox.boxed.generators;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.util.noise.SimplexNoiseGenerator;
|
||||
|
||||
import nl.rutgerkok.worldgeneratorapi.BaseNoiseGenerator;
|
||||
@ -29,13 +30,26 @@ public class BasicWorldGenerator implements BaseNoiseGenerator {
|
||||
//addon.getPlugin().logDebug("1 Scaled x = " + scaledX + " scaled z = " + scaledZ);
|
||||
// Repeat on an island boundary
|
||||
int dist = addon.getSettings().getIslandDistance();
|
||||
double height = 8;
|
||||
scaledX = ((scaledX*4) % dist) / 4;
|
||||
scaledZ = ((scaledZ*4) % dist) / 4;
|
||||
|
||||
float noiseScaleHorizontal = addon.getSettings().getNoiseScaleHorizontal();
|
||||
Biome biome = biomeGenerator.getZoomedOutBiome(scaledX, scaledZ);
|
||||
double noiseScaleHorizontal = addon.getSettings().getNoiseScaleHorizontal();
|
||||
if (biome.equals(Biome.SNOWY_TAIGA)) {
|
||||
noiseScaleHorizontal = noiseScaleHorizontal / 2;
|
||||
} else if (biome.equals(Biome.MOUNTAINS)) {
|
||||
height = 10;
|
||||
noiseScaleHorizontal = noiseScaleHorizontal / 4;
|
||||
} else if (biome.equals(Biome.DESERT)) {
|
||||
height = 9;
|
||||
noiseScaleHorizontal = noiseScaleHorizontal * 1.5F;
|
||||
} else if (biome.equals(Biome.BADLANDS)) {
|
||||
height = 8.5;
|
||||
noiseScaleHorizontal = noiseScaleHorizontal * 1.5F;
|
||||
}
|
||||
for (int y = 0; y < buffer.length; y++) {
|
||||
double noise = this.mainNoiseGenerator.noise(scaledX / noiseScaleHorizontal, y, scaledZ / noiseScaleHorizontal);
|
||||
int heightOffset = -y + 8;
|
||||
double heightOffset = height - y;
|
||||
buffer[y] = noise + heightOffset;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package world.bentobox.boxed.generators;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
|
||||
import world.bentobox.boxed.Boxed;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class BoxedBiomeGenerator implements BiomeGenerator {
|
||||
|
||||
private final Boxed addon;
|
||||
private final int dist;
|
||||
private final int offsetX;
|
||||
private final int offsetZ;
|
||||
|
||||
public BoxedBiomeGenerator(Boxed boxed) {
|
||||
this.addon = boxed;
|
||||
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, y * 4, z * 4);
|
||||
Vector l = getClosestIsland(s);
|
||||
double d = l.distance(s) / addon.getSettings().getIslandDistance();
|
||||
if (d < 0.2) {
|
||||
return Biome.PLAINS;
|
||||
} else if (d < 0.3) {
|
||||
return Biome.FOREST;
|
||||
} else if (d < 0.33) {
|
||||
return Biome.SNOWY_TAIGA;
|
||||
} else if (d < 0.4) {
|
||||
return Biome.DARK_FOREST;
|
||||
} else if (d < 0.45) {
|
||||
return Biome.MOUNTAINS;
|
||||
} else if (d < 0.52) {
|
||||
return Biome.DESERT;
|
||||
}
|
||||
return Biome.BADLANDS;
|
||||
}
|
||||
|
||||
public Vector getClosestIsland(Vector v) {
|
||||
long x = Math.round((double) v.getBlockX() / dist) * dist + offsetX;
|
||||
long z = Math.round((double) v.getBlockZ() / dist) * dist + offsetZ;
|
||||
return new Vector(x, v.getBlockY(), z);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user