Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Deepslate Generation #1379

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/main/java/cn/nukkit/level/generator/Normal.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,33 @@ public void init(ChunkManager level, NukkitRandom random) {
//this should run before all other populators so that we don't do things like generate ground cover on bedrock or something
this.generationPopulators = ImmutableList.of(
new PopulatorBedrock(),
new PopulatorDeepslate(),
new PopulatorGroundCover()
);

this.populators = ImmutableList.of(
new PopulatorOre(STONE, new OreType[]{
new OreType(Block.get(BlockID.COAL_ORE), 20, 17, 0, 128),
new OreType(Block.get(BlockID.COPPER_ORE), 17, 9, 0, 64),
new OreType(Block.get(BlockID.IRON_ORE), 20, 9, 0, 64),
new OreType(Block.get(BlockID.REDSTONE_ORE), 8, 8, 0, 16),
new OreType(Block.get(BlockID.LAPIS_ORE), 1, 7, 0, 16),
new OreType(Block.get(BlockID.GOLD_ORE), 2, 9, 0, 32),
new OreType(Block.get(BlockID.DIAMOND_ORE), 1, 8, 0, 16),
new OreType(Block.get(BlockID.DIRT), 10, 33, 0, 128),
new OreType(Block.get(BlockID.GRAVEL), 8, 33, 0, 128),
new OreType(Block.get(BlockID.STONE, BlockStone.GRANITE), 10, 33, 0, 80),
new OreType(Block.get(BlockID.STONE, BlockStone.DIORITE), 10, 33, 0, 80),
new OreType(Block.get(BlockID.STONE, BlockStone.ANDESITE), 10, 33, 0, 80)
new OreType(Block.get(BlockID.STONE, BlockStone.GRANITE), 10, 33, 8, 80),
new OreType(Block.get(BlockID.STONE, BlockStone.DIORITE), 10, 33, 8, 80),
new OreType(Block.get(BlockID.STONE, BlockStone.ANDESITE), 10, 33, 8, 80)
}),
new PopulatorOre(BlockID.DEEPSLATE, new OreType[]{
new OreType(Block.get(BlockID.DEEPSLATE_COAL_ORE), 20, 17, 0, 8),
new OreType(Block.get(BlockID.DEEPSLATE_COPPER_ORE), 20, 9, -64, 8),
new OreType(Block.get(BlockID.DEEPSLATE_IRON_ORE), 20, 9, -64, 8),
new OreType(Block.get(BlockID.DEEPSLATE_REDSTONE_ORE), 8, 8, -64, 8),
new OreType(Block.get(BlockID.DEEPSLATE_LAPIS_ORE), 1, 7, -64, 8),
new OreType(Block.get(BlockID.DEEPSLATE_GOLD_ORE), 2, 9, -64, 8),
new OreType(Block.get(BlockID.DEEPSLATE_DIAMOND_ORE), 1, 8, -64, 8)
}),
new PopulatorCaves(),
//new PopulatorRavines()
Expand Down Expand Up @@ -363,7 +374,8 @@ public void generateChunk(final int chunkX, final int chunkZ) {

for (int xIn = 0; xIn < 4; ++xIn) {
if ((scaleZ2 += scaleZ) > 0.0f) {
chunk.setBlockId(xSeg * 4 + zIn, ySeg * 8 + yIn, zSeg * 4 + xIn, STONE);
int y = ySeg * 8 + yIn;
chunk.setBlockId(xSeg * 4 + zIn, y, zSeg * 4 + xIn, STONE);
} else if (ySeg * 8 + yIn <= seaHeight) {
chunk.setBlockId(xSeg * 4 + zIn, ySeg * 8 + yIn, zSeg * 4 + xIn, STILL_WATER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public boolean spawn(ChunkManager level, NukkitRandom rand, int replaceId, int x
double zVal = ((double) zSeg + 0.5D - scaleZ) / (randVec1 / 2.0D);

if (xVal * xVal + yVal * yVal + zVal * zVal < 1.0D) {
if (level.getBlockIdAt(xSeg, ySeg, zSeg) == replaceBlockId) {
if (level.getBlockIdAt(xSeg, ySeg, zSeg) != 0) {
level.setBlockAt(xSeg, ySeg, zSeg, blockId, blockData);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
* Places bedrock on the bottom of the world
*/
public class PopulatorBedrock extends Populator {

public static final int BEDROCK_LAYER = -64;
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
chunk.setBlockId(x, 0, z, BEDROCK);
chunk.setBlockId(x, BEDROCK_LAYER, z, BEDROCK);
for (int i = 1; i < 5; i++) {
if (random.nextBoundedInt(i) == 0) { //decreasing amount
chunk.setBlockId(x, i, z, BEDROCK);
chunk.setBlockId(x, BEDROCK_LAYER +i, z, BEDROCK);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PopulatorCaves extends Populator {

public static int caveRarity = 7;//7
public static int caveFrequency = 40;//40
public static int caveMinAltitude = 8;
public static int caveMinAltitude = -56;
public static int caveMaxAltitude = 67;
public static int individualCaveRarity = 25;//25
public static int caveSystemFrequency = 1;
Expand Down Expand Up @@ -143,8 +143,8 @@ protected void generateCaveNode(long seed, FullChunk chunk, double x, double y,
if (xTo > 16)
xTo = 16;

if (yFrom < 1)
yFrom = 1;
if (yFrom < -63)
yFrom = -63;
if (yTo > this.worldHeightCap - 8) {
yTo = this.worldHeightCap - 8;
}
Expand All @@ -158,7 +158,7 @@ protected void generateCaveNode(long seed, FullChunk chunk, double x, double y,
for (int xx = xFrom; (!waterFound) && (xx < xTo); xx++) {
for (int zz = zFrom; (!waterFound) && (zz < zTo); zz++) {
for (int yy = yTo + 1; (!waterFound) && (yy >= yFrom - 1); yy--) {
if (yy >= 0 && yy < this.worldHeightCap) {
if (yy >= -64 && yy < this.worldHeightCap) {
int block = chunk.getBlockId(xx, yy, zz);
if (block == Block.FLOWING_WATER || block == Block.STILL_WATER) {
waterFound = true;
Expand Down Expand Up @@ -198,7 +198,7 @@ protected void generateCaveNode(long seed, FullChunk chunk, double x, double y,
//TODO: check this
// if (this.isSuitableBlock(material, materialAbove, biome))
{
if (yy - 1 < 10) {
if (yy - 1 < -58) {
chunk.setBlock(xx, yy, zz, Block.FLOWING_LAVA);
} else {
chunk.setBlock(xx, yy, zz, Block.AIR);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cn.nukkit.level.generator.populator.impl;

import cn.nukkit.level.ChunkManager;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.populator.type.Populator;
import cn.nukkit.math.NukkitRandom;

/**
* @author DaPorkchop_
* <p>
* Places bedrock on the bottom of the world
*/
public class PopulatorDeepslate extends Populator {

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random, FullChunk chunk) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for(int y = PopulatorBedrock.BEDROCK_LAYER; y < 0; y++) {
if(chunk.getBlockId(x,y,z) == 0) chunk.setBlockId(x, y, z, DEEPSLATE);
}
for (int y = 0; y < 8; y++) {
if (random.nextBoundedInt(y) == 0) {
chunk.setBlockId(x, y, z, DEEPSLATE);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom ra
for (int i = 0; i < type.clusterCount; i++) {
int x = NukkitMath.randomRange(random, sx, ex);
int z = NukkitMath.randomRange(random, sz, ez);
int y = NukkitMath.randomRange(random, type.minHeight, type.maxHeight);
int y = type.minHeight + random.nextBoundedInt((type.maxHeight - type.minHeight) + 1);
if (level.getBlockIdAt(x, y, z) != replaceId) {
continue;
}
Expand Down
Loading