diff --git a/server/blocks/Block.ts b/server/blocks/Block.ts index 32490b6..3d43e91 100644 --- a/server/blocks/Block.ts +++ b/server/blocks/Block.ts @@ -236,7 +236,7 @@ export class Block { 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 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 fence = new Block(85).setHardness(2).setBlockName("Fence"); // TODO: Behavior script static readonly pumpkin = new Block(86).setHardness(1).setBlockName("Pumpkin"); diff --git a/server/generators/Hilly.ts b/server/generators/Hilly.ts index 5e3488d..a706c5b 100644 --- a/server/generators/Hilly.ts +++ b/server/generators/Hilly.ts @@ -70,6 +70,7 @@ export class HillyGenerator implements IGenerator { public generate(chunk:Chunk) { 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 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 if (chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId && chunk.getBlockId(x, orgColY, z) === Block.grass.blockId && treeRNG() > 0.995) {