コード例 #1
0
        CopyState RotateX(CopyState state)
        {
            CopyState newState = new CopyState(state.X, state.Y, state.Z,
                                               state.Width, state.Length, state.Height);

            byte[] blocks  = state.Blocks, extBlocks = state.ExtBlocks;
            int    oldMaxZ = state.Length - 1;

            for (int i = 0; i < blocks.Length; i++)
            {
                ushort x, y, z;
                state.GetCoords(i, out x, out y, out z);
                newState.Set(x, oldMaxZ - z, y, blocks[i], extBlocks[i]);
            }
            newState.SetOrigin(state.OriginX, state.Y + (state.OppositeOriginZ - state.Z),
                               state.Z + (state.OriginY - state.Y));
            return(newState);
        }
コード例 #2
0
ファイル: CmdCopy.cs プロジェクト: 1stupidname/MCGalaxy
        void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            ushort   minX = (ushort)Math.Min(x, cpos.x), minY = (ushort)Math.Min(y, cpos.y);
            ushort   minZ = (ushort)Math.Min(z, cpos.z), maxX = (ushort)Math.Max(x, cpos.x);
            ushort   maxY = (ushort)Math.Max(y, cpos.y), maxZ = (ushort)Math.Max(z, cpos.z);

            CopyState state = new CopyState(minX, minY, minZ, maxX - minX + 1,
                                            maxY - minY + 1, maxZ - minZ + 1);

            state.SetOrigin(cpos.x, cpos.y, cpos.z);
            int totalAir = 0, index = 0;

            state.PasteAir = cpos.type == 2;

            for (ushort yy = minY; yy <= maxY; ++yy)
            {
                for (ushort zz = minZ; zz <= maxZ; ++zz)
                {
                    for (ushort xx = minX; xx <= maxX; ++xx)
                    {
                        byte b = p.level.GetTile(xx, yy, zz), extB = 0;
                        if (!Block.canPlace(p, b))
                        {
                            index++; continue;
                        }
                        if (b == Block.custom_block)
                        {
                            extB = p.level.GetExtTile(xx, yy, zz);
                        }

                        if (b == Block.air && cpos.type != 2)
                        {
                            totalAir++;
                        }
                        state.Blocks[index]    = b;
                        state.ExtBlocks[index] = extB;
                        index++;
                    }
                }
            }
            p.CopyBuffer = state;

            if ((state.Volume - totalAir) > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to copy " + state.Volume + " blocks.");
                Player.SendMessage(p, "You cannot copy more than " + p.group.maxBlocks + ".");
                p.CopyBuffer = null;
                return;
            }

            if (cpos.type == 1)
            {
                for (ushort yy = minY; yy <= maxY; ++yy)
                {
                    for (ushort zz = minZ; zz <= maxZ; ++zz)
                    {
                        for (ushort xx = minX; xx <= maxX; ++xx)
                        {
                            byte b = p.level.GetTile(xx, yy, zz);
                            if (b != Block.air && Block.canPlace(p, b))
                            {
                                p.level.UpdateBlock(p, xx, yy, zz, Block.air, 0);
                            }
                        }
                    }
                }
            }

            Player.SendMessage(p, (state.Volume - totalAir) + " blocks copied.");
            if (cpos.allowoffset != -1)
            {
                Player.SendMessage(p, "Place a block to determine where to paste from");
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange3);
            }
        }