generate sugar cane
This commit is contained in:
parent
9f93f14461
commit
19453b7f16
2 changed files with 17 additions and 1 deletions
|
@ -236,7 +236,7 @@ export class Block {
|
||||||
static readonly snowBlock = new Block(80).setHardness(0.2).setBlockName("Snow"); // TODO: Behavior script
|
static readonly snowBlock = new Block(80).setHardness(0.2).setBlockName("Snow"); // TODO: Behavior script
|
||||||
static readonly cactus = new Block(81).setHardness(0.4).setBlockName("Cactus"); // TODO: Behavior script
|
static readonly cactus = new Block(81).setHardness(0.4).setBlockName("Cactus"); // TODO: Behavior script
|
||||||
static readonly clay = new Block(82).setHardness(0.6).setBehaviour(Behaviour.clay).setBlockName("Clay");
|
static readonly clay = new Block(82).setHardness(0.6).setBehaviour(Behaviour.clay).setBlockName("Clay");
|
||||||
static readonly sugarcane = new Block(83).setHardness(0).setBlockName("Sugar Cane"); // TODO: Behavior script
|
static readonly sugarcane = new Block(83).setHardness(0).setLightPassage(255).setBlockName("Sugar Cane"); // TODO: Behavior script
|
||||||
static readonly jukebox = new Block(84).setHardness(2).setBlockName("Jukebox"); // TODO: Behavior script
|
static readonly jukebox = new Block(84).setHardness(2).setBlockName("Jukebox"); // TODO: Behavior script
|
||||||
static readonly fence = new Block(85).setHardness(2).setBlockName("Fence"); // TODO: Behavior script
|
static readonly fence = new Block(85).setHardness(2).setBlockName("Fence"); // TODO: Behavior script
|
||||||
static readonly pumpkin = new Block(86).setHardness(1).setBlockName("Pumpkin");
|
static readonly pumpkin = new Block(86).setHardness(1).setBlockName("Pumpkin");
|
||||||
|
|
|
@ -70,6 +70,7 @@ export class HillyGenerator implements IGenerator {
|
||||||
|
|
||||||
public generate(chunk:Chunk) {
|
public generate(chunk:Chunk) {
|
||||||
const treeRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
const treeRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
||||||
|
const sugarcaneRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
||||||
const grassRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
const grassRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
||||||
const flowerRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
const flowerRNG = mulberry32(this.seed + chunk.x + chunk.z);
|
||||||
|
|
||||||
|
@ -165,6 +166,21 @@ export class HillyGenerator implements IGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId &&
|
||||||
|
chunk.getBlockId(x, orgColY, z) === Block.sand.blockId &&
|
||||||
|
(((x - 1) < 0 ? false : chunk.getBlockId(x - 1, orgColY, z) === Block.waterStill.blockId) ||
|
||||||
|
((x + 1) > 15 ? false : chunk.getBlockId(x + 1, orgColY, z) === Block.waterStill.blockId) ||
|
||||||
|
((z - 1) < 0 ? false : chunk.getBlockId(x, orgColY, z - 1) === Block.waterStill.blockId) ||
|
||||||
|
((z + 1) > 15 ? false : chunk.getBlockId(x, orgColY, z + 1) === Block.waterStill.blockId)) &&
|
||||||
|
sugarcaneRNG() > 0.695
|
||||||
|
) {
|
||||||
|
let sugarcaneYHeight = 1 + Math.floor(sugarcaneRNG() * 2.9);
|
||||||
|
while (sugarcaneYHeight > 0) {
|
||||||
|
chunk.setBlock(Block.sugarcane.blockId, x, orgColY + sugarcaneYHeight, z);
|
||||||
|
sugarcaneYHeight--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Move trees to it's own generator
|
// TODO: Move trees to it's own generator
|
||||||
if (chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId && chunk.getBlockId(x, orgColY, z) === Block.grass.blockId && treeRNG() > 0.995) {
|
if (chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId && chunk.getBlockId(x, orgColY, z) === Block.grass.blockId && treeRNG() > 0.995) {
|
||||||
|
|
Loading…
Reference in a new issue