WorldGenSand .java

net.minecraft.world.gen.feature.WorldGenSand (class, 61 lines): extends WorldGenerator. members: radius, block, generate. imports: Block.

net.minecraft.world.gen.featureclass61 linescommonextends WorldGenerator1.8 KB

API Surface (1)

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

Fields & Constants (2)

block
radius

Code Graph: Dependencies (6)

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

Full Source

WorldGenSand.java61 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.init.Blocks;
7
import net.minecraft.util.BlockPos;
8
import net.minecraft.world.World;
9
10
public class WorldGenSand extends WorldGenerator
11
{
12
    private Block block;
13
14
    /** The maximum radius used when generating a patch of blocks. */
15
    private int radius;
16
17
    public WorldGenSand(Block p_i45462_1_, int p_i45462_2_)
18
    {
19
        this.block = p_i45462_1_;
20
        this.radius = p_i45462_2_;
21
    }
22
23
    public boolean generate(World worldIn, Random rand, BlockPos position)
24
    {
25
        if (worldIn.getBlockState(position).getBlock().getMaterial() != Material.water)
26
        {
27
            return false;
28
        }
29
        else
30
        {
31
            int i = rand.nextInt(this.radius - 2) + 2;
32
            int j = 2;
33
34
            for (int k = position.getX() - i; k <= position.getX() + i; ++k)
35
            {
36
                for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
37
                {
38
                    int i1 = k - position.getX();
39
                    int j1 = l - position.getZ();
40
41
                    if (i1 * i1 + j1 * j1 <= i * i)
42
                    {
43
                        for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
44
                        {
45
                            BlockPos blockpos = new BlockPos(k, k1, l);
46
                            Block block = worldIn.getBlockState(blockpos).getBlock();
47
48
                            if (block == Blocks.dirt || block == Blocks.grass)
49
                            {
50
                                worldIn.setBlockState(blockpos, this.block.getDefaultState(), 2);
51
                            }
52
                        }
53
                    }
54
                }
55
            }
56
57
            return true;
58
        }
59
    }
60
}
61

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