Beispiel #1
0
        private static void ProccesChunk(byte[] data, int x, short y, int z, byte sizex, byte sizey, byte sizez)
        {
            MapChunkReader r = new MapChunkReader(data);

            int ChunkPosX = x / MinecraftLevel.ChunkXSize;
            int ChunkPosY = y / MinecraftLevel.ChunkYSize;
            int ChunkPosZ = z / MinecraftLevel.ChunkZSize;

            int cx = (ChunkPosX * MinecraftLevel.ChunkXSize);
            int cy = (ChunkPosY * MinecraftLevel.ChunkYSize);
            int cz = (ChunkPosZ * MinecraftLevel.ChunkZSize);

            MinecraftLevel.Chunk c;
            Cubia.Point <int>    p = new Cubia.Point <int>(ChunkPosX, ChunkPosZ);
            if (!SMPInterface.Chunks.TryGetValue(p, out c))
            {
                c = MinecraftLevel.Chunk.EmptyChunk();
                SMPInterface.Chunks.Add(p, c);
            }
            MinecraftLevel.Chunk ct;
            if (!SMPInterface.TransChunks.TryGetValue(p, out ct))
            {
                ct       = MinecraftLevel.Chunk.EmptyChunk();
                ct.Trans = true;
                SMPInterface.TransChunks.Add(p, ct);
            }

            for (int ix = x; ix < x + sizex + 1; ix++)
            {
                for (int iz = z; iz < z + sizez + 1; iz++)
                {
                    for (int iy = y; iy < y + sizey + 1; iy++)
                    {
                        int rx = mod((ix - cx), MinecraftLevel.ChunkXSize); // fixes the negatives
                        int ry = mod((iy - cy), MinecraftLevel.ChunkYSize);
                        int rz = mod((iz - cz), MinecraftLevel.ChunkZSize);

                        Cubia.Vector <int> vec = new Cubia.Vector <int>(rx, ry, rz);
                        byte           bType   = (byte)r.Read(8);// 8 bits in byte
                        MinecraftBlock block   = new MinecraftBlock()
                        {
                            BlockLight = 0,
                            SkyLight   = 0,
                            Type       = bType
                        };
                        if (GCScheme.IsTrans(bType))
                        {
                            ct.UpdateBlock(vec, block);
                        }
                        else
                        {
                            c.UpdateBlock(vec, block);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private static void ProccesChunk(byte[] data, int x, short y, int z, byte sizex, byte sizey, byte sizez)
        {
            MapChunkReader r = new MapChunkReader(data);

            int ChunkPosX = x / MinecraftLevel.ChunkXSize;
            int ChunkPosY = y / MinecraftLevel.ChunkYSize;
            int ChunkPosZ = z / MinecraftLevel.ChunkZSize;

            int cx = (ChunkPosX * MinecraftLevel.ChunkXSize);
            int cy = (ChunkPosY * MinecraftLevel.ChunkYSize);
            int cz = (ChunkPosZ * MinecraftLevel.ChunkZSize);

            MinecraftLevel.Chunk c;
            Cubia.Point<int> p = new Cubia.Point<int>(ChunkPosX, ChunkPosZ);
            if (!SMPInterface.Chunks.TryGetValue(p, out c))
            {
                c = MinecraftLevel.Chunk.EmptyChunk();
                SMPInterface.Chunks.Add(p, c);
            }
            MinecraftLevel.Chunk ct;
            if (!SMPInterface.TransChunks.TryGetValue(p, out ct))
            {
                ct = MinecraftLevel.Chunk.EmptyChunk();
                ct.Trans = true;
                SMPInterface.TransChunks.Add(p, ct);
            }

            for (int ix = x; ix < x + sizex + 1; ix++)
                for (int iz = z; iz < z + sizez + 1; iz++)
                    for (int iy = y; iy < y + sizey + 1; iy++)
                    {
                        int rx = mod((ix - cx), MinecraftLevel.ChunkXSize); // fixes the negatives
                        int ry = mod((iy - cy), MinecraftLevel.ChunkYSize);
                        int rz = mod((iz - cz), MinecraftLevel.ChunkZSize);

                        Cubia.Vector<int> vec = new Cubia.Vector<int>(rx, ry, rz);
                        byte bType = (byte)r.Read(8); // 8 bits in byte
                        MinecraftBlock block = new MinecraftBlock()
                        {
                            BlockLight = 0,
                            SkyLight = 0,
                            Type = bType
                        };
                        if (GCScheme.IsTrans(bType))
                            ct.UpdateBlock(vec, block);
                        else
                            c.UpdateBlock(vec, block);
                    }
        }