当前位置: 首页>>代码示例>>C#>>正文


C# Player.ClearBlockchange方法代码示例

本文整理汇总了C#中MCSharp.Player.ClearBlockchange方法的典型用法代码示例。如果您正苦于以下问题:C# Player.ClearBlockchange方法的具体用法?C# Player.ClearBlockchange怎么用?C# Player.ClearBlockchange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MCSharp.Player的用法示例。


在下文中一共展示了Player.ClearBlockchange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Blockchange2

        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            switch (cpos.solid)
            {
                case SolidType.solid:
                    if (!Server.operators.Contains(p.name))
                    {
                        int attemptedLimit = (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z));
                        if (attemptedLimit > p.group.CuboidLimit && p.group.CuboidLimit != 0) //OPERATOR door LIMIT, same as cuboid
                        {
                            p.SendMessage("You're trying to convert " + attemptedLimit + " blocks.");
                            p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
                            return;
                        }
                    }
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                                /*if (p.level.GetTile(xx, yy, zz) != type) {*/
                                BufferAdd(buffer, xx, yy, zz); //}
                    break;
            }

            p.SendMessage("Converting " + buffer.Count.ToString() + " blocks into door_material.");

            // Disable physics before changing the blocks
            Physics physicsSetting = p.level.Physics;
            p.level.Physics = Physics.Off;
            p.level.ClearPhysics();

            // Because we are calling ClearPhysics() we do not need to account for doorair_material. These materials will be
            // converted back into door_material automatically.

            buffer.ForEach(delegate(Pos pos)
            {
                byte oldBlock = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
                byte newBlock = Block.convertDoor(oldBlock);
                if (newBlock != oldBlock)  // if the block is doorifiable
                {
                    if (!opMats.doorBlocks.Contains(oldBlock)) // if the block is not already a door
                    {
                        if (!ignoreList.Contains(newBlock)) // if the new block is not being ignored
                        {
                            p.level.Blockchange(p, pos.x, pos.y, pos.z, newBlock); // send converted reg_material
                        }
                    }
                }
            });

            p.level.Physics = physicsSetting;
            p.SendMessage("Conversion complete.");
        }
开发者ID:Postremus,项目名称:MCSharp,代码行数:59,代码来源:CmdDoor.cs

示例2: Blockchange1

 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     CatchPos bp = (CatchPos)p.blockchangeObject;
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
开发者ID:duaneking,项目名称:MCSharp,代码行数:9,代码来源:CmdReplace.cs

示例3: Blockchange2

        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            switch (cpos.solid)
            {
                case SolidType.solid:
                    if (!Server.operators.Contains(p.name))
                    {
                        int attemptedLimit = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                        if (attemptedLimit > p.group.CuboidLimit && p.group.CuboidLimit != 0) //OPERATOR unlock LIMIT, same as cuboid
                        {
                            p.SendMessage("You're trying to unlock " + attemptedLimit + " blocks.");
                            p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
                            return;
                        }
                    }
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                                /*if (p.level.GetTile(xx, yy, zz) != type) {*/
                                BufferAdd(buffer, xx, yy, zz); //}
                    break;
            }

            p.SendMessage("Unlocking " + buffer.Count.ToString() + " blocks.");

            // Disable physics before changing the blocks
            Physics physicsSetting = p.level.Physics;
            p.level.Physics = Physics.Off;
            p.level.ClearPhysics();

            buffer.ForEach(delegate(Pos pos)
            {
                byte bl = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
                if (opMats.opBlocks.Contains(bl))  // if the block is op_material
                {

                    if (!ignoreList.Contains(bl)) // if the block is not being ignored
                    {
                        p.level.Blockchange(p, pos.x, pos.y, pos.z, (byte)Block.convertOp(bl)); // send converted reg_material
                    }
                }
            });
            //p.level.Blockchange(p, pos.x, pos.y, pos.z, (byte)(Block.lavastill));
            p.level.Physics = physicsSetting;
            p.SendMessage("Unlocking complete.");
        }
开发者ID:duaneking,项目名称:MCSharp,代码行数:53,代码来源:CmdUnlock.cs

示例4: Use

 // Code to run when used by a player
 public override void Use(Player p,string message)
 {
     if (p.HasBlockchange())
     {
         p.SendMessage("There is no action to abort.");
     }
     else
     {
         p.ClearBlockchange();
         p.SendMessage("Action aborted.");
     }
 }
开发者ID:pazuzu156,项目名称:MCSharp,代码行数:13,代码来源:CmdAbort.cs

示例5: Use

 // Code to run when used by a player
 public override void Use(Player p,string message)
 {
     if (message == "")
     {
         p.SendMessage("Break/build a block to display information.");
         p.ClearBlockchange();
         p.Blockchange += new Player.BlockchangeEventHandler(Blockchange);
     }
     else
     {
         Help(p);
     }
 }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:14,代码来源:CmdAbout.cs

示例6: Blockchange

 public void Blockchange(Player p,ushort x,ushort y,ushort z,byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x,y,z);
     if (b != Block.Zero)
     {
         p.SendBlockchange(x, y, z, b);
         string message = "Block (" + x + "," + y + "," + z + "): ";
         message += "&f" + b + " = " + Block.Name(b);
         p.SendMessage(message + "&e.");
     }
     else
     {
         p.SendMessage("Invalid Block(" + x + "," + y + "," + z + ")!");
     }
 }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:16,代码来源:CmdAbout.cs

示例7: Blockchange2

        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            switch (cpos.solid)
            {
                case SolidType.solid:
                    if (!Server.operators.Contains(p.name))
                    {
                        int attemptedLimit = (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z));
                        if (attemptedLimit > 200000 && p.group.CuboidLimit != 0)
                        { //OPERATOR opview limit, NOT DESTRUCTIVE, therefor high limit
                            p.SendMessage("You're trying to view " + attemptedLimit + " blocks.");
                            p.SendMessage("Your OpView limit is " + 200000 + " blocks. Build in stages.");
                            return;
                        }
                    }
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                                /*if (p.level.GetTile(xx, yy, zz) != type) {*/
                                BufferAdd(buffer, xx, yy, zz); //}
                    break;
            }

            p.SendMessage("Processing " + buffer.Count.ToString() + " blocks.");

            buffer.ForEach(delegate(Pos pos)
            {
                byte bl = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
                if (!ignoreList.Contains(bl)) // if the block is not being ignored
                {
                    if (opMats.doorBlocks.Contains(bl)) // if the block is a door_material
                    {
                        p.SendBlockchange(pos.x, pos.y, pos.z, ((byte)Block.green)); // turn it green
                    }
                }
            }
            );
            p.SendMessage("Doorview complete.");
        }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:46,代码来源:CmdDoorView.cs

示例8: Blockchange2

        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            switch (cpos.solid)
            {
                case SolidType.solid:
                    if (!Server.operators.Contains(p.name))
                    {
                        int attemptedLimit = (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z));
                        if (attemptedLimit > p.group.CuboidLimit && p.group.CuboidLimit != 0) // Use cuboid limit
                        {
                            p.SendMessage("You're trying to unview " + attemptedLimit + " blocks.");
                            p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
                            return;
                        }
                    }
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                                /*if (p.level.GetTile(xx, yy, zz) != type) {*/
                                BufferAdd(buffer, xx, yy, zz); //}
                    break;
            }

            p.SendMessage("Processing " + buffer.Count.ToString() + " blocks.");

            buffer.ForEach(delegate(Pos pos)
            {
                byte bl = p.level.GetTile(pos.x, pos.y, pos.z); //Get the block that is there at the moment
                if (!ignoreList.Contains(bl))// if the block is not being ignored
                {
                    if (opMats.doorBlocks.Contains(bl))   // if the block is a door_material// Saves bandwidth not sending reg_material updates
                    {
                        p.SendBlockchange(pos.x, pos.y, pos.z, bl); // Send original texture back to client
                    }
                }
            }
            );
            p.SendMessage("Undoorview complete.");
        }
开发者ID:Postremus,项目名称:MCSharp,代码行数:46,代码来源:CmdUnDoorView.cs

示例9: Blockchange2

        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) == type)
                        {
                            BufferAdd(buffer, xx, yy, zz);
                        }
                    }
                }
            }

                if (buffer.Count > p.group.CuboidLimit && p.group.CuboidLimit != 0)
                {
                    p.SendMessage("You're trying to replace " + buffer.Count.ToString() + " blocks.");
                    p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Replace in stages.");
                    return;
                }

            p.SendMessage(buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos)
            {
                p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.type2);                  //update block for everyone
            });
        }
开发者ID:duaneking,项目名称:MCSharp,代码行数:36,代码来源:CmdReplace.cs

示例10: Use

 // Code to run when used by a player
 public override void Use(Player p, string message)
 {
     if (!Properties.BetaMode)
     {
         p.SendMessage("/copy is not currently available in non-beta mode.");
     }
     else
     {
         p.SendMessage("Place two blocks to determine the edges.");
         p.ClearBlockchange();
         p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
     }
 }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:14,代码来源:CmdCopy.cs

示例11: Use

        // Code to run when used by a player
        public override void Use(Player p, string message)
        {
            // Clear previously ignored blocks
            for (int i = 0; i < ignoreList.Length - 1; i++)
            {
                ignoreList[i] = 255;
            }
            int counter = 0;
            CatchPos cpos = new CatchPos(); cpos.solid = SolidType.solid; unchecked { cpos.type = (byte)-1; }
            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            if (message != "")
            {
                // Here we can use the same principle as searching through opMats.
                // This function ignores op_material for security reasons.
                // This function also ignores any non-doorifiable block (ie: air, water, lava...etc)
                message = message.ToLower();
                message = " " + message;  // Add the whitespace back to work with the ignore list code below

                for (int i = 0; i < opMats.doorBlocks.Length; i++)
                {
                    if ((message.Contains(" " + Block.Name(opMats.doorBlocks[i]))) || (message.Contains(" " + Block.Name(opMats.regBlocks[i]))))
                    {
                        ignoreList[counter] = opMats.doorBlocks[i];
                        counter += 1;
                        if (counter > ignoreList.Length - 1)
                        {
                            break;
                        }
                    }
                }
            } // Not allowing user to use "all" because turning a map into door_material would be pointless
              // User can still manually do it by placing blocks.
            p.SendMessage("Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:37,代码来源:CmdDoor.cs

示例12: Use

 // Code to run when used by a player
 public override void Use(Player p, string message)
 {
     // Clear previously ignored blocks
     for (int i = 0; i < ignoreList.Length - 1; i++)
     {
         ignoreList[i] = 255;
     }
     int counter = 0;
     CatchPos cpos = new CatchPos(); cpos.solid = SolidType.solid; unchecked { cpos.type = (byte)-1; }
     cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
     if (message != "")
     {
         message = message.ToLower();
         message = " " + message;
         for (int i = 0; i < opMats.opBlocks.Length; i++)
         {
             if ((message.Contains(" " + Block.Name(opMats.opBlocks[i]))) || (message.Contains(" " + Block.Name(opMats.regBlocks[i]))))
             {
                 ignoreList[counter] = opMats.opBlocks[i];
                 counter += 1;
                 if (counter > ignoreList.Length - 1)
                 {
                     break;
                 }
             }
         }
         if (message.Contains("all"))   // Add spaces before an after?  Block might contain "all" in the future
         {   // User used "all"
             Blockchange2(p, p.level.width, p.level.depth, p.level.height, type);
             return;
         }
     }
     // Code will only be reached if user message doesn't contain "all"
     p.SendMessage("Place two blocks to determine the edges.");
     p.ClearBlockchange();
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:38,代码来源:CmdUnlock.cs

示例13: Blockchange2

        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();

            if (Math.Abs(x - cpos.x) != Math.Abs(z - cpos.z)) { p.SendMessage("No good, make it a circle."); return; }

            float CenX = Middle(x , cpos.x);
            float CenZ = Middle(z , cpos.z);
            float Rad = Math.Abs(CenX - (float)x);

            if (Rad != (int)Rad) { p.SendMessage("No good, try a diferent radius."); return; }
            switch (cpos.solid)
            {
                case SolidType.solid:
                    //for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    //    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    //        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    //            if (p.level.GetTile(xx, yy, zz).type != type) { BufferAdd(buffer, xx, yy, zz); }

                    float error = -Rad;
                    float varx = Rad;
                    float varz = 0;

                    p.SendMessage("Radius " + Rad.ToString());

                    while (varx >= varz)
                    {
                        for (ushort yy = (ushort)(Math.Min(cpos.y, y)); yy <= Math.Max(cpos.y, y); ++yy)
                        {
                            BufferAdd(buffer, (ushort)(CenX + varx), yy, (ushort)(CenZ + varz));
                            BufferAdd(buffer, (ushort)(CenX - varx), yy, (ushort)(CenZ + varz));
                            BufferAdd(buffer, (ushort)(CenX + varx), yy, (ushort)(CenZ - varz));
                            BufferAdd(buffer, (ushort)(CenX - varx), yy, (ushort)(CenZ - varz));

                            BufferAdd(buffer, (ushort)(CenX + varz), yy, (ushort)(CenZ + varx));
                            BufferAdd(buffer, (ushort)(CenX - varz), yy, (ushort)(CenZ + varx));
                            BufferAdd(buffer, (ushort)(CenX + varz), yy, (ushort)(CenZ - varx));
                            BufferAdd(buffer, (ushort)(CenX - varz), yy, (ushort)(CenZ - varx));
                        }

                        error += varz;
                        ++varz;
                        error += varz;

                        // The following test may be implemented in assembly language in
                        // most machines by testing the carry flag after adding 'y' to
                        // the value of 'error' in the previous step, since 'error'
                        // nominally has a negative value.
                        if (error >= 0)
                        {
                            --varx;
                            error -= varx;
                            error -= varx;
                        }
                    }

                    break;

                case SolidType.hollow:
                    p.SendMessage("Not implemented yet.");
                    return;
            }

            if (!Server.operators.Contains(p.name))
            {
                if (buffer.Count > 800)
                {
                    p.SendMessage("Too many blocks, build in stages.");
                    return;
                }
            }
            else if (buffer.Count > 20000)
            {
                p.SendMessage("That is a bad idea.");
                return;
            }

            p.SendMessage(buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos)
            {
                p.level.Blockchange(p, pos.x, pos.y, pos.z, type);                  //update block for everyone
            });
        }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:88,代码来源:CmdCircle.cs

示例14: Use

 // Code to run when used by a player
 public override void Use(Player p, string message)
 {
     int number = message.Split(' ').Length;
     if (number > 2) { Help(p); return; }
     if (number == 2)
     {
         int pos = message.IndexOf(' ');
         string t = message.Substring(0, pos).ToLower();
         string s = message.Substring(pos + 1).ToLower();
         byte type = Block.Byte(t);
         if (type == 255) { p.SendMessage("There is no block \"" + t + "\"."); return; }
         SolidType solid;
         if (s == "solid") { solid = SolidType.solid; }
         else if (s == "hollow") { solid = SolidType.hollow; }
         else { Help(p); return; }
         CatchPos cpos = new CatchPos(); cpos.solid = solid; cpos.type = type;
         cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
     }
     else if (message != "")
     {
         SolidType solid = SolidType.solid;
         message = message.ToLower();
         byte type; unchecked { type = (byte)-1; }
         if (message == "solid") { solid = SolidType.solid; }
         else if (message == "hollow") { solid = SolidType.hollow; }
         else
         {
             byte t = Block.Byte(message);
             if (t == 255) { p.SendMessage("There is no block \"" + t + "\"."); return; }
             type = t;
         } CatchPos cpos = new CatchPos(); cpos.solid = solid; cpos.type = type;
         cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
     }
     else
     {
         CatchPos cpos = new CatchPos(); cpos.solid = SolidType.solid; unchecked { cpos.type = (byte)-1; }
         cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
     }
     p.SendMessage("Place two blocks to determine the edges.");
     p.ClearBlockchange();
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
开发者ID:TaFinalDestination,项目名称:MCSharp,代码行数:43,代码来源:CmdCircle.cs

示例15: Blockchange2

        // Second block change (defining second corner)
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos) p.blockchangeObject;
            unchecked { if (cpos.type != (byte) -1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();

            // Solid is default
            switch (cpos.solid)
            {
                case SolidType.solid:

                    // redundant?
                    if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > p.group.CuboidLimit && p.group.CuboidLimit != 0)
                    {
                        p.SendMessage("You're trying to place " + buffer.Count.ToString() + " blocks.");
                        p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
                        return;
                    }
                    // end redundant?

                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);

                    // Nested for loops to cover a solid cube
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                                if (p.level.GetTile(xx, yy, zz) != type) { BufferAdd(buffer, xx, yy, zz); }
                    break;

                case SolidType.hollow:
                    // TODO: Work out if theres 800 blocks used before making the buffer

                    // Hollow will build only the outer shell of a cube leaving the center alone
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (p.level.GetTile(cpos.x, yy, zz) != type) { BufferAdd(buffer, cpos.x, yy, zz); }
                            if (cpos.x != x) { if (p.level.GetTile(x, yy, zz) != type) { BufferAdd(buffer, x, yy, zz); } }
                        }
                    if (Math.Abs(cpos.x - x) >= 2)
                    {
                        for (ushort xx = (ushort) (Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                            for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                if (p.level.GetTile(xx, cpos.y, zz) != type) { BufferAdd(buffer, xx, cpos.y, zz); }
                                if (cpos.y != y) { if (p.level.GetTile(xx, y, zz) != type) { BufferAdd(buffer, xx, y, zz); } }
                            }
                        if (Math.Abs(cpos.y - y) >= 2)
                        {
                            for (ushort xx = (ushort) (Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                                for (ushort yy = (ushort) (Math.Min(cpos.y, y) + 1); yy <= Math.Max(cpos.y, y) - 1; ++yy)
                                {
                                    if (p.level.GetTile(xx, yy, cpos.z) != type) { BufferAdd(buffer, xx, yy, cpos.z); }
                                    if (cpos.z != z) { if (p.level.GetTile(xx, yy, z) != type) { BufferAdd(buffer, xx, yy, z); } }
                                }
                        }
                    }
                    break;

                // Walls builds only the surrounding vertical borders of a cube
                case SolidType.walls:
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (p.level.GetTile(cpos.x, yy, zz) != type) { BufferAdd(buffer, cpos.x, yy, zz); }
                            if (cpos.x != x) { if (p.level.GetTile(x, yy, zz) != type) { BufferAdd(buffer, x, yy, zz); } }
                        }
                    if (Math.Abs(cpos.x - x) >= 2)
                    {
                        if (Math.Abs(cpos.z - z) >= 2)
                        {
                            for (ushort xx = (ushort) (Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                                for (ushort yy = (ushort) (Math.Min(cpos.y, y)); yy <= Math.Max(cpos.y, y); ++yy)
                                {
                                    if (p.level.GetTile(xx, yy, cpos.z) != type) { BufferAdd(buffer, xx, yy, cpos.z); }
                                    if (cpos.z != z) { if (p.level.GetTile(xx, yy, z) != type) { BufferAdd(buffer, xx, yy, z); } }
                                }
                        }
                    }
                    break;
            }

            // Why are we running this in the solid case statement as well?
            if (buffer.Count > p.group.CuboidLimit && p.group.CuboidLimit != 0)
            {
                p.SendMessage("You're trying to place " + buffer.Count.ToString() + " blocks.");
                p.SendMessage("Your block limit is " + p.group.CuboidLimit.ToString() + " blocks. Build in stages.");
                return;
            }

            p.SendMessage(buffer.Count.ToString() + " blocks.");

            // This code may not be needed. We already check whether the player can place the block near the top of this class
            if (!Server.advbuilders.Contains(p.name))
            {
                buffer.ForEach(delegate(Pos pos)
//.........这里部分代码省略.........
开发者ID:MinedroidFTW,项目名称:MCSharp,代码行数:101,代码来源:CmdCuboid.cs


注:本文中的MCSharp.Player.ClearBlockchange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。