Beispiel #1
0
        bool CheckBlock(Player p, string value, string variable, ref byte modify)
        {
            byte extBlock = 0;
            byte block    = DrawCmd.GetBlock(p, value, out extBlock, false);

            if (block == Block.Zero)
            {
                return(false);
            }
            if (block >= Block.CpeCount && block != Block.custom_block)
            {
                p.SendMessage("Cannot use physics block ids for /env."); return(false);
            }

            if (block == Block.shrub || block == Block.yellowflower || block == Block.redflower ||
                block == Block.mushroom || block == Block.redmushroom || block == Block.rope || block == Block.fire)
            {
                p.SendMessage(string.Format("Env: Cannot use {0} for {1}.", block, variable));
            }
            else
            {
                modify = block == Block.custom_block ? extBlock : block;
                p.SendMessage(string.Format("Set {0} for {1}&S to {2}", variable, p.level.name, modify));
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            type = type < 128 ? p.bindings[type] : type;

            string[] parts = cpos.message.Split(trimChars, 3);
            if (parts.Length < 2)
            {
                Help(p); return;
            }

            byte extTile = 0;
            byte tile    = DrawCmd.GetBlock(p, parts[0], out extTile);

            if (tile == Block.Zero)
            {
                return;
            }
            string brushName = CmdBrush.FindBrush(parts[1]);

            if (brushName == null)
            {
                Player.SendMessage(p, "No brush found with name \"" + parts[1] + "\".");
                Player.SendMessage(p, "Available brushes: " + CmdBrush.AvailableBrushes);
                return;
            }

            string    brushMessage = parts.Length > 2 ? parts[2].ToLower() : "";
            BrushArgs args         = new BrushArgs(p, brushMessage, type, extType);
            Brush     brush        = Brush.Brushes[brushName](args);

            if (brush == null)
            {
                return;
            }

            DrawOp drawOp = null;

            if (ReplaceNot)
            {
                drawOp = new ReplaceNotDrawOp(tile, extTile);
            }
            else
            {
                drawOp = new ReplaceDrawOp(tile, extTile);
            }

            if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
            {
                return;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Beispiel #3
0
        public override void Use(Player p, string message)
        {
            byte   type = Block.Zero, extType = 0;
            ushort x = (ushort)(p.pos[0] / 32);
            ushort y = (ushort)((p.pos[1] / 32) - 1);
            ushort z = (ushort)(p.pos[2] / 32);

            try {
                string[] parts = message.Split(' ');
                switch (parts.Length)
                {
                case 1: type = message == "" ? Block.rock :
                               DrawCmd.GetBlock(p, parts[0], out extType); break;

                case 3:
                    type = Block.rock;
                    x    = Convert.ToUInt16(parts[0]);
                    y    = Convert.ToUInt16(parts[1]);
                    z    = Convert.ToUInt16(parts[2]);
                    break;

                case 4:
                    type = DrawCmd.GetBlock(p, parts[0], out extType);
                    x    = Convert.ToUInt16(parts[1]);
                    y    = Convert.ToUInt16(parts[2]);
                    z    = Convert.ToUInt16(parts[3]);
                    break;

                default: Player.SendMessage(p, "Invalid number of parameters"); return;
                }
            } catch {
                Player.SendMessage(p, "Invalid parameters"); return;
            }

            if (type == Block.Zero)
            {
                return;
            }
            if (!Block.canPlace(p, type))
            {
                Player.SendMessage(p, "Cannot place that block type."); return;
            }
            Vec3U16 P = Vec3U16.ClampToBounds(x, y, z, p.level);

            p.level.UpdateBlock(p, P.X, P.Y, P.Z, type, extType);
            Player.SendMessage(p, "A block was placed at (" + P.X + ", " + P.Y + ", " + P.Z + ").");
        }