ChunkPrimer .java

net.minecraft.world.chunk.ChunkPrimer (class, 49 lines): members: defaultState, setBlockState, getBlockState, data. imports: Block.

net.minecraft.world.chunkclass49 linescommon1.3 KB

API Surface (4)

IBlockState getBlockState(int x, int y, int z)
IBlockState getBlockState(int index)
void setBlockState(int x, int y, int z, IBlockState state)
void setBlockState(int index, IBlockState state)

Fields & Constants (2)

data
defaultState

String literals (1)

"The coordinate is out of range"

Code Graph: Dependencies (3)

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

Full Source

ChunkPrimer.java49 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.chunk;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.state.IBlockState;
5
import net.minecraft.init.Blocks;
6
7
public class ChunkPrimer
8
{
9
    private final short[] data = new short[65536];
10
    private final IBlockState defaultState = Blocks.air.getDefaultState();
11
12
    public IBlockState getBlockState(int x, int y, int z)
13
    {
14
        int i = x << 12 | z << 8 | y;
15
        return this.getBlockState(i);
16
    }
17
18
    public IBlockState getBlockState(int index)
19
    {
20
        if (index >= 0 && index < this.data.length)
21
        {
22
            IBlockState iblockstate = (IBlockState)Block.BLOCK_STATE_IDS.getByValue(this.data[index]);
23
            return iblockstate != null ? iblockstate : this.defaultState;
24
        }
25
        else
26
        {
27
            throw new IndexOutOfBoundsException("The coordinate is out of range");
28
        }
29
    }
30
31
    public void setBlockState(int x, int y, int z, IBlockState state)
32
    {
33
        int i = x << 12 | z << 8 | y;
34
        this.setBlockState(i, state);
35
    }
36
37
    public void setBlockState(int index, IBlockState state)
38
    {
39
        if (index >= 0 && index < this.data.length)
40
        {
41
            this.data[index] = (short)Block.BLOCK_STATE_IDS.get(state);
42
        }
43
        else
44
        {
45
            throw new IndexOutOfBoundsException("The coordinate is out of range");
46
        }
47
    }
48
}
49

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