generate sugar cane on grass instead, forgot this only became a thing in beta 1.8+

This commit is contained in:
Holly Stubbs 2024-10-17 10:02:43 +01:00
parent 19453b7f16
commit db9847634e
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E

View file

@ -63,11 +63,6 @@ export class HillyGenerator implements IGenerator {
return makeNoise3D(this.seedGenerator() * Number.MAX_SAFE_INTEGER); return makeNoise3D(this.seedGenerator() * Number.MAX_SAFE_INTEGER);
} }
// This is soooo much faster than using Math.round in here
private fastRound(num:number) {
return num >= 0.5 ? (num | 0) + 1 : num | 0;
}
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 sugarcaneRNG = mulberry32(this.seed + chunk.x + chunk.z);
@ -78,7 +73,7 @@ export class HillyGenerator implements IGenerator {
for (let x = 0; x < 16; x++) { for (let x = 0; x < 16; x++) {
for (let z = 0; z < 16; z++) { for (let z = 0; z < 16; z++) {
const oceanValue = this.oceanGenerator((chunk.x * 16 + x) / 128, (chunk.z * 16 + z) / 128) * 100; const oceanValue = this.oceanGenerator((chunk.x * 16 + x) / 128, (chunk.z * 16 + z) / 128) * 100;
orgColY = colWaterY = colY = 60 + this.fastRound(( orgColY = colWaterY = colY = 60 + Math.round((
this.generator((chunk.x * 16 + x) / 16, (chunk.z * 16 + z) / 16) * 16 + this.generator((chunk.x * 16 + x) / 16, (chunk.z * 16 + z) / 16) * 16 +
this.generator1((chunk.z * 16 + z) / 16, (chunk.x * 16 + x) / 16) * 16 + this.generator1((chunk.z * 16 + z) / 16, (chunk.x * 16 + x) / 16) * 16 +
this.generator2((chunk.x * 16 + x) / 8, (chunk.z * 16 + z) / 8) * 8 + this.generator2((chunk.x * 16 + x) / 8, (chunk.z * 16 + z) / 8) * 8 +
@ -167,15 +162,15 @@ export class HillyGenerator implements IGenerator {
} }
if ( if (
sugarcaneRNG() > 0.992 &&
chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId && chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId &&
chunk.getBlockId(x, orgColY, z) === Block.sand.blockId && chunk.getBlockId(x, orgColY, z) === Block.grass.blockId &&
(((x - 1) < 0 ? false : chunk.getBlockId(x - 1, orgColY, z) === Block.waterStill.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) || ((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) < 0 ? false : chunk.getBlockId(x, orgColY, z - 1) === Block.waterStill.blockId) ||
((z + 1) > 15 ? 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); let sugarcaneYHeight = 2 + Math.round(sugarcaneRNG() * 2.5);
while (sugarcaneYHeight > 0) { while (sugarcaneYHeight > 0) {
chunk.setBlock(Block.sugarcane.blockId, x, orgColY + sugarcaneYHeight, z); chunk.setBlock(Block.sugarcane.blockId, x, orgColY + sugarcaneYHeight, z);
sugarcaneYHeight--; sugarcaneYHeight--;
@ -186,7 +181,7 @@ export class HillyGenerator implements IGenerator {
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) {
const treeType = treeRNG() >= 0.5; const treeType = treeRNG() >= 0.5;
chunk.setBlock(Block.dirt.blockId, x, orgColY, z); chunk.setBlock(Block.dirt.blockId, x, orgColY, z);
let tYT = 0, tY = tYT = orgColY + 4 + this.fastRound(treeRNG() - 0.2), tLY = 0; let tYT = 0, tY = tYT = orgColY + 4 + Math.round(treeRNG() - 0.2), tLY = 0;
while (tY > orgColY) { while (tY > orgColY) {
chunk.setBlockWithMetadata(Block.wood.blockId, treeType ? 2 : 0, x, tY, z); chunk.setBlockWithMetadata(Block.wood.blockId, treeType ? 2 : 0, x, tY, z);
if (tLY !== 0 && tLY < 3) { if (tLY !== 0 && tLY < 3) {