/numberofblocks (block) - Displays number of (block)s

/numberofblocks (block) - Displays number of (block)s

Postby Leeizazombie » 29 Mar 2014, 12:07

Hey, I was using this command to debug a mini-game I'm working on, and I thought that it would also be of use for map building! or if you are playing hide the block, you can check if that block even exists in the world.

Syntax: /numberofblocks (block)
Shortcut: /nob (block)

Please be aware that if you enter an invalid block name, it will just say there is 0 of it. (I'll try update that)

Preview:
Spoiler:


Code:
Code: Select all
using System;
using System.Collections.Generic;

namespace MCDzienny
{
    public class CmdNumberOfBlocks : Command
    {
        public override string name { get { return "numberofblocks"; } }
        public override string shortcut { get { return "nob"; } }
        public override string type { get { return "build"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
        public override void Use(Player p, string message)
        {
            byte b1;
            string blockname = message.Split(' ')[0];
            b1 = Block.Byte(message.Split(' ')[0]);
            ushort x2, y2, z2; int currentBlock = 0;

            if (b1 == null)
            {
                Player.SendMessage(p, "Please enter a valid block type!");
                return;
            }

            List<MCDzienny.Level.Pos> stored = new List<MCDzienny.Level.Pos>(); MCDzienny.Level.Pos pos;

            foreach (byte b in p.level.blocks)
            {
                if (b == b1)
                {
                    p.level.IntToPos(currentBlock, out x2, out y2, out z2);
                    pos.x = x2;
                    pos.z = z2;
                    stored.Add(pos);
                }
                currentBlock++;
            }
            Player.SendMessage(p, "There is: %7" +  stored.Count.ToString() + Server.DefaultColor + " of %7" + blockname + Server.DefaultColor + " blocks in%b " + p.level.name);
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/nob (block) - Shows how many (block) is in the current level.");
        }
    }
}
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Return to Custom Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron