public override void Use(Player p, string message) { if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } if (message.CaselessEq("all")) { if (!p.HasBlockchange) { Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return; } Level lvl = p.level; PlaceMark(p, 0, 0, 0); PlaceMark(p, lvl.Width - 1, lvl.Height - 1, lvl.Length - 1); return; } // convert player pos to block coords Vec3U16 P = Vec3U16.ClampPos(p.pos[0], (ushort)(p.pos[1] - 32), p.pos[2], p.level); P.X /= 32; P.Y /= 32; P.Z /= 32; if (message != "" && !ParseCoords(message, p, ref P)) { return; } P = Vec3U16.Clamp(P.X, P.Y, P.Z, p.level); if (p.HasBlockchange) { PlaceMark(p, P.X, P.Y, P.Z); } else { // We only want to activate blocks in the world byte old = p.level.GetTile(P.X, P.Y, P.Z); if (!p.CheckManualChange(old, Block.air, false)) { return; } HandleDelete handler = BlockBehaviour.deleteHandlers[old]; if (handler != null) { handler(p, old, P.X, P.Y, P.Z); } else { Player.Message(p, "Cannot mark, no selection or cuboid in progress, " + "nor could the existing block at the coordinates be activated."); return; } } }
public override void Use(Player p, string message) { byte ext = 0; int block = p.GetActualHeldBlock(out ext); ushort x = p.pos[0], y = (ushort)(p.pos[1] - 32), z = p.pos[2]; try { string[] parts = message.Split(' '); switch (parts.Length) { case 1: block = message == "" ? block : DrawCmd.GetBlockIfAllowed(p, parts[0], out ext); break; case 3: x = (ushort)(ushort.Parse(parts[0]) * 32); y = (ushort)(ushort.Parse(parts[1]) * 32); z = (ushort)(ushort.Parse(parts[2]) * 32); break; case 4: block = DrawCmd.GetBlockIfAllowed(p, parts[0], out ext); x = (ushort)(ushort.Parse(parts[1]) * 32); y = (ushort)(ushort.Parse(parts[2]) * 32); z = (ushort)(ushort.Parse(parts[3]) * 32); break; default: Player.Message(p, "Invalid number of parameters"); return; } } catch { Player.Message(p, "Invalid parameters"); return; } if (block == -1 || block == Block.Invalid) return; if (!Block.canPlace(p, (byte)block)) { Formatter.MessageBlock(p, "place ", (byte)block); return; } Vec3U16 P = Vec3U16.ClampPos(x, y, z, p.level); P.X /= 32; P.Y /= 32; P.Z /= 32; p.level.UpdateBlock(p, P.X, P.Y, P.Z, (byte)block, ext, BlockDBFlags.ManualPlace); string blockName = p.level.BlockName((byte)block, ext); Player.Message(p, "{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName); }