WorldGenMinable .java

net.minecraft.world.gen.feature.WorldGenMinable (class, 93 lines): members: oreBlock, numberOfBlocks, predicate, generate. imports: BlockHelper, Predicate.

net.minecraft.world.gen.featureclass93 linescommonextends WorldGenerator3.8 KB

API Surface (1)

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

Fields & Constants (3)

oreBlock
numberOfBlocks
predicate

Code Graph: Dependencies (7)

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

Full Source

WorldGenMinable.java93 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen.feature;
2
3
import com.google.common.base.Predicate;
4
import java.util.Random;
5
import net.minecraft.block.state.IBlockState;
6
import net.minecraft.block.state.pattern.BlockHelper;
7
import net.minecraft.init.Blocks;
8
import net.minecraft.util.BlockPos;
9
import net.minecraft.util.MathHelper;
10
import net.minecraft.world.World;
11
12
public class WorldGenMinable extends WorldGenerator
13
{
14
    private final IBlockState oreBlock;
15
16
    /** The number of blocks to generate. */
17
    private final int numberOfBlocks;
18
    private final Predicate<IBlockState> predicate;
19
20
    public WorldGenMinable(IBlockState state, int blockCount)
21
    {
22
        this(state, blockCount, BlockHelper.forBlock(Blocks.stone));
23
    }
24
25
    public WorldGenMinable(IBlockState state, int blockCount, Predicate<IBlockState> p_i45631_3_)
26
    {
27
        this.oreBlock = state;
28
        this.numberOfBlocks = blockCount;
29
        this.predicate = p_i45631_3_;
30
    }
31
32
    public boolean generate(World worldIn, Random rand, BlockPos position)
33
    {
34
        float f = rand.nextFloat() * (float)Math.PI;
35
        double d0 = (double)((float)(position.getX() + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
36
        double d1 = (double)((float)(position.getX() + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
37
        double d2 = (double)((float)(position.getZ() + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
38
        double d3 = (double)((float)(position.getZ() + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
39
        double d4 = (double)(position.getY() + rand.nextInt(3) - 2);
40
        double d5 = (double)(position.getY() + rand.nextInt(3) - 2);
41
42
        for (int i = 0; i < this.numberOfBlocks; ++i)
43
        {
44
            float f1 = (float)i / (float)this.numberOfBlocks;
45
            double d6 = d0 + (d1 - d0) * (double)f1;
46
            double d7 = d4 + (d5 - d4) * (double)f1;
47
            double d8 = d2 + (d3 - d2) * (double)f1;
48
            double d9 = rand.nextDouble() * (double)this.numberOfBlocks / 16.0D;
49
            double d10 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
50
            double d11 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
51
            int j = MathHelper.floor_double(d6 - d10 / 2.0D);
52
            int k = MathHelper.floor_double(d7 - d11 / 2.0D);
53
            int l = MathHelper.floor_double(d8 - d10 / 2.0D);
54
            int i1 = MathHelper.floor_double(d6 + d10 / 2.0D);
55
            int j1 = MathHelper.floor_double(d7 + d11 / 2.0D);
56
            int k1 = MathHelper.floor_double(d8 + d10 / 2.0D);
57
58
            for (int l1 = j; l1 <= i1; ++l1)
59
            {
60
                double d12 = ((double)l1 + 0.5D - d6) / (d10 / 2.0D);
61
62
                if (d12 * d12 < 1.0D)
63
                {
64
                    for (int i2 = k; i2 <= j1; ++i2)
65
                    {
66
                        double d13 = ((double)i2 + 0.5D - d7) / (d11 / 2.0D);
67
68
                        if (d12 * d12 + d13 * d13 < 1.0D)
69
                        {
70
                            for (int j2 = l; j2 <= k1; ++j2)
71
                            {
72
                                double d14 = ((double)j2 + 0.5D - d8) / (d10 / 2.0D);
73
74
                                if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D)
75
                                {
76
                                    BlockPos blockpos = new BlockPos(l1, i2, j2);
77
78
                                    if (this.predicate.apply(worldIn.getBlockState(blockpos)))
79
                                    {
80
                                        worldIn.setBlockState(blockpos, this.oreBlock, 2);
81
                                    }
82
                                }
83
                            }
84
                        }
85
                    }
86
                }
87
            }
88
        }
89
90
        return true;
91
    }
92
}
93

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