WorldGenTallGrass .java

net.minecraft.world.gen.feature.WorldGenTallGrass (class, 43 lines): members: tallGrassState, generate. imports: BlockTallGrass, Block, Material.

net.minecraft.world.gen.featureclass43 linescommonextends WorldGenerator1.4 KB

API Surface (1)

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

Fields & Constants (1)

tallGrassState

Code Graph: Dependencies (8)

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

Full Source

WorldGenTallGrass.java43 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.BlockTallGrass;
6
import net.minecraft.block.material.Material;
7
import net.minecraft.block.state.IBlockState;
8
import net.minecraft.init.Blocks;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.world.World;
11
12
public class WorldGenTallGrass extends WorldGenerator
13
{
14
    private final IBlockState tallGrassState;
15
16
    public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_)
17
    {
18
        this.tallGrassState = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, p_i45629_1_);
19
    }
20
21
    public boolean generate(World worldIn, Random rand, BlockPos position)
22
    {
23
        Block block;
24
25
        while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
26
        {
27
            position = position.down();
28
        }
29
30
        for (int i = 0; i < 128; ++i)
31
        {
32
            BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
33
34
            if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
35
            {
36
                worldIn.setBlockState(blockpos, this.tallGrassState, 2);
37
            }
38
        }
39
40
        return true;
41
    }
42
}
43

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