WorldGenCactus .java

net.minecraft.world.gen.feature.WorldGenCactus (class, 33 lines): extends WorldGenerator. members: generate. imports: Blocks.

net.minecraft.world.gen.featureclass33 linescommonextends WorldGenerator977 B

API Surface (1)

boolean generate(World worldIn, Random rand, BlockPos position)

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

WorldGenCactus.java33 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.feature;
2
3
import java.util.Random;
4
import net.minecraft.init.Blocks;
5
import net.minecraft.util.BlockPos;
6
import net.minecraft.world.World;
7
8
public class WorldGenCactus extends WorldGenerator
9
{
10
    public boolean generate(World worldIn, Random rand, BlockPos position)
11
    {
12
        for (int i = 0; i < 10; ++i)
13
        {
14
            BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
15
16
            if (worldIn.isAirBlock(blockpos))
17
            {
18
                int j = 1 + rand.nextInt(rand.nextInt(3) + 1);
19
20
                for (int k = 0; k < j; ++k)
21
                {
22
                    if (Blocks.cactus.canBlockStay(worldIn, blockpos))
23
                    {
24
                        worldIn.setBlockState(blockpos.up(k), Blocks.cactus.getDefaultState(), 2);
25
                    }
26
                }
27
            }
28
        }
29
30
        return true;
31
    }
32
}
33

Deobfuscated MCP 1.8.9 source of WorldGenCactus from Marcelektro/MavenMCP-1.8.9 (net/minecraft/world/gen/feature/WorldGenCactus.java), stored verbatim.