Пример #1
0
    public override void Build(World world, BlockPos chunkPos, BlockPos pos, TerrainLayer layer)
    {
        int leaves = layer.GetNoise(pos.x, 0, pos.z, 1f, 2, 1) +1;

        for (int x = -leaves; x <= leaves; x++)
        {
            for (int y = 3; y <= 6; y++)
            {
                for (int z = -leaves; z <= leaves; z++)
                {
                    if (Chunk.InRange(pos.x + x - chunkPos.x) && Chunk.InRange(pos.z + z - chunkPos.z))
                    {
                        Block block = "leaves";
                        block.modified = false;
                        world.SetBlock(pos.Add(x, y, z), block, false);
                    }
                }
            }
        }
        for (int y = 0; y <= 5; y++)
        {
            if (y < Config.Env.WorldMaxY)
            {
                Block block = "log";
                block.modified = false;
                world.SetBlock(pos.Add(0, y, 0), block, false);
            }
        }
    }
Пример #2
0
    public override void Build(World world, Chunk chunk, Vector3Int pos, TerrainLayer layer)
    {
        int noise        = layer.GetNoise(pos.x, pos.y, pos.z, 1f, 3, 1);
        int leavesRange  = noise + 3;
        int leavesRange2 = leavesRange * leavesRange;
        int trunkHeight  = posY - noise;

        float a2inv = 1.0f / leavesRange2;
        float b2inv = 1.0f / ((leavesRange - 1) * (leavesRange - 1));

        for (int y = -leavesRange + 1; y <= leavesRange - 1; y++)
        {
            for (int z = -leavesRange; z <= leavesRange; z++)
            {
                for (int x = -leavesRange; x <= leavesRange; x++)
                {
                    if (x * x * a2inv + z * z * a2inv + y * y * b2inv <= 1.0f) // An ellipsoid flattened on the y axis
                    {
                        blocks.Set(pos.Add(x, y + trunkHeight, z), leaves);
                    }
                }
            }
        }

        blocks.Set(pos, log);
        for (int y = 1; y <= trunkHeight; y++)
        {
            blocks.Set(pos.Add(0, y, 0), log);
        }
    }
Пример #3
0
    public override void Build(World world, BlockPos chunkPos, BlockPos pos, TerrainLayer layer)
    {
        int leaves = layer.GetNoise(pos.x, 0, pos.z, 1f, 2, 1) + 1;

        for (int x = -leaves; x <= leaves; x++)
        {
            for (int y = 3; y <= 6; y++)
            {
                for (int z = -leaves; z <= leaves; z++)
                {
                    if (Chunk.InRange(pos.x + x - chunkPos.x) && Chunk.InRange(pos.z + z - chunkPos.z))
                    {
                        Block block = "leaves";
                        block.modified = false;
                        world.SetBlock(pos.Add(x, y, z), block, false);
                    }
                }
            }
        }
        for (int y = 0; y <= 5; y++)
        {
            if (y < Config.Env.WorldMaxY)
            {
                Block block = "log";
                block.modified = false;
                world.SetBlock(pos.Add(0, y, 0), block, false);
            }
        }
    }