ChunkProviderDebug .java

net.minecraft.world.gen.ChunkProviderDebug (class, 188 lines): members: field_177462_b, field_177464_a, field_181039_c, func_177461_b, world, provideChunk.

net.minecraft.world.genclass188 linescommon5.3 KB

Implements

API Surface (15)

Chunk provideChunk(int x, int z)
IBlockState func_177461_b(int p_177461_0_, int p_177461_1_)
boolean chunkExists(int x, int z)
void populate(IChunkProvider chunkProvider, int x, int z)
boolean populateChunk(IChunkProvider chunkProvider, Chunk chunkIn, int x, int z)
boolean saveChunks(boolean saveAllChunks, IProgressUpdate progressCallback)
void saveExtraData()
boolean unloadQueuedChunks()
boolean canSave()
String makeString()
List<BiomeGenBase.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos)
BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position)
int getLoadedChunkCount()
void recreateStructures(Chunk chunkIn, int x, int z)
Chunk provideChunk(BlockPos blockPosIn)

Fields & Constants (4)

field_177464_a
field_177462_b
field_181039_c
world

String literals (1)

"DebugLevelSource"

Full Source

ChunkProviderDebug.java188 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.world.gen;
2
3
import com.google.common.collect.Lists;
4
import java.util.List;
5
import net.minecraft.block.Block;
6
import net.minecraft.block.state.IBlockState;
7
import net.minecraft.entity.EnumCreatureType;
8
import net.minecraft.init.Blocks;
9
import net.minecraft.util.BlockPos;
10
import net.minecraft.util.IProgressUpdate;
11
import net.minecraft.util.MathHelper;
12
import net.minecraft.world.World;
13
import net.minecraft.world.biome.BiomeGenBase;
14
import net.minecraft.world.chunk.Chunk;
15
import net.minecraft.world.chunk.ChunkPrimer;
16
import net.minecraft.world.chunk.IChunkProvider;
17
18
public class ChunkProviderDebug implements IChunkProvider
19
{
20
    private static final List<IBlockState> field_177464_a = Lists.<IBlockState>newArrayList();
21
    private static final int field_177462_b;
22
    private static final int field_181039_c;
23
    private final World world;
24
25
    public ChunkProviderDebug(World worldIn)
26
    {
27
        this.world = worldIn;
28
    }
29
30
    /**
31
     * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
32
     * specified chunk from the map seed and chunk seed
33
     */
34
    public Chunk provideChunk(int x, int z)
35
    {
36
        ChunkPrimer chunkprimer = new ChunkPrimer();
37
38
        for (int i = 0; i < 16; ++i)
39
        {
40
            for (int j = 0; j < 16; ++j)
41
            {
42
                int k = x * 16 + i;
43
                int l = z * 16 + j;
44
                chunkprimer.setBlockState(i, 60, j, Blocks.barrier.getDefaultState());
45
                IBlockState iblockstate = func_177461_b(k, l);
46
47
                if (iblockstate != null)
48
                {
49
                    chunkprimer.setBlockState(i, 70, j, iblockstate);
50
                }
51
            }
52
        }
53
54
        Chunk chunk = new Chunk(this.world, chunkprimer, x, z);
55
        chunk.generateSkylightMap();
56
        BiomeGenBase[] abiomegenbase = this.world.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[])null, x * 16, z * 16, 16, 16);
57
        byte[] abyte = chunk.getBiomeArray();
58
59
        for (int i1 = 0; i1 < abyte.length; ++i1)
60
        {
61
            abyte[i1] = (byte)abiomegenbase[i1].biomeID;
62
        }
63
64
        chunk.generateSkylightMap();
65
        return chunk;
66
    }
67
68
    public static IBlockState func_177461_b(int p_177461_0_, int p_177461_1_)
69
    {
70
        IBlockState iblockstate = null;
71
72
        if (p_177461_0_ > 0 && p_177461_1_ > 0 && p_177461_0_ % 2 != 0 && p_177461_1_ % 2 != 0)
73
        {
74
            p_177461_0_ = p_177461_0_ / 2;
75
            p_177461_1_ = p_177461_1_ / 2;
76
77
            if (p_177461_0_ <= field_177462_b && p_177461_1_ <= field_181039_c)
78
            {
79
                int i = MathHelper.abs_int(p_177461_0_ * field_177462_b + p_177461_1_);
80
81
                if (i < field_177464_a.size())
82
                {
83
                    iblockstate = (IBlockState)field_177464_a.get(i);
84
                }
85
            }
86
        }
87
88
        return iblockstate;
89
    }
90
91
    /**
92
     * Checks to see if a chunk exists at x, z
93
     */
94
    public boolean chunkExists(int x, int z)
95
    {
96
        return true;
97
    }
98
99
    /**
100
     * Populates chunk with ores etc etc
101
     */
102
    public void populate(IChunkProvider chunkProvider, int x, int z)
103
    {
104
    }
105
106
    public boolean populateChunk(IChunkProvider chunkProvider, Chunk chunkIn, int x, int z)
107
    {
108
        return false;
109
    }
110
111
    /**
112
     * Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.
113
     * Return true if all chunks have been saved.
114
     */
115
    public boolean saveChunks(boolean saveAllChunks, IProgressUpdate progressCallback)
116
    {
117
        return true;
118
    }
119
120
    /**
121
     * Save extra data not associated with any Chunk.  Not saved during autosave, only during world unload.  Currently
122
     * unimplemented.
123
     */
124
    public void saveExtraData()
125
    {
126
    }
127
128
    /**
129
     * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.
130
     */
131
    public boolean unloadQueuedChunks()
132
    {
133
        return false;
134
    }
135
136
    /**
137
     * Returns if the IChunkProvider supports saving.
138
     */
139
    public boolean canSave()
140
    {
141
        return true;
142
    }
143
144
    /**
145
     * Converts the instance data to a readable string.
146
     */
147
    public String makeString()
148
    {
149
        return "DebugLevelSource";
150
    }
151
152
    public List<BiomeGenBase.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos)
153
    {
154
        BiomeGenBase biomegenbase = this.world.getBiomeGenForCoords(pos);
155
        return biomegenbase.getSpawnableList(creatureType);
156
    }
157
158
    public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position)
159
    {
160
        return null;
161
    }
162
163
    public int getLoadedChunkCount()
164
    {
165
        return 0;
166
    }
167
168
    public void recreateStructures(Chunk chunkIn, int x, int z)
169
    {
170
    }
171
172
    public Chunk provideChunk(BlockPos blockPosIn)
173
    {
174
        return this.provideChunk(blockPosIn.getX() >> 4, blockPosIn.getZ() >> 4);
175
    }
176
177
    static
178
    {
179
        for (Block block : Block.blockRegistry)
180
        {
181
            field_177464_a.addAll(block.getBlockState().getValidStates());
182
        }
183
184
        field_177462_b = MathHelper.ceiling_float_int(MathHelper.sqrt_float((float)field_177464_a.size()));
185
        field_181039_c = MathHelper.ceiling_float_int((float)field_177464_a.size() / (float)field_177462_b);
186
    }
187
}
188

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