net.minecraft.world.gen.ChunkGeneratorDebug(调试模式地图生成器)

net.minecraft.world.gen.ChunkGeneratorDebug
的“数据”成员:

private static final List ALL_VALID_STATES = Lists.newArrayList();//用来保存所有的有效状态
    private static final int GRID_WIDTH;
    private static final int GRID_HEIGHT;
    protected static final IBlockState AIR = Blocks.AIR.getDefaultState();
    protected static final IBlockState BARRIER = Blocks.BARRIER.getDefaultState();//屏障方块
    private final World world;//保存当前世界

static 函数

static
    {
        for (Block block : Block.REGISTRY)
        {
            ALL_VALID_STATES.addAll(block.getBlockState().getValidStates());//把所有方块及物体都增加到ALL_VALID_STATES中。
        }

        GRID_WIDTH = MathHelper.ceil(MathHelper.sqrt((float)ALL_VALID_STATES.size()));
        GRID_HEIGHT = MathHelper.ceil((float)ALL_VALID_STATES.size() / (float)GRID_WIDTH);
    }
    public static IBlockState getBlockStateFor(int k, int l)//通过位置坐标设置IBlockState是那个方块
    {
        IBlockState iblockstate = AIR;

        if (k > 0 && l > 0 && k % 2 != 0 && l % 2 != 0)
        {
            k = k / 2;
            l = l / 2;

            if (k <= GRID_WIDTH && l <= GRID_HEIGHT)
            {
                int i = MathHelper.abs(k * GRID_WIDTH + l);

                if (i < ALL_VALID_STATES.size())
                {
                    iblockstate = ALL_VALID_STATES.get(i);
                }
            }
        }

        return iblockstate;
    }

 generateStructures(.........)是否有结构生成?返回:没有。
 public List getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos)得到可能的生物
public void populate(int x, int z)填充地图(例子:生成海洋)(实际上根本就没有运行这个函数)
public void recreateStructures(Chunk chunkIn, int x, int z)重建结构
public Chunk provideChunk(int x, int z)
    {
        ChunkPrimer chunkprimer = new ChunkPrimer();
        
        for (int i = 0; i < this.cachedBlockIDs.length; ++i)
        {
            IBlockState iblockstate = this.cachedBlockIDs[i];

            if (iblockstate != null)
            {
                for (int j = 0; j < 16; ++j)
                {
                    for (int k = 0; k < 16; ++k)
                    {
                        chunkprimer.setBlockState(j, i, k, iblockstate);
                    }
                }
            }
        }
//设置所有方块的位置。如果超平坦模式的相关的类也有这个上面的内容就会在相应的位置上生成与调试模式一样的内容。
        for (MapGenBase mapgenbase : this.structureGenerators.values())
        {
            mapgenbase.generate(this.worldObj, x, z, chunkprimer);
        }

        Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z);
        Biome[] abiome = this.worldObj.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16);
        byte[] abyte = chunk.getBiomeArray();

        for (int l = 0; l < abyte.length; ++l)
        {
            abyte[l] = (byte)Biome.getIdForBiome(abiome[l]);
        }

        chunk.generateSkylightMap();
        return chunk;
    }

你可能感兴趣的:(我的世界1.12源代码分析)