WorldGenIceSpike .java

net.minecraft.world.gen.feature.WorldGenIceSpike (class, 120 lines): extends WorldGenerator. members: generate. imports: Block.

net.minecraft.world.gen.featureclass120 linescommonextends WorldGenerator4.1 KB

API Surface (1)

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

Code Graph: Dependencies (7)

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

Full Source

WorldGenIceSpike.java120 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.util.MathHelper;
9
import net.minecraft.world.World;
10
11
public class WorldGenIceSpike extends WorldGenerator
12
{
13
    public boolean generate(World worldIn, Random rand, BlockPos position)
14
    {
15
        while (worldIn.isAirBlock(position) && position.getY() > 2)
16
        {
17
            position = position.down();
18
        }
19
20
        if (worldIn.getBlockState(position).getBlock() != Blocks.snow)
21
        {
22
            return false;
23
        }
24
        else
25
        {
26
            position = position.up(rand.nextInt(4));
27
            int i = rand.nextInt(4) + 7;
28
            int j = i / 4 + rand.nextInt(2);
29
30
            if (j > 1 && rand.nextInt(60) == 0)
31
            {
32
                position = position.up(10 + rand.nextInt(30));
33
            }
34
35
            for (int k = 0; k < i; ++k)
36
            {
37
                float f = (1.0F - (float)k / (float)i) * (float)j;
38
                int l = MathHelper.ceiling_float_int(f);
39
40
                for (int i1 = -l; i1 <= l; ++i1)
41
                {
42
                    float f1 = (float)MathHelper.abs_int(i1) - 0.25F;
43
44
                    for (int j1 = -l; j1 <= l; ++j1)
45
                    {
46
                        float f2 = (float)MathHelper.abs_int(j1) - 0.25F;
47
48
                        if ((i1 == 0 && j1 == 0 || f1 * f1 + f2 * f2 <= f * f) && (i1 != -l && i1 != l && j1 != -l && j1 != l || rand.nextFloat() <= 0.75F))
49
                        {
50
                            Block block = worldIn.getBlockState(position.add(i1, k, j1)).getBlock();
51
52
                            if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
53
                            {
54
                                this.setBlockAndNotifyAdequately(worldIn, position.add(i1, k, j1), Blocks.packed_ice.getDefaultState());
55
                            }
56
57
                            if (k != 0 && l > 1)
58
                            {
59
                                block = worldIn.getBlockState(position.add(i1, -k, j1)).getBlock();
60
61
                                if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
62
                                {
63
                                    this.setBlockAndNotifyAdequately(worldIn, position.add(i1, -k, j1), Blocks.packed_ice.getDefaultState());
64
                                }
65
                            }
66
                        }
67
                    }
68
                }
69
            }
70
71
            int k1 = j - 1;
72
73
            if (k1 < 0)
74
            {
75
                k1 = 0;
76
            }
77
            else if (k1 > 1)
78
            {
79
                k1 = 1;
80
            }
81
82
            for (int l1 = -k1; l1 <= k1; ++l1)
83
            {
84
                for (int i2 = -k1; i2 <= k1; ++i2)
85
                {
86
                    BlockPos blockpos = position.add(l1, -1, i2);
87
                    int j2 = 50;
88
89
                    if (Math.abs(l1) == 1 && Math.abs(i2) == 1)
90
                    {
91
                        j2 = rand.nextInt(5);
92
                    }
93
94
                    while (blockpos.getY() > 50)
95
                    {
96
                        Block block1 = worldIn.getBlockState(blockpos).getBlock();
97
98
                        if (block1.getMaterial() != Material.air && block1 != Blocks.dirt && block1 != Blocks.snow && block1 != Blocks.ice && block1 != Blocks.packed_ice)
99
                        {
100
                            break;
101
                        }
102
103
                        this.setBlockAndNotifyAdequately(worldIn, blockpos, Blocks.packed_ice.getDefaultState());
104
                        blockpos = blockpos.down();
105
                        --j2;
106
107
                        if (j2 <= 0)
108
                        {
109
                            blockpos = blockpos.down(rand.nextInt(5) + 1);
110
                            j2 = rand.nextInt(5);
111
                        }
112
                    }
113
                }
114
            }
115
116
            return true;
117
        }
118
    }
119
}
120

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