-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include better vanilla gen + fix placeDecoration
- Loading branch information
Showing
49 changed files
with
5,195 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
387 changes: 387 additions & 0 deletions
387
src/main/java/worldgeneratorextension/vanillagenerator/LICENSE
Large diffs are not rendered by default.
Oops, something went wrong.
505 changes: 505 additions & 0 deletions
505
src/main/java/worldgeneratorextension/vanillagenerator/NormalGenerator.java
Large diffs are not rendered by default.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
src/main/java/worldgeneratorextension/vanillagenerator/biome/BiomeClimate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package worldgeneratorextension.vanillagenerator.biome; | ||
|
||
import cn.nukkit.level.biome.Biome; | ||
import cn.nukkit.level.biome.EnumBiome; | ||
import cn.nukkit.math.NukkitRandom; | ||
import worldgeneratorextension.vanillagenerator.noise.bukkit.SimplexOctaveGenerator; | ||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; | ||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; | ||
|
||
public class BiomeClimate { | ||
|
||
private static final Int2ObjectMap<Climate> CLIMATE_MAP = new Int2ObjectOpenHashMap<>(); | ||
private static final SimplexOctaveGenerator noiseGen; | ||
|
||
static { | ||
int[] biomes = new int[Biome.unorderedBiomes.size()]; | ||
for (int i = 0; i < biomes.length; i++) { | ||
biomes[i] = Biome.unorderedBiomes.get(i).getId(); | ||
} | ||
setBiomeClimate(Climate.DEFAULT, biomes); | ||
setBiomeClimate(Climate.PLAINS, EnumBiome.PLAINS.id, EnumBiome.SUNFLOWER_PLAINS.id, EnumBiome.BEACH.id); | ||
setBiomeClimate(Climate.DESERT, EnumBiome.DESERT.id, EnumBiome.DESERT_HILLS.id, EnumBiome.DESERT_M.id, EnumBiome.MESA.id, EnumBiome.MESA_BRYCE.id, EnumBiome.MESA_PLATEAU.id, EnumBiome.MESA_PLATEAU_F.id, EnumBiome.MESA_PLATEAU_M.id, EnumBiome.MESA_PLATEAU_F_M.id, EnumBiome.HELL.id); | ||
setBiomeClimate(Climate.EXTREME_HILLS, EnumBiome.EXTREME_HILLS.id, EnumBiome.EXTREME_HILLS_PLUS.id, EnumBiome.EXTREME_HILLS_M.id, EnumBiome.EXTREME_HILLS_PLUS_M.id, EnumBiome.STONE_BEACH.id, EnumBiome.EXTREME_HILLS_EDGE.id); | ||
setBiomeClimate(Climate.FOREST, EnumBiome.FOREST.id, EnumBiome.FOREST_HILLS.id, EnumBiome.FLOWER_FOREST.id, EnumBiome.ROOFED_FOREST.id, EnumBiome.ROOFED_FOREST_M.id); | ||
setBiomeClimate(Climate.BIRCH_FOREST, EnumBiome.BIRCH_FOREST.id, EnumBiome.BIRCH_FOREST_HILLS.id, EnumBiome.BIRCH_FOREST_M.id, EnumBiome.BIRCH_FOREST_HILLS_M.id); | ||
setBiomeClimate(Climate.TAIGA, EnumBiome.TAIGA.id, EnumBiome.TAIGA_HILLS.id, EnumBiome.TAIGA_M.id, EnumBiome.MEGA_SPRUCE_TAIGA.id, EnumBiome.MEGA_SPRUCE_TAIGA_HILLS.id); | ||
setBiomeClimate(Climate.SWAMPLAND, EnumBiome.SWAMP.id, EnumBiome.SWAMPLAND_M.id); | ||
setBiomeClimate(Climate.ICE_PLAINS, EnumBiome.ICE_PLAINS.id, EnumBiome.ICE_PLAINS_SPIKES.id, EnumBiome.FROZEN_RIVER.id, EnumBiome.FROZEN_OCEAN.id, EnumBiome.ICE_MOUNTAINS.id); | ||
setBiomeClimate(Climate.MUSHROOM, EnumBiome.MUSHROOM_ISLAND.id, EnumBiome.MUSHROOM_ISLAND_SHORE.id); | ||
setBiomeClimate(Climate.COLD_BEACH, EnumBiome.COLD_BEACH.id); | ||
setBiomeClimate(Climate.JUNGLE, EnumBiome.JUNGLE.id, EnumBiome.JUNGLE_HILLS.id, EnumBiome.JUNGLE_M.id, EnumBiome.BAMBOO_JUNGLE.id, EnumBiome.BAMBOO_JUNGLE_HILLS.id); | ||
setBiomeClimate(Climate.JUNGLE_EDGE, EnumBiome.JUNGLE_EDGE.id, EnumBiome.JUNGLE_EDGE_M.id); | ||
setBiomeClimate(Climate.COLD_TAIGA, EnumBiome.COLD_TAIGA.id, EnumBiome.COLD_TAIGA_HILLS.id, EnumBiome.COLD_TAIGA_M.id); | ||
setBiomeClimate(Climate.MEGA_TAIGA, EnumBiome.MEGA_TAIGA.id, EnumBiome.MEGA_TAIGA_HILLS.id); | ||
setBiomeClimate(Climate.SAVANNA, EnumBiome.SAVANNA.id); | ||
setBiomeClimate(Climate.SAVANNA_MOUNTAINS, EnumBiome.SAVANNA_M.id); | ||
setBiomeClimate(Climate.SAVANNA_PLATEAU, EnumBiome.SAVANNA_PLATEAU.id); | ||
setBiomeClimate(Climate.SAVANNA_PLATEAU_MOUNTAINS, EnumBiome.SAVANNA_PLATEAU_M.id); | ||
setBiomeClimate(Climate.SKY);//, EnumBiome.THE_END.id, EnumBiome.SMALL_END_ISLANDS.id, EnumBiome.END_MIDLANDS.id, EnumBiome.END_HIGHLANDS.id, EnumBiome.END_BARRENS.id | ||
|
||
noiseGen = new SimplexOctaveGenerator(new NukkitRandom(1234), 1); | ||
noiseGen.setScale(1 / 8.0D); | ||
} | ||
|
||
public static double getTemperature(int biome) { | ||
return CLIMATE_MAP.get(biome).getTemperature(); | ||
} | ||
|
||
public static double getHumidity(int biome) { | ||
return CLIMATE_MAP.get(biome).getHumidity(); | ||
} | ||
|
||
public static boolean isWet(int biome) { | ||
return getHumidity(biome) > 0.85D; | ||
} | ||
|
||
public static boolean isCold(int biome, int x, int y, int z) { | ||
return getVariatedTemperature(biome, x, y, z) < 0.15D; | ||
} | ||
|
||
public static boolean isRainy(int biome, int x, int y, int z) { | ||
boolean rainy = CLIMATE_MAP.get(biome).isRainy(); | ||
return rainy && !isCold(biome, x, y, z); | ||
} | ||
|
||
public static boolean isSnowy(int biome, int x, int y, int z) { | ||
boolean rainy = CLIMATE_MAP.get(biome).isRainy(); | ||
return rainy && isCold(biome, x, y, z); | ||
} | ||
|
||
private static double getVariatedTemperature(int biome, int x, int y, int z) { | ||
double temp = CLIMATE_MAP.get(biome).getTemperature(); | ||
if (y > 64) { | ||
double variation = noiseGen.noise(x, z, 0.5D, 2.0D) * 4.0D; | ||
return temp - (variation + (y - 64)) * 0.05D / 30.0D; | ||
} else { | ||
return temp; | ||
} | ||
} | ||
|
||
private static void setBiomeClimate(Climate temp, int... biomes) { | ||
for (int biome : biomes) { | ||
CLIMATE_MAP.put(biome, temp); | ||
} | ||
} | ||
|
||
private static class Climate { | ||
|
||
public static final Climate DEFAULT = new Climate(0.5D, 0.5D, true); | ||
public static final Climate PLAINS = new Climate(0.8D, 0.4D, true); | ||
public static final Climate DESERT = new Climate(2.0D, 0.0D, false); | ||
public static final Climate EXTREME_HILLS = new Climate(0.2D, 0.3D, true); | ||
public static final Climate FOREST = new Climate(0.7D, 0.8D, true); | ||
public static final Climate BIRCH_FOREST = new Climate(0.6D, 0.6D, true); | ||
public static final Climate TAIGA = new Climate(0.25D, 0.8D, true); | ||
public static final Climate SWAMPLAND = new Climate(0.8D, 0.9D, true); | ||
public static final Climate ICE_PLAINS = new Climate(0.0D, 0.5D, true); | ||
public static final Climate MUSHROOM = new Climate(0.9D, 1.0D, true); | ||
public static final Climate COLD_BEACH = new Climate(0.05D, 0.3D, true); | ||
public static final Climate JUNGLE = new Climate(0.95D, 0.9D, true); | ||
public static final Climate JUNGLE_EDGE = new Climate(0.95D, 0.8D, true); | ||
public static final Climate COLD_TAIGA = new Climate(-0.5D, 0.4D, true); | ||
public static final Climate MEGA_TAIGA = new Climate(0.3D, 0.8D, true); | ||
public static final Climate SAVANNA = new Climate(1.2D, 0.0D, false); | ||
public static final Climate SAVANNA_MOUNTAINS = new Climate(1.1D, 0.0D, false); | ||
public static final Climate SAVANNA_PLATEAU = new Climate(1.0D, 0.0D, false); | ||
public static final Climate SAVANNA_PLATEAU_MOUNTAINS = new Climate(0.5D, 0.0D, false); | ||
public static final Climate SKY = new Climate(0.5D, 0.5D, false); | ||
|
||
private final double temperature; | ||
private final double humidity; | ||
private final boolean rainy; | ||
|
||
Climate(double temperature, double humidity, boolean rainy) { | ||
this.temperature = temperature; | ||
this.humidity = humidity; | ||
this.rainy = rainy; | ||
} | ||
|
||
public double getTemperature() { | ||
return this.temperature; | ||
} | ||
|
||
public double getHumidity() { | ||
return this.humidity; | ||
} | ||
|
||
public boolean isRainy() { | ||
return this.rainy; | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
src/main/java/worldgeneratorextension/vanillagenerator/biomegrid/MapLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package worldgeneratorextension.vanillagenerator.biomegrid; | ||
|
||
import cn.nukkit.level.Level; | ||
import cn.nukkit.level.biome.EnumBiome; | ||
import cn.nukkit.level.generator.Generator; | ||
import cn.nukkit.math.NukkitRandom; | ||
import worldgeneratorextension.vanillagenerator.NormalGenerator; | ||
import worldgeneratorextension.vanillagenerator.biomegrid.MapLayerWhittaker.ClimateType; | ||
import worldgeneratorextension.vanillagenerator.biomegrid.MapLayerZoom.ZoomType; | ||
|
||
public abstract class MapLayer { | ||
|
||
private final NukkitRandom random = new NukkitRandom(); | ||
private final long seed; | ||
|
||
public MapLayer(long seed) { | ||
this.seed = seed; | ||
} | ||
|
||
/** | ||
* Creates the instances for the given map. | ||
* @param seed the world seed | ||
* @param environment the type of dimension | ||
* @param worldType the world generator | ||
* @return an array of all map layers this dimension needs | ||
*/ | ||
public static MapLayer[] initialize(long seed, int environment, int worldType) { | ||
if (environment == Level.DIMENSION_OVERWORLD && worldType == Generator.TYPE_FLAT) { | ||
return new MapLayer[]{new MapLayerBiomeConstant(seed, EnumBiome.PLAINS.id), null}; | ||
} else if (environment == Level.DIMENSION_NETHER) { | ||
return new MapLayer[]{new MapLayerBiomeConstant(seed, EnumBiome.HELL.id), null}; | ||
} else if (environment == Level.DIMENSION_THE_END) { | ||
return new MapLayer[]{new MapLayerBiomeConstant(seed, 9), null};//EnumBiome.THE_END.id | ||
} | ||
|
||
int zoom = 2; | ||
if (worldType == NormalGenerator.TYPE_LARGE_BIOMES) { | ||
zoom = 4; | ||
} | ||
|
||
MapLayer layer = new MapLayerNoise(seed); // this is initial land spread layer | ||
layer = new MapLayerWhittaker(seed + 1, layer, ClimateType.WARM_WET); | ||
layer = new MapLayerWhittaker(seed + 1, layer, ClimateType.COLD_DRY); | ||
layer = new MapLayerWhittaker(seed + 2, layer, ClimateType.LARGER_BIOMES); | ||
for (int i = 0; i < 2; i++) { | ||
layer = new MapLayerZoom(seed + 100 + i, layer, ZoomType.BLURRY); | ||
} | ||
for (int i = 0; i < 2; i++) { | ||
layer = new MapLayerErosion(seed + 3 + i, layer); | ||
} | ||
layer = new MapLayerDeepOcean(seed + 4, layer); | ||
|
||
MapLayer layerMountains = new MapLayerBiomeVariation(seed + 200, layer); | ||
for (int i = 0; i < 2; i++) { | ||
layerMountains = new MapLayerZoom(seed + 200 + i, layerMountains); | ||
} | ||
|
||
layer = new MapLayerBiome(seed + 5, layer); | ||
for (int i = 0; i < 2; i++) { | ||
layer = new MapLayerZoom(seed + 200 + i, layer); | ||
} | ||
layer = new MapLayerBiomeEdge(seed + 200, layer); | ||
layer = new MapLayerBiomeVariation(seed + 200, layer, layerMountains); | ||
layer = new MapLayerRarePlains(seed + 201, layer); | ||
layer = new MapLayerZoom(seed + 300, layer); | ||
layer = new MapLayerErosion(seed + 6, layer); | ||
layer = new MapLayerZoom(seed + 400, layer); | ||
layer = new MapLayerBiomeEdgeThin(seed + 400, layer); | ||
layer = new MapLayerShore(seed + 7, layer); | ||
for (int i = 0; i < zoom; i++) { | ||
layer = new MapLayerZoom(seed + 500 + i, layer); | ||
} | ||
|
||
MapLayer layerRiver = layerMountains; | ||
layerRiver = new MapLayerZoom(seed + 300, layerRiver); | ||
layerRiver = new MapLayerZoom(seed + 400, layerRiver); | ||
for (int i = 0; i < zoom; i++) { | ||
layerRiver = new MapLayerZoom(seed + 500 + i, layerRiver); | ||
} | ||
layerRiver = new MapLayerRiver(seed + 10, layerRiver); | ||
layer = new MapLayerRiver(seed + 1000, layerRiver, layer); | ||
|
||
MapLayer layerLowerRes = layer; | ||
for (int i = 0; i < 2; i++) { | ||
layer = new MapLayerZoom(seed + 2000 + i, layer); | ||
} | ||
|
||
layer = new MapLayerSmooth(seed + 1001, layer); | ||
|
||
return new MapLayer[]{layer, layerLowerRes}; | ||
} | ||
|
||
public void setCoordsSeed(int x, int z) { | ||
this.random.setSeed(this.seed); | ||
this.random.setSeed(x * this.random.nextInt() + z * this.random.nextInt() ^ this.seed); | ||
} | ||
|
||
public int nextInt(int max) { | ||
return this.random.nextBoundedInt(max); | ||
} | ||
|
||
public abstract int[] generateValues(int x, int z, int sizeX, int sizeZ); | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/worldgeneratorextension/vanillagenerator/biomegrid/MapLayerBiome.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package worldgeneratorextension.vanillagenerator.biomegrid; | ||
|
||
import cn.nukkit.level.biome.EnumBiome; | ||
|
||
public class MapLayerBiome extends MapLayer { | ||
|
||
private static final int[] WARM = new int[]{EnumBiome.DESERT.id, EnumBiome.DESERT.id, EnumBiome.DESERT.id, EnumBiome.SAVANNA.id, EnumBiome.SAVANNA.id, EnumBiome.PLAINS.id}; | ||
private static final int[] WET = new int[]{EnumBiome.PLAINS.id, EnumBiome.PLAINS.id, EnumBiome.FOREST.id, EnumBiome.BIRCH_FOREST.id, EnumBiome.ROOFED_FOREST.id, EnumBiome.EXTREME_HILLS.id, EnumBiome.SWAMP.id}; | ||
private static final int[] DRY = new int[]{EnumBiome.PLAINS.id, EnumBiome.FOREST.id, EnumBiome.TAIGA.id, EnumBiome.EXTREME_HILLS.id}; | ||
private static final int[] COLD = new int[]{EnumBiome.ICE_PLAINS.id, EnumBiome.ICE_PLAINS.id, EnumBiome.COLD_TAIGA.id}; | ||
private static final int[] WARM_LARGE = new int[]{EnumBiome.MESA_PLATEAU_F.id, EnumBiome.MESA_PLATEAU_F.id, EnumBiome.MESA_PLATEAU.id}; | ||
private static final int[] DRY_LARGE = new int[]{EnumBiome.MEGA_TAIGA.id}; | ||
private static final int[] WET_LARGE = new int[]{EnumBiome.JUNGLE.id, EnumBiome.JUNGLE.id, EnumBiome.BAMBOO_JUNGLE.id}; | ||
|
||
private final MapLayer belowLayer; | ||
|
||
public MapLayerBiome(long seed, MapLayer belowLayer) { | ||
super(seed); | ||
this.belowLayer = belowLayer; | ||
} | ||
|
||
@Override | ||
public int[] generateValues(int x, int z, int sizeX, int sizeZ) { | ||
int[] values = this.belowLayer.generateValues(x, z, sizeX, sizeZ); | ||
|
||
int[] finalValues = new int[sizeX * sizeZ]; | ||
for (int i = 0; i < sizeZ; i++) { | ||
for (int j = 0; j < sizeX; j++) { | ||
int val = values[j + i * sizeX]; | ||
if (val != 0) { | ||
setCoordsSeed(x + j, z + i); | ||
switch (val) { | ||
case 1: | ||
val = DRY[nextInt(DRY.length)]; | ||
break; | ||
case 2: | ||
val = WARM[nextInt(WARM.length)]; | ||
break; | ||
case 3: | ||
case 1003: | ||
val = COLD[nextInt(COLD.length)]; | ||
break; | ||
case 4: | ||
val = WET[nextInt(WET.length)]; | ||
break; | ||
case 1001: | ||
val = DRY_LARGE[nextInt(DRY_LARGE.length)]; | ||
break; | ||
case 1002: | ||
val = WARM_LARGE[nextInt(WARM_LARGE.length)]; | ||
break; | ||
case 1004: | ||
val = WET_LARGE[nextInt(WET_LARGE.length)]; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
finalValues[j + i * sizeX] = val; | ||
} | ||
} | ||
return finalValues; | ||
} | ||
} |
Oops, something went wrong.