WorldGenSpikes .java

net.minecraft.world.gen.feature.WorldGenSpikes (class, 71 lines): members: baseBlockRequired, generate. imports: EntityEnderCrystal, Block, Entity.

net.minecraft.world.gen.featureclass71 linescommonextends WorldGenerator2.6 KB

API Surface (1)

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

Fields & Constants (1)

baseBlockRequired

Code Graph: Dependencies (7)

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

Full Source

WorldGenSpikes.java71 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.entity.Entity;
6
import net.minecraft.entity.item.EntityEnderCrystal;
7
import net.minecraft.init.Blocks;
8
import net.minecraft.util.BlockPos;
9
import net.minecraft.world.World;
10
11
public class WorldGenSpikes extends WorldGenerator
12
{
13
    private Block baseBlockRequired;
14
15
    public WorldGenSpikes(Block p_i45464_1_)
16
    {
17
        this.baseBlockRequired = p_i45464_1_;
18
    }
19
20
    public boolean generate(World worldIn, Random rand, BlockPos position)
21
    {
22
        if (worldIn.isAirBlock(position) && worldIn.getBlockState(position.down()).getBlock() == this.baseBlockRequired)
23
        {
24
            int i = rand.nextInt(32) + 6;
25
            int j = rand.nextInt(4) + 1;
26
            BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
27
28
            for (int k = position.getX() - j; k <= position.getX() + j; ++k)
29
            {
30
                for (int l = position.getZ() - j; l <= position.getZ() + j; ++l)
31
                {
32
                    int i1 = k - position.getX();
33
                    int j1 = l - position.getZ();
34
35
                    if (i1 * i1 + j1 * j1 <= j * j + 1 && worldIn.getBlockState(blockpos$mutableblockpos.set(k, position.getY() - 1, l)).getBlock() != this.baseBlockRequired)
36
                    {
37
                        return false;
38
                    }
39
                }
40
            }
41
42
            for (int l1 = position.getY(); l1 < position.getY() + i && l1 < 256; ++l1)
43
            {
44
                for (int i2 = position.getX() - j; i2 <= position.getX() + j; ++i2)
45
                {
46
                    for (int j2 = position.getZ() - j; j2 <= position.getZ() + j; ++j2)
47
                    {
48
                        int k2 = i2 - position.getX();
49
                        int k1 = j2 - position.getZ();
50
51
                        if (k2 * k2 + k1 * k1 <= j * j + 1)
52
                        {
53
                            worldIn.setBlockState(new BlockPos(i2, l1, j2), Blocks.obsidian.getDefaultState(), 2);
54
                        }
55
                    }
56
                }
57
            }
58
59
            Entity entity = new EntityEnderCrystal(worldIn);
60
            entity.setLocationAndAngles((double)((float)position.getX() + 0.5F), (double)(position.getY() + i), (double)((float)position.getZ() + 0.5F), rand.nextFloat() * 360.0F, 0.0F);
61
            worldIn.spawnEntityInWorld(entity);
62
            worldIn.setBlockState(position.up(i), Blocks.bedrock.getDefaultState(), 2);
63
            return true;
64
        }
65
        else
66
        {
67
            return false;
68
        }
69
    }
70
}
71

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