Beispiel #1
0
        public void SendMultiBlockChange(int x, int z, BlockChangeData[] blocks)
        {
            blocks = (BlockChangeData[])blocks.Truncate(short.MaxValue);
                byte[] bytes = new byte[10 + (blocks.Length * 4)];
                util.EndianBitConverter.Big.GetBytes(x).CopyTo(bytes, 0);
                util.EndianBitConverter.Big.GetBytes(z).CopyTo(bytes, 4);
                util.EndianBitConverter.Big.GetBytes((short)blocks.Length).CopyTo(bytes, 8);

                BlockChangeData block;
                short[] coord = new short[blocks.Length];
                byte[] type = new byte[blocks.Length];
                byte[] meta = new byte[blocks.Length];
                for (int i = 0; i < blocks.Length; i++)
                {
                    block = blocks[i];
                    coord[i] = (short)((block.x << 12) | (block.z << 8) | block.y);
                    type[i] = block.type;
                    meta[i] = block.meta;
                }
                for (int i = 0; i < coord.Length; i++)
                    util.EndianBitConverter.Big.GetBytes(coord[i]).CopyTo(bytes, 10 + (i * 2));
                type.CopyTo(bytes, 10 + (blocks.Length * 2));
                meta.CopyTo(bytes, 10 + (blocks.Length * 3));

                SendRaw(0x34, bytes);
        }
Beispiel #2
0
 public void SendMultiBlockChange(Point a, BlockChangeData[] blocks)
 {
     SendMultiBlockChange(a.x, a.z, blocks);
 }
Beispiel #3
0
        public void QueueBlockChange(int x, int y, int z, byte type, byte meta)
        {
            Point pt = new Point(x >> 4, z >> 4);
            BlockChangeData data = new BlockChangeData(x & 0xf, y, z & 0xf, type, meta);

            lock (blockQueue)
            {
                if (!blockQueue.ContainsKey(pt))
                    blockQueue.Add(pt, new List<BlockChangeData>());
                blockQueue[pt].RemoveAll(bl => (bl.x == data.x && bl.y == data.y && bl.z == data.z)); // We don't want multiple with the same coordinates.
                blockQueue[pt].Add(data);
            }
        }