• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CatchPos类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CatchPos的典型用法代码示例。如果您正苦于以下问题:C# CatchPos类的具体用法?C# CatchPos怎么用?C# CatchPos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CatchPos类属于命名空间,在下文中一共展示了CatchPos类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Use

        public void Use(Player p, string[] args) {
            CatchPos cpos = new CatchPos();
            if (args.Length != 0) {
                cpos.ignore = new List<byte>();
                for (int i = 0; i < args.Length; i++) {
                    try {
                        cpos.ignore.Add(Block.NameToBlock(args[i]));
                    }
                    catch {
                        p.SendMessage("Could not find the block '" + args[i] + "'");
                        return;
                    }
                }
                string s = "";
                for (int i = 0; i < cpos.ignore.Count; i++) {
                    s += ((Block)cpos.ignore[i]).Name;
                    if (i == cpos.ignore.Count - 2) s += " and ";
                    else if (i != cpos.ignore.Count - 1) s += ", ";
                }
                p.SendMessage("Ignoring " + s + ".");
            }
            //else
            //cpos.ignore.Add(Block.NameToByte("unknown")); //So it doesn't ignore air.
            p.SendMessage("Place two blocks to determine the edges.");
            //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos);
            p.SetDatapass("CmdMeasure_cpos", cpos);
            p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock);

        }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:29,代码来源:CmdMeasure.cs


示例2: CopyBlocks

        static bool CopyBlocks(Player p, Level other, ushort x, ushort y, ushort z, CatchPos cpos) {
            byte[] blocks = other.blocks;
            if (blocks.Length != p.level.blocks.Length) { 
                p.SendMessage("Cant restore selection of different size maps.");
                return false;
            }
            int width = other.Width, height = other.Length;

            if (p.level.bufferblocks && !p.level.Instant) {
                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)
                        for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    BlockQueue.Addblock(p, xx, yy, zz, blocks[xx + (zz * width) + (yy * width * height)]);
                }
            } else {
                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)
                        
                        for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    p.level.Blockchange(p, xx, yy, zz, blocks[xx + (zz * width) + (yy * width * height)]);
                }
            }
            return true;
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:26,代码来源:CmdRestoreSelection.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;
                List<CatchPos> buffer = new List<CatchPos>();
                CatchPos pos = new CatchPos();
                //int totalChecks = 0;

                //if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > 8000) { Player.SendMessage(p, "Tried to restart too many blocks. You may only restart 8000"); return; }

                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) != Block.air)
                            {
                                pos.x = xx; pos.y = yy; pos.z = zz;
                                pos.extraInfo = cpos.extraInfo;
                                buffer.Add(pos);
                            }
                        }
                    }
                }

                try
                {
                    if (cpos.extraInfo == "")
                    {
                        if (buffer.Count > Server.rpNormLimit)
                        {
                            Player.SendMessage(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
                            Player.SendMessage(p, "Tried to restart " + buffer.Count + " blocks.");
                            return;
                        }
                    }
                    else
                    {
                        if (buffer.Count > Server.rpLimit)
                        {
                            Player.SendMessage(p, "Tried to add physics to " + buffer.Count + " blocks.");
                            Player.SendMessage(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
                            return;
                        }
                    }
                }
                catch { return; }

                foreach (CatchPos pos1 in buffer)
                {
                    p.level.AddCheck(p.level.PosToInt(pos1.x, pos1.y, pos1.z), pos1.extraInfo, true);
                }

                Player.SendMessage(p, "Activated " + buffer.Count + " blocks.");
                if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:Cazzar,项目名称:MCForge-MCLawl,代码行数:59,代码来源:CmdRestartPhysics.cs


示例4: Use

 public void Use(Player p, string[] args) {
     if (args.Length == 0) { p.SendMessage("Please specify a message to write!"); Help(p); return; }
     CatchPos cpos = new CatchPos();
     cpos.message = string.Join(" ", args);
     p.SetDatapass(Name, cpos);
     p.SendMessage("Place two blocks to determine the direction!");
     p.OnPlayerBlockChange.Normal += BlockChange1;
 }
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:8,代码来源:CmdWrite.cs


示例5: CatchBlock

 public void CatchBlock(Player p, BlockChangeEventArgs args)
 {
     CatchPos cpos = new CatchPos();
     cpos.pos = new Vector3S(args.X, args.Z, args.Y);
     cpos.block = args.Holding;
     args.Cancel();
     p.OnPlayerBlockChange.Normal -= new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock);
     p.SetDatapass(this.Name, cpos);
     p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2);
 }
开发者ID:Maicke98,项目名称:MCForge-Vanilla,代码行数:10,代码来源:CmdCuboid.cs


示例6: 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);
     bp = (CatchPos)p.blockchangeObject;
     thex = x; they = y + 2; thez = z; p.blockchangeObject = bp;
     Thread t = new Thread(ZombieMob);
     t.Start(p);
 }
开发者ID:EricKilla,项目名称:mcforge,代码行数:10,代码来源:CmdZombieSpawn.cs


示例7: OnUse

 protected override void OnUse(Player p, string msg, string[] parts, ref CatchPos cpos) {
     if (parts.Length == 2 || parts.Length == 3) {
         string arg = parts[parts.Length - 1];
         ushort len;
         if (!ushort.TryParse(arg, out len)) {
             if (arg == "walls" || arg == "straight" || arg == "normal") return;                
             Player.SendMessage(p, msg + " is not valid length, assuming maximum length allowed.");
         } else {
             cpos.data = len;
         }
     } 
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:12,代码来源:CmdLine.cs


示例8: Use

        public void Use(Player p, string[] args)
        {
            main = new CatchPos();
            main.block = 255;
            main.cuboidType = SolidType.solid;
            switch (args.Length)
            {
                case -1:
                    p.SendMessage("Invalid block or type!");
                    return;
                case 0: // No arguments
                    break;
                case 1: // Block or Type ONLY
                    if (ValidSolidType(args[0]) || ValidBlockName(args[0]))
                        break;
                    goto case -1;
                case 2: // Block AND Type
                    if (ValidSolidType(args[0]) || ValidSolidType(args[1]))
                        if (ValidBlockName(args[0]) || ValidBlockName(args[1]))
                            break;
                    goto case -1;
                case 6: // Coordinates ONLY
                    main.block = 1;
                    ParseCoordinates(p, args);
                    return;
                case 7: //Coordinates with Block OR Type
                    if (ValidSolidType(args[6]) || ValidBlockName(args[6]))
                        ParseCoordinates(p, args);
                    else
                        goto case -1;
                    return;
                case 8: //Coordinates with Block AND Type
                    if (ValidSolidType(args[6]) || ValidSolidType(args[7]))
                        if (ValidBlockName(args[6]) || ValidBlockName(args[7]))
                        {
                            ParseCoordinates(p, args);
                            return;
                        }
                    goto case -1;
                default:
                    p.SendMessage("Invalid number of arguments!");
                    Help(p);
                    return;
            }

            p.SendMessage("Place two blocks to determine the corners.");
            p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1);
        }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:48,代码来源:CmdCuboid.cs


示例9: Use

        public void Use(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.SendMessage("Invalid number of arguments!");
                Help(p);
                return;
            }

            CatchPos cpos = new CatchPos();
            List<string> oldType;

            if (args[0].Contains(","))
                oldType = new List<string>(args[0].Split(','));
            else
                oldType = new List<string>() { args[0] };
            
            oldType = oldType.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in oldType)
                if (!Block.ValidBlockName(name))
                    invalid.Add(name);
            if (!Block.ValidBlockName(args[1]))
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid)));
                return;
            }

            if (oldType.Contains(args[1]))
                oldType.Remove(args[1]);
            if (oldType.Count < 1)
            {
                p.SendMessage("Replacing a block with the same one would be pointless!");
                return;
            }

            cpos.oldType = new List<byte>();
            foreach (string name in oldType)
                cpos.oldType.Add(Block.NameToBlock(name));
            cpos.newType = Block.NameToBlock(args[1]);

            p.SendMessage("Place two blocks to determine the edges.");
            p.SetDatapass(this.Name, cpos);
            p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1);
        }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:48,代码来源:CmdReplace.cs


示例10: 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;
            if (cpos.type == Block.Zero) type = p.bindings[type]; else type = cpos.type;
            List<CatchPos> buffer = new List<CatchPos>();
            CatchPos pos = new CatchPos();

            if (cpos.extraType == 2)
            {  //Fun part of making a straight line
                int xdif = Math.Abs(cpos.x - x);
                int ydif = Math.Abs(cpos.y - y);
                int zdif = Math.Abs(cpos.z - z);

                if (xdif > ydif && xdif > zdif)
                {
                    y = cpos.y; z = cpos.z;
                }
                else if (ydif > xdif && ydif > zdif)
                {
                    x = cpos.x; z = cpos.z;
                }
                else if (zdif > ydif && zdif > xdif)
                {
                    y = cpos.y; x = cpos.x;
                }
            }

            if (cpos.maxNum == 0) cpos.maxNum = 100000;

            int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2;
            int[] pixel = new int[3];

            pixel[0] = cpos.x; pixel[1] = cpos.y; pixel[2] = cpos.z;
            dx = x - cpos.x; dy = y - cpos.y; dz = z - cpos.z;

            x_inc = (dx < 0) ? -1 : 1; l = Math.Abs(dx);
            y_inc = (dy < 0) ? -1 : 1; m = Math.Abs(dy);
            z_inc = (dz < 0) ? -1 : 1; n = Math.Abs(dz);

            dx2 = l << 1; dy2 = m << 1; dz2 = n << 1;

            if ((l >= m) && (l >= n))
            {
                err_1 = dy2 - l;
                err_2 = dz2 - l;
                for (i = 0; i < l; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[1] += y_inc;
                        err_1 -= dx2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[2] += z_inc;
                        err_2 -= dx2;
                    }
                    err_1 += dy2;
                    err_2 += dz2;
                    pixel[0] += x_inc;
                }
            }
            else if ((m >= l) && (m >= n))
            {
                err_1 = dx2 - m;
                err_2 = dz2 - m;
                for (i = 0; i < m; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[0] += x_inc;
                        err_1 -= dy2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[2] += z_inc;
                        err_2 -= dy2;
                    }
                    err_1 += dx2;
                    err_2 += dz2;
                    pixel[1] += y_inc;
                }
            }
            else
            {
                err_1 = dy2 - n;
                err_2 = dx2 - n;
//.........这里部分代码省略.........
开发者ID:sillyboyization,项目名称:MCDawn,代码行数:101,代码来源:CmdLine.cs


示例11: Use

        public override void Use(Player p, string message)
        {
            wait = 0;
            string[] args = message.Split(' ');
            if (args.Length != 2) { p.SendMessage("Invalid number of arguments!"); Help(p); wait = 1; return; }

            CatchPos cpos = new CatchPos();
            List<string> ignore;

            if (args[0].Contains(","))
                ignore = new List<string>(args[0].Split(','));
            else
                ignore = new List<string>() { args[0] };

            ignore = ignore.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in ignore)
                if (Block.Byte(name) == 255)
                    invalid.Add(name);
            if (Block.Byte(args[1]) == 255)
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid.ToArray())));
                return;
            }

            if (ignore.Contains(args[1]))
                ignore.Remove(args[1]);
            if (ignore.Count == 0)
                p.SendMessage("Next time just use cuboid if you're not going to ignore anything!");

            if (Block.Byte(message.Split(' ')[1]) == 255) { p.SendMessage(message.Split(' ')[1] + " does not exist, please spell it correctly."); wait = 1; return; }

            cpos.ignore = new List<byte>();
            foreach (string name in ignore)
                cpos.ignore.Add(Block.Byte(name));
            cpos.newType = Block.Byte(args[1]);

            if (!Block.canPlace(p, cpos.newType)) { p.SendMessage("Cannot place this block type!"); wait = 1; return; }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:727021,项目名称:MCForge-MCLawl,代码行数:47,代码来源:CmdReplaceNot.cs


示例12: Cuboid

        private void Cuboid(CatchPos cpos, byte NewType, Player p, ushort x, ushort y, ushort z)
        {
            List<Pos> buffer = new List<Pos>();
            ushort xx, zz, yy;
            if (cpos.block != 255) {
                NewType = cpos.block;
            }
            switch (cpos.cuboidType) {
                case SolidType.solid:
                    buffer.Capacity = Math.Max(Math.Abs(cpos.pos.x - x), 1) * Math.Max(Math.Abs(cpos.pos.z - z), 1) * Math.Max(Math.Abs(cpos.pos.y - y), 1);
                    for (xx = Math.Min((ushort)(cpos.pos.x), x); xx <= Math.Max((ushort)(cpos.pos.x), x); ++xx) {
                        for (zz = Math.Min((ushort)(cpos.pos.z), z); zz <= Math.Max((ushort)(cpos.pos.z), z); ++zz) {
                            for (yy = Math.Min((ushort)(cpos.pos.y), y); yy <= Math.Max((ushort)(cpos.pos.y), y); ++yy) {
                                Vector3S loop = new Vector3S(xx, zz, yy);
                                if (p.Level.GetBlock(loop) != NewType) {
                                    BufferAdd(buffer, xx, zz, yy);
                                }
                            }
                        }
                    }
                    break;
                case SolidType.hollow:
                    for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max(cpos.pos.z, y); ++zz)
                        for (yy = Math.Min((ushort)cpos.pos.z, z); yy <= Math.Max(cpos.pos.z, z); ++yy) {
                            if (p.Level.GetBlock(cpos.pos.x, yy, zz) != NewType) {
                                BufferAdd(buffer, (ushort)cpos.pos.x, yy, zz);
                            }
                            if (cpos.pos.x != x) {
                                if (p.Level.GetBlock(x, yy, zz) != NewType) {
                                    BufferAdd(buffer, x, yy, zz);
                                }
                            }
                        }
                    if (Math.Abs(cpos.pos.x - x) >= 2) {
                        for (xx = (ushort)(Math.Min(cpos.pos.x, x) + 1); xx <= Math.Max(cpos.pos.x, x) - 1; ++xx)
                            for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max((ushort)cpos.pos.y, y); ++yy) {
                                if (p.Level.GetBlock(xx, cpos.pos.z, yy) != NewType) {
                                    BufferAdd(buffer, xx, (ushort)cpos.pos.z, yy);
                                }
                                if (cpos.pos.z != z) {
                                    if (p.Level.GetBlock(xx, z, yy) != NewType) {
                                        BufferAdd(buffer, xx, z, yy);
                                    }
                                }
                            }
                        if (Math.Abs(cpos.pos.z - z) >= 2) {
                            for (xx = (ushort)(Math.Min(cpos.pos.x, x) + 1); xx <= Math.Max(cpos.pos.x, x) - 1; ++xx)
                                for (zz = (ushort)(Math.Min(cpos.pos.z, y) + 1); zz <= Math.Max(cpos.pos.z, y) - 1; ++zz) {
                                    if (p.Level.GetBlock(xx, zz, cpos.pos.y) != NewType) {
                                        BufferAdd(buffer, xx, zz, (ushort)cpos.pos.y);
                                    }
                                    if (cpos.pos.y != y) {
                                        if (p.Level.GetBlock(xx, zz, y) != NewType) {
                                            BufferAdd(buffer, xx, zz, y);
                                        }
                                    }
                                }
                        }
                    }
                    break;
                case SolidType.walls:
                    for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max(cpos.pos.z, z); ++zz)
                        for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max(cpos.pos.y, y); ++yy) {
                            if (p.Level.GetBlock(cpos.pos.x, zz, yy) != NewType) {
                                BufferAdd(buffer, (ushort)cpos.pos.x, zz, yy);
                            }
                            if (cpos.pos.x != x) {
                                if (p.Level.GetBlock(x, zz, yy) != NewType) {
                                    BufferAdd(buffer, x, zz, yy);
                                }
                            }
                        }
                    if (Math.Abs(cpos.pos.x - x) >= 2) {
                        if (Math.Abs(cpos.pos.y - y) >= 2) {
                            for (xx = (ushort)(Math.Min(cpos.pos.x, x) + 1); xx <= Math.Max(cpos.pos.x, x) - 1; ++xx)
                                for (zz = (ushort)(Math.Min(cpos.pos.z, z)); zz <= Math.Max(cpos.pos.z, z); ++zz) {
                                    if (p.Level.GetBlock(xx, zz, (ushort)cpos.pos.y) != NewType) {
                                        BufferAdd(buffer, xx, zz, (ushort)cpos.pos.y);
                                    }
                                    if (cpos.pos.y != y) {
                                        if (p.Level.GetBlock(xx, zz, y) != NewType) {
                                            BufferAdd(buffer, xx, zz, y);
                                        }
                                    }
                                }
                        }
                    }
                    break;
                case SolidType.holes:
                    bool Checked = true, startZ, startY;

                    for (xx = Math.Min((ushort)cpos.pos.x, x); xx <= Math.Max((ushort)cpos.pos.x, x); ++xx) {
                        startZ = Checked;
                        for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max((ushort)cpos.pos.z, z); ++zz) {
                            startY = Checked;
                            for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max((ushort)cpos.pos.y, y); ++yy) {
                                Checked = !Checked;
                                if (Checked && p.Level.GetBlock(xx, zz, yy) != NewType) {
                                    BufferAdd(buffer, xx, zz, yy);
                                }
//.........这里部分代码省略.........
开发者ID:Maicke98,项目名称:MCForge-Vanilla,代码行数:101,代码来源:CmdCuboid.cs


示例13: findNext

 public void findNext(CatchPos lookedAt, ref CatchPos pos)
开发者ID:MCSDFDBSWADZDSBL,项目名称:MCSDFDBSWADZBSBL,代码行数:1,代码来源:CmdMissile.cs


示例14: ParseCoordinates

 protected void ParseCoordinates(Player p, string[] coordinates)
 {
     CatchPos cpos = new CatchPos();
     try
     {
         cpos.pos = new Vector3S(ushort.Parse(coordinates[0]), ushort.Parse(coordinates[1]), ushort.Parse(coordinates[2]));
         cpos.secondPos = new Vector3S(ushort.Parse(coordinates[3]), ushort.Parse(coordinates[4]), ushort.Parse(coordinates[5]));
     }
     catch
     {
         p.SendMessage("Invalid coordinates!");
         return;
     }
     Cuboid(cpos, p);
 }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:15,代码来源:CmdCuboid.cs


示例15: Use

        public override void Use(Player p, string message)
        {
            wait = 0;
            string[] args = message.Split(' ');
            if (args.Length != 2)
            {
                p.SendMessage("Invail number of arguments!");
                wait = 1;
                Help(p);
                return;
            }

            CatchPos cpos = new CatchPos();
            List<string> oldType;

            oldType = new List<string>(args[0].Split(','));

            oldType = oldType.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in oldType)
                if (Block.Ushort(name) == Block.maxblocks)
                    invalid.Add(name);
            if (Block.Ushort(args[1]) == Block.maxblocks)
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid.ToArray())));
                wait = 1;
                return;
            }

            if (oldType.Contains(args[1]))
                oldType.Remove(args[1]);
            if (oldType.Count < 1)
            {
                p.SendMessage("Replacing a block with the same one would be pointless!");
                return;
            }

            cpos.oldType = new List<ushort>();
            foreach (string name in oldType)
                cpos.oldType.Add(Block.Ushort(name));
            cpos.newType = Block.Ushort(args[1]);

            foreach (byte type in cpos.oldType)
                if (!Block.canPlace(p, type) && !Block.BuildIn(type)) { p.SendMessage("Cannot replace that."); wait = 1; return; }
            if (!Block.canPlace(p, cpos.newType)) { p.SendMessage("Cannot place that."); wait = 1; return; }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:NorthPL,项目名称:MCForge-Vanilla-Redux,代码行数:54,代码来源:CmdReplace.cs


示例16: Use

 public void Use(Player p, string[] args)
 {
     //To-do
     //Broken types: Walls,
     //Hollows seems to make an error on GetBlock because of negative pos value >_>
     //Need testing for: Wire
     CatchPos cpos = new CatchPos();
     cpos.block = 255;
     ushort unused; //For the TryParse
     switch (args.Length) {
         case 0:
             Default(cpos);
             break;
         case 1: //Block or type only
             if (ValidSolidType(args[0]) || Block.ValidBlockName(args[0])) {
                 cpos = Parser(p, true, false, args, cpos);
                 break;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         case 2: //Block and type
             if (ValidSolidType(args[0 | 1]) || Block.ValidBlockName(args[0 | 1])) {
                 cpos = Parser(p, false, false, args, cpos);
                 break;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         case 6: //Coordinates
             Default(cpos);
             cpos.block = 1; //Silliness
             cpos = CoordinatesParse(p, args, cpos);
             p.SendMessage("Coordinates");
             Cuboid(cpos, cpos.block, p, (ushort)cpos.secondPos.x, (ushort)cpos.secondPos.y, (ushort)cpos.secondPos.z);
             return;
         case 7: //Coordinates and block or type
             if (ValidSolidType(args[7]) || Block.ValidBlockName(args[7])) {
                 cpos = Parser(p, true, true, args, cpos);
                 Cuboid(cpos, cpos.block, p, (ushort)cpos.secondPos.x, (ushort)cpos.secondPos.y, (ushort)cpos.secondPos.z);
                 return;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         case 8: //Coordinates block and type
             if (ValidSolidType(args[7 | 8]) || Block.ValidBlockName(args[7 | 8])) {
                 CoordinatesParse(p, args, cpos);
                 cpos = Parser(p, false, true, args, cpos);
                 Cuboid(cpos, cpos.block, p, (ushort)cpos.secondPos.x, (ushort)cpos.secondPos.y, (ushort)cpos.secondPos.z);
                 return;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         default:
             if (ushort.TryParse(args[0 | 1 | 2 | 3 | 4 | 5], out unused)) {
                 p.SendMessage("You need 6 coordinates for cuboid to work like that!");
                 return;
             }
             else
                 p.SendMessage("Invalid arguments!");
             Help(p);
             return;
     }
     p.SendMessage("Place two blocks to determine the corners.");
     p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock);
 }
开发者ID:Maicke98,项目名称:MCForge-Vanilla,代码行数:72,代码来源:CmdCuboid.cs


示例17: Use

        public void Use(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.SendMessage("Invalid number of arguments!");
                Help(p);
                return;
            }

            CatchPos cpos = new CatchPos();
            List<string> ignore;

            if (args[0].Contains(","))
                ignore = new List<string>(args[0].Split(','));
            else
                ignore = new List<string>() { args[0] };

            ignore = ignore.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in ignore)
                if (!Block.ValidBlockName(name))
                    invalid.Add(name);
            if (!Block.ValidBlockName(args[1]))
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid)));
                return;
            }

            if (ignore.Contains(args[1]))
                ignore.Remove(args[1]);
            if (ignore.Count < 1)
                p.SendMessage("Next time, just use cuboid if you're not going to ignore anything!");

            cpos.ignore = new List<byte>();
            foreach (string name in ignore)
                cpos.ignore.Add(Block.NameToBlock(name));
            cpos.newType = Block.NameToBlock(args[1]);

            p.SendMessage("Place two blocks to determine the edges.");
            p.SetDatapass(this.Name, cpos);
            p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1);
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:45,代码来源:CmdReplaceNot.cs


示例18: Use

 public void Use(Player p, string[] args)
 {
     CatchPos cpos = new CatchPos();
     if (args.Length == 1)
     {
         try
         {
             cpos.ignore = Blocks.NameToByte(args[0]);
         }
         catch
         {
             p.SendMessage("Could not find block specified");
             return;
         }
         p.SendMessage("Ignoring " + args[0]);
     }
     else
         cpos.ignore = (byte)(Blocks.Types.zero); //So it doesn't ignore air.
     p.SendMessage("Place two blocks to determine the edges.");
     p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos);
 }
开发者ID:hirsty,项目名称:MCForge-Vanilla-1,代码行数:21,代码来源:CmdMeasure.cs


示例19: FirstChange

 void FirstChange(Player p, BlockChangeEventArgs args)
 {
     CatchPos cpos = new CatchPos();
     cpos.pos = new Vector3(args.X, args.Z, args.Y);
     cpos.block = args.Holding;
     //args.Cancel();
     p.OnPlayerBlockChange.Normal -= FirstChange;
     p.setDatapass(this.Name, cpos);
 }
开发者ID:Maicke98,项目名称:MCForge-Vanilla,代码行数:9,代码来源:CmdRainbow.cs


示例20: Use

        public override void Use(Player p, string message)
        {
            int number = message.Split(' ').Length;
            CatchPos cpos = new CatchPos(); byte btype;
            if (number < 2) { Help(p); return; }

            btype = Block.Byte(message.Split(' ')[0]);
            if (btype == 255) { Player.SendMessage(p, message.Split(' ')[0] + " does not exist, please spell it correctly."); return; }

            cpos.type = btype;

            if (Block.Byte(message.Split(' ')[1]) == 255) { Player.SendMessage(p, message.Split(' ')[1] + " does not exist, please spell it correctly."); return; }

            cpos.type2 = Block.Byte(message.Split(' ')[1]);
            if (!Block.canPlace(p, cpos.type2)) { Player.SendMessage(p, "Cannot place this block type!"); return; }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
开发者ID:legorek,项目名称:MCDeamon,代码行数:21,代码来源:CmdReplaceNot.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Categories类代码示例发布时间:2022-05-24
下一篇:
C# CatchClause类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap