Skip to content

Commit db98476

Browse files
committedOct 17, 2024··
generate sugar cane on grass instead, forgot this only became a thing in beta 1.8+
1 parent 19453b7 commit db98476

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed
 

‎server/generators/Hilly.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ export class HillyGenerator implements IGenerator {
6363
return makeNoise3D(this.seedGenerator() * Number.MAX_SAFE_INTEGER);
6464
}
6565

66-
// This is soooo much faster than using Math.round in here
67-
private fastRound(num:number) {
68-
return num >= 0.5 ? (num | 0) + 1 : num | 0;
69-
}
70-
7166
public generate(chunk:Chunk) {
7267
const treeRNG = mulberry32(this.seed + chunk.x + chunk.z);
7368
const sugarcaneRNG = mulberry32(this.seed + chunk.x + chunk.z);
@@ -78,7 +73,7 @@ export class HillyGenerator implements IGenerator {
7873
for (let x = 0; x < 16; x++) {
7974
for (let z = 0; z < 16; z++) {
8075
const oceanValue = this.oceanGenerator((chunk.x * 16 + x) / 128, (chunk.z * 16 + z) / 128) * 100;
81-
orgColY = colWaterY = colY = 60 + this.fastRound((
76+
orgColY = colWaterY = colY = 60 + Math.round((
8277
this.generator((chunk.x * 16 + x) / 16, (chunk.z * 16 + z) / 16) * 16 +
8378
this.generator1((chunk.z * 16 + z) / 16, (chunk.x * 16 + x) / 16) * 16 +
8479
this.generator2((chunk.x * 16 + x) / 8, (chunk.z * 16 + z) / 8) * 8 +
@@ -167,15 +162,15 @@ export class HillyGenerator implements IGenerator {
167162
}
168163

169164
if (
165+
sugarcaneRNG() > 0.992 &&
170166
chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId &&
171-
chunk.getBlockId(x, orgColY, z) === Block.sand.blockId &&
167+
chunk.getBlockId(x, orgColY, z) === Block.grass.blockId &&
172168
(((x - 1) < 0 ? false : chunk.getBlockId(x - 1, orgColY, z) === Block.waterStill.blockId) ||
173169
((x + 1) > 15 ? false : chunk.getBlockId(x + 1, orgColY, z) === Block.waterStill.blockId) ||
174170
((z - 1) < 0 ? false : chunk.getBlockId(x, orgColY, z - 1) === Block.waterStill.blockId) ||
175-
((z + 1) > 15 ? false : chunk.getBlockId(x, orgColY, z + 1) === Block.waterStill.blockId)) &&
176-
sugarcaneRNG() > 0.695
171+
((z + 1) > 15 ? false : chunk.getBlockId(x, orgColY, z + 1) === Block.waterStill.blockId))
177172
) {
178-
let sugarcaneYHeight = 1 + Math.floor(sugarcaneRNG() * 2.9);
173+
let sugarcaneYHeight = 2 + Math.round(sugarcaneRNG() * 2.5);
179174
while (sugarcaneYHeight > 0) {
180175
chunk.setBlock(Block.sugarcane.blockId, x, orgColY + sugarcaneYHeight, z);
181176
sugarcaneYHeight--;
@@ -186,7 +181,7 @@ export class HillyGenerator implements IGenerator {
186181
if (chunk.getBlockId(x, orgColY + 1, z) !== Block.waterStill.blockId && chunk.getBlockId(x, orgColY, z) === Block.grass.blockId && treeRNG() > 0.995) {
187182
const treeType = treeRNG() >= 0.5;
188183
chunk.setBlock(Block.dirt.blockId, x, orgColY, z);
189-
let tYT = 0, tY = tYT = orgColY + 4 + this.fastRound(treeRNG() - 0.2), tLY = 0;
184+
let tYT = 0, tY = tYT = orgColY + 4 + Math.round(treeRNG() - 0.2), tLY = 0;
190185
while (tY > orgColY) {
191186
chunk.setBlockWithMetadata(Block.wood.blockId, treeType ? 2 : 0, x, tY, z);
192187
if (tLY !== 0 && tLY < 3) {

0 commit comments

Comments
 (0)
Please sign in to comment.