/
CloudGen.java
52 lines (46 loc) · 1.69 KB
/
CloudGen.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mods.natura.worldgen;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
public class CloudGen extends WorldGenerator
{
private int bID;
private int meta;
private int numberOfBlocks;
private boolean flatCloud;
public CloudGen(int blockID, int metadata, int size, boolean flag)
{
bID = blockID;
meta = metadata;
numberOfBlocks = size;
flatCloud = flag;
}
public boolean generate (World world, Random random, int x, int y, int z)
{
int l = random.nextInt(3) - 1;
int i1 = random.nextInt(3) - 1;
for (int j1 = 0; j1 < numberOfBlocks; j1++)
{
x += (random.nextInt(3) - 1) + l;
z += (random.nextInt(3) - 1) + i1;
if (random.nextBoolean() && !flatCloud || flatCloud && random.nextInt(10) == 0)
{
y += random.nextInt(3) - 1;
}
for (int xIter = x; xIter < x + random.nextInt(4) + 3 * (flatCloud ? 3 : 1); xIter++)
{
for (int yIter = y; yIter < y + random.nextInt(1) + 2; yIter++)
{
for (int zIter = z; zIter < z + random.nextInt(4) + 3 * (flatCloud ? 3 : 1); zIter++)
{
if (world.getBlockId(xIter, yIter, zIter) == 0 && Math.abs(xIter - x) + Math.abs(yIter - y) + Math.abs(zIter - z) < 4 * (flatCloud ? 3 : 1) + random.nextInt(2))
{
setBlockAndMetadata(world, xIter, yIter, zIter, bID, meta);
}
}
}
}
}
return true;
}
}