WorldGenShrub .java

net.minecraft.world.gen.feature.WorldGenShrub (class, 69 lines): extends WorldGenTrees. members: leavesMetadata, woodMetadata, generate. imports: Block.

net.minecraft.world.gen.featureclass69 linescommonextends WorldGenTrees2.2 KB

API Surface (1)

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

Fields & Constants (2)

leavesMetadata
woodMetadata

Code Graph: Dependencies (7)

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

Full Source

WorldGenShrub.java69 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.feature;
2
3
import java.util.Random;
4
import net.minecraft.block.Block;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.state.IBlockState;
7
import net.minecraft.init.Blocks;
8
import net.minecraft.util.BlockPos;
9
import net.minecraft.world.World;
10
11
public class WorldGenShrub extends WorldGenTrees
12
{
13
    private final IBlockState leavesMetadata;
14
    private final IBlockState woodMetadata;
15
16
    public WorldGenShrub(IBlockState p_i46450_1_, IBlockState p_i46450_2_)
17
    {
18
        super(false);
19
        this.woodMetadata = p_i46450_1_;
20
        this.leavesMetadata = p_i46450_2_;
21
    }
22
23
    public boolean generate(World worldIn, Random rand, BlockPos position)
24
    {
25
        Block block;
26
27
        while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
28
        {
29
            position = position.down();
30
        }
31
32
        Block block1 = worldIn.getBlockState(position).getBlock();
33
34
        if (block1 == Blocks.dirt || block1 == Blocks.grass)
35
        {
36
            position = position.up();
37
            this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);
38
39
            for (int i = position.getY(); i <= position.getY() + 2; ++i)
40
            {
41
                int j = i - position.getY();
42
                int k = 2 - j;
43
44
                for (int l = position.getX() - k; l <= position.getX() + k; ++l)
45
                {
46
                    int i1 = l - position.getX();
47
48
                    for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
49
                    {
50
                        int k1 = j1 - position.getZ();
51
52
                        if (Math.abs(i1) != k || Math.abs(k1) != k || rand.nextInt(2) != 0)
53
                        {
54
                            BlockPos blockpos = new BlockPos(l, i, j1);
55
56
                            if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock())
57
                            {
58
                                this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
59
                            }
60
                        }
61
                    }
62
                }
63
            }
64
        }
65
66
        return true;
67
    }
68
}
69

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