예제 #1
0
 public override void Use(Player p, params string[] args)
 {
     p.ClearBlockChange();
     p.BlockChangeObject = args.Length > 0 ? byte.Parse(args[0]) : (byte)0;
     p.OnBlockChange += Blockchange1;
     p.SendMessage("Place/delete a block where you want the tree.");
     //p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
예제 #2
0
        void Blockchange1(Player p, int x, int y, int z, short type)
        {
            p.ClearBlockChange();
            p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), p.level.GetMeta(x, y, z));

            p.SendMessage("Position: " + x + "," + y + "," + z);
            p.SendMessage("Type: " + p.level.GetBlock(x, y, z));
            p.SendMessage("Meta: " + p.level.GetMeta(x, y, z));
        }
예제 #3
0
        public override void Use(Player p, params string[] args)
        {
            if (args.Length < 1) { Help(p); return; }

            byte meta = 0;
            try { meta = byte.Parse(args[0]); }
            catch { p.SendMessage("Invalid input."); return; }

            if (meta < 0)
                meta = 0;
            else if (meta > 15)
                meta = 15;

            p.ClearBlockChange();
            p.BlockChangeObject = meta;
            p.OnBlockChange += Blockchange1;
            p.SendMessage("Place/delete a block to change it's meta data.");
        }
예제 #4
0
        public override void Use(Player p, params string[] args)
        {
            SpheroidData cd; cd.x = 0; cd.y = 0; cd.z = 0;
            cd.type = -1; cd.vertical = false;

            if (args.Length >= 2)
            {
                try { cd.type = Convert.ToInt16(args[0]); }
                catch { cd.type = FindBlocks.FindBlock(args[0]); }
                if (!FindBlocks.ValidBlock(cd.type)) { p.SendMessage("There is no block \"" + args[0] + "\"."); return; }

                cd.vertical = (args[1].ToLower() == "vertical");
            }
            else if (args.Length >= 1)
            {
                cd.vertical = (args[0].ToLower() == "vertical");

                if (!cd.vertical)
                {
                    try { cd.type = Convert.ToInt16(args[0]); }
                    catch { cd.type = FindBlocks.FindBlock(args[0]); }
                    if (!FindBlocks.ValidBlock(cd.type)) { p.SendMessage("There is no block \"" + args[0] + "\"."); return; }
                }
            }

            p.ClearBlockChange();
            p.BlockChangeObject = cd;
            p.OnBlockChange += Blockchange1;
            p.SendMessage("Place/delete a block at 2 corners for the spheroid.");
        }
예제 #5
0
        void Blockchange2(Player p, int x, int y, int z, short type)
        {
            p.ClearBlockChange();
            //p.SendMessage("tile: " + x + " " + y + " " + z + " " + type);
            p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), p.level.GetMeta(x, y, z));
            SpheroidData cd = (SpheroidData)p.BlockChangeObject;
            byte meta = (byte)p.inventory.current_item.meta;
            if (cd.type != -1) type = cd.type;
            if (!FindBlocks.ValidBlock(type)) type = 0;

            int sx = Math.Min(cd.x, x);
            int ex = Math.Max(cd.x, x);
            int sy = Math.Min(cd.y, y);
            int ey = Math.Max(cd.y, y);
            int sz = Math.Min(cd.z, z);
            int ez = Math.Max(cd.z, z);

            int total = 0;
            p.SendMessage("Spheroiding...");
            if (!cd.vertical)
            {
                // find center points
                double cx = (ex + sx) / 2 + (((ex + sx) % 2 == 1) ? 0.5 : 0);
                double cy = (ey + sy) / 2 + (((ey + sy) % 2 == 1) ? 0.5 : 0);
                double cz = (ez + sz) / 2 + (((ez + sz) % 2 == 1) ? 0.5 : 0);

                // find axis lengths
                double rx = Convert.ToDouble(ex) - cx + 0.25;
                double ry = Convert.ToDouble(ey) - cy + 0.25;
                double rz = Convert.ToDouble(ez) - cz + 0.25;

                double rx2 = 1 / (rx * rx);
                double ry2 = 1 / (ry * ry);
                double rz2 = 1 / (rz * rz);

                //int totalBlocks = (int)(Math.PI * 0.75 * rx * ry * rz);

                for (int xx = sx; xx <= ex; xx += 8)
                    for (int yy = sy; yy <= ey; yy += 8)
                        for (int zz = sz; zz <= ez; zz += 8)
                            for (int z3 = 0; z3 < 8 && zz + z3 <= ez; z3++)
                                for (int y3 = 0; y3 < 8 && yy + y3 <= ey; y3++)
                                    for (int x3 = 0; x3 < 8 && xx + x3 <= ex; x3++)
                                    {
                                        // get relative coordinates
                                        double dx = (xx + x3 - cx);
                                        double dy = (yy + y3 - cy);
                                        double dz = (zz + z3 - cz);

                                        // test if it's inside ellipse
                                        if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                        {
                                            p.level.BlockChange(x3 + xx, yy + y3, zz + z3, (byte)type, meta);
                                            total++;
                                        }
                                    }
            }
            else
            {
                // find center points
                double cx = (ex + sx) / 2 + (((ex + sx) % 2 == 1) ? 0.5 : 0);
                double cz = (ez + sz) / 2 + (((ez + sz) % 2 == 1) ? 0.5 : 0);

                // find axis lengths
                double rx = Convert.ToDouble(ex) - cx + 0.25;
                double rz = Convert.ToDouble(ez) - cz + 0.25;

                double rx2 = 1 / (rx * rx);
                double rz2 = 1 / (rz * rz);
                double smallrx2 = 1 / ((rx - 1) * (rx - 1));
                double smallrz2 = 1 / ((rz - 1) * (rz - 1));

                for (int xx = sx; xx <= ex; xx += 8)
                    for (int zz = sz; zz <= ez; zz += 8)
                        for (int z3 = 0; z3 < 8 && zz + z3 <= ez; z3++)
                            for (int x3 = 0; x3 < 8 && xx + x3 <= ex; x3++)
                            {
                                // get relative coordinates
                                double dx = (xx + x3 - cx);
                                double dz = (zz + z3 - cz);

                                // test if it's inside ellipse
                                if ((dx * dx) * rx2 + (dz * dz) * rz2 <= 1 && (dx * dx) * smallrx2 + (dz * dz) * smallrz2 > 1)
                                {
                                    p.level.BlockChange(x3 + xx, sy, zz + z3, (byte)type, meta);
                                    total++;
                                }
                            }
            }
            p.SendMessage(total + " blocks.");
        }
예제 #6
0
 void Blockchange1(Player p, int x, int y, int z, short type)
 {
     p.ClearBlockChange();
     //p.SendMessage("tile: " + x + " " + y + " " + z + " " + type);
     p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), p.level.GetMeta(x, y, z));
     SpheroidData cd = (SpheroidData)p.BlockChangeObject;
     cd.x = x; cd.y = y; cd.z = z;
     p.BlockChangeObject = cd;
     p.OnBlockChange += Blockchange2;
 }
예제 #7
0
 void Blockchange1(Player p, int x, int y, int z, short type)
 {
     p.ClearBlockChange();
     p.level.BlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), (byte)p.BlockChangeObject);
     p.SendMessage("Metadata set!");
 }
예제 #8
0
        public override void Use(Player p, params string[] args)
        {
            CuboidData cd; cd.x = 0; cd.y = 0; cd.z = 0;
            cd.type = -1; cd.mode = CuboidType.Solid;

            if (args.Length >= 2)
            {
                try { cd.type = Convert.ToInt16(args[0]); }
                catch { cd.type = FindBlocks.FindBlock(args[0]); }
                if (!FindBlocks.ValidBlock(cd.type)) { p.SendMessage("There is no block \"" + args[0] + "\"."); return; }

                switch (args[1].ToLower())
                {
                    case "hollow":
                        cd.mode = CuboidType.Hollow;
                        break;
                    case "walls":
                        cd.mode = CuboidType.Walls;
                        break;
                    case "holes":
                        cd.mode = CuboidType.Holes;
                        break;
                    case "wire":
                        cd.mode = CuboidType.Wire;
                        break;
                    case "random":
                        cd.mode = CuboidType.Random;
                        break;
                }
            }
            else if (args.Length >= 1)
            {
                switch (args[0].ToLower())
                {
                    case "hollow":
                        cd.mode = CuboidType.Hollow;
                        break;
                    case "walls":
                        cd.mode = CuboidType.Walls;
                        break;
                    case "holes":
                        cd.mode = CuboidType.Holes;
                        break;
                    case "wire":
                        cd.mode = CuboidType.Wire;
                        break;
                    case "random":
                        cd.mode = CuboidType.Random;
                        break;
                }

                if (cd.mode == CuboidType.Solid)
                {
                    try { cd.type = Convert.ToInt16(args[0]); }
                    catch { cd.type = FindBlocks.FindBlock(args[0]); }
                    if (!FindBlocks.ValidBlock(cd.type)) { p.SendMessage("There is no block \"" + args[0] + "\"."); return; }
                }
            }

            p.ClearBlockChange();
            p.BlockChangeObject = cd;
            p.OnBlockChange += Blockchange1;
            p.SendMessage("Place/delete a block at 2 corners for the cuboid.");
            //p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
예제 #9
0
        void Blockchange2(Player p, int x, int y, int z, short type)
        {
            p.ClearBlockChange();
            //p.SendMessage("tile: " + x + " " + y + " " + z + " " + type);
            p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), p.level.GetMeta(x, y, z));
            CuboidData cd = (CuboidData)p.BlockChangeObject;
            byte meta = (byte)p.inventory.current_item.meta;
            if (cd.type != -1) type = cd.type;
            if (!FindBlocks.ValidBlock(type)) type = 0;

            int sx = Math.Min(cd.x, x);
            int ex = Math.Max(cd.x, x);
            int sy = Math.Min(cd.y, y);
            int ey = Math.Max(cd.y, y);
            int sz = Math.Min(cd.z, z);
            int ez = Math.Max(cd.z, z);

            int total = 0;
            p.SendMessage("Cuboiding...");
            switch (cd.mode)
            {
                case CuboidType.Solid:
                    for (int xx = sx; xx <= ex; xx++)
                        for (int yy = sy; yy <= ey; yy++)
                            for (int zz = sz; zz <= ez; zz++)
                            {
                                p.level.BlockChange(xx, yy, zz, (byte)type, meta, false);
                                total++;
                            }
                    break;
                case CuboidType.Hollow:
                    for (int xx = sx; xx <= ex; xx++)
                        for (int zz = sz; zz <= ez; zz++)
                        {
                            p.level.BlockChange(xx, sy, zz, (byte)type, meta, false);
                            p.level.BlockChange(xx, ey, zz, (byte)type, meta, false);
                            total += 2;
                        }
                    for (int yy = sy; yy <= ey; yy++)
                    {
                        for (int xx = sx; xx <= ex; xx++)
                        {
                            p.level.BlockChange(xx, yy, sz, (byte)type, meta, false);
                            p.level.BlockChange(xx, yy, ez, (byte)type, meta, false);
                            total += 2;
                        }
                        for (int zz = sz; zz <= ez; zz++)
                        {
                            p.level.BlockChange(sx, yy, zz, (byte)type, meta, false);
                            p.level.BlockChange(ex, yy, zz, (byte)type, meta, false);
                            total += 2;
                        }
                    }
                    break;
                case CuboidType.Walls:
                    for (int yy = sy; yy <= ey; yy++)
                    {
                        for (int xx = sx; xx <= ex; xx++)
                        {
                            p.level.BlockChange(xx, yy, sz, (byte)type, meta, false);
                            p.level.BlockChange(xx, yy, ez, (byte)type, meta, false);
                            total += 2;
                        }
                        for (int zz = sz; zz <= ez; zz++)
                        {
                            p.level.BlockChange(sx, yy, zz, (byte)type, meta, false);
                            p.level.BlockChange(ex, yy, zz, (byte)type, meta, false);
                            total += 2;
                        }
                    }
                    break;
                case CuboidType.Holes:
                    bool Checked = true, startZ, startY;
                    for (int xx = sx; xx <= ex; xx++)
                    {
                        startY = Checked;
                        for (int yy = sy; yy <= ey; yy++)
                        {
                            startZ = Checked;
                            for (int zz = sz; zz <= ez; zz++)
                            {
                                Checked = !Checked;
                                if (Checked) { p.level.BlockChange(xx, yy, zz, (byte)type, meta, false); total++; }
                            }
                            Checked = !startZ;
                        }
                        Checked = !startY;
                    }
                    break;
                case CuboidType.Wire:
                    for (int xx = sx; xx <= ex; xx++)
                    {
                        p.level.BlockChange(xx, sy, sz, (byte)type, meta, false);
                        p.level.BlockChange(xx, sy, ez, (byte)type, meta, false);
                        p.level.BlockChange(xx, ey, sz, (byte)type, meta, false);
                        p.level.BlockChange(xx, ey, ez, (byte)type, meta, false);
                        total += 4;
                    }
                    for (int yy = sy; yy <= ey; yy++)
                    {
                        p.level.BlockChange(sx, yy, sz, (byte)type, meta, false);
                        p.level.BlockChange(sx, yy, ez, (byte)type, meta, false);
                        p.level.BlockChange(ex, yy, sz, (byte)type, meta, false);
                        p.level.BlockChange(ex, yy, ez, (byte)type, meta, false);
                        total += 4;
                    }
                    for (int zz = sz; zz <= ez; zz++)
                    {
                        p.level.BlockChange(sx, sy, zz, (byte)type, meta, false);
                        p.level.BlockChange(sx, ey, zz, (byte)type, meta, false);
                        p.level.BlockChange(ex, sy, zz, (byte)type, meta, false);
                        p.level.BlockChange(ex, ey, zz, (byte)type, meta, false);
                        total += 4;
                    }
                    break;
                case CuboidType.Random:
                    Random rand = new Random();
                    for (int xx = sx; xx <= ex; xx++)
                        for (int yy = sy; yy <= ey; yy++)
                            for (int zz = sz; zz <= ez; zz++)
                                if (rand.Next(1, 11) <= 5)
                                {
                                    p.level.BlockChange(xx, yy, zz, (byte)type, meta, false);
                                    total++;
                                }
                    break;
            }
            p.SendMessage(total + " blocks.");
        }
예제 #10
0
        void Blockchange2(Player p, int x, int y, int z, short type)
        {
            p.ClearBlockChange();
            //p.SendMessage("tile: " + x + " " + y + " " + z + " " + type);
            p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), (byte)0);
            if (p.cuboidpos.type != -1) type = p.cuboidpos.type;
            int xx1, zz1, x2, z2;
            byte y2, yy1;
            xx1 = Math.Min(p.cuboidpos.x, x);
            x2 = Math.Max(p.cuboidpos.x, x);
            yy1 = (byte)Math.Min(p.cuboidpos.y, y);
            y2 = (byte)Math.Max(p.cuboidpos.y, y);
            zz1 = Math.Min(p.cuboidpos.z, z);
            z2 = Math.Max(p.cuboidpos.z, z);
            if (type == 255 || type == -1) type = 20;
            //int total = Math.Abs(pos.x - x + 1) * Math.Abs(pos.z - z + 1) * Math.Abs(pos.y - y + 1);
            p.SendMessage("Cuboiding " + total(p.cuboidtype, xx1, x2, yy1, y2, zz1, z2) + " Blocks.");
            if (p.cuboidtype == "solid")
            {
                for (int x1 = xx1; x1 <= x2; ++x1)
                    for (byte y1 = yy1; y1 <= y2; ++y1)
                        for (int z1 = zz1; z1 <= z2; ++z1)
                            p.level.BlockChange(x1, y1, z1, (byte)type, 0);
                return;
            }

            if (p.cuboidtype == "hollow")
            {
                for (int x1 = xx1; x1 <= x2; ++x1)
                    for (int z1 = zz1; z1 <= z2; ++z1)
                    {
                        p.level.BlockChange(x1, yy1, z1, (byte)type, 0);
                        p.level.BlockChange(x1, y2, z1, (byte)type, 0);
                    }
                for (int y1 = yy1; y1 <= y2; ++y1)
                {
                    for (int z1 = zz1; z1 <= z2; ++z1)
                    {
                        p.level.BlockChange(xx1, y1, z1, (byte)type, 0);
                        p.level.BlockChange(x2, y1, z1, (byte)type, 0);
                    }
                    for (int x1 = xx1; x1 <= x2; ++x1)
                    {
                        p.level.BlockChange(x1, y1, zz1, (byte)type, 0);
                        p.level.BlockChange(x1, y1, z2, (byte)type, 0);
                    }
                }
                return;
            }
            if (p.cuboidtype == "walls")
            {
                for (int y1 = yy1; y1 <= y2; ++y1)
                {
                    for (int z1 = zz1; z1 <= z2; ++z1)
                    {
                        p.level.BlockChange(xx1, y1, z1, (byte)type, 0);
                        p.level.BlockChange(x2, y1, z1, (byte)type, 0);
                    }
                    for (int x1 = xx1; x1 <= x2; ++x1)
                    {
                        p.level.BlockChange(x1, y1, zz1, (byte)type, 0);
                        p.level.BlockChange(x1, y1, z2, (byte)type, 0);
                    }
                }
                return;
            }
            if (p.cuboidtype == "holes")
            {
                for (int x1 = xx1; x1 <= x2; x1 += 2)
                    for (byte y1 = yy1; y1 <= y2; y1 += 2)
                        for (int z1 = zz1; z1 <= z2; z1 += 2)
                            p.level.BlockChange(x1, y1, z1, (byte)type, 0);
                return;
            }
            if (p.cuboidtype == "random")
            {
                Random rand = new Random();
                for (int x1 = xx1; x1 <= x2; ++x1)
                    for (byte y1 = yy1; y1 <= y2; ++y1)
                        for (int z1 = zz1; z1 <= z2; ++z1)
                            if (rand.Next(1, 11) <= 5) p.level.BlockChange(x1, y1, z1, (byte)type, 0);
                return;
            }
            //if (p.level.GetBlock(x1, y1, z1) != type)
            //p.SendBlockChange(x1, y1, z1, type, 0);
        }
예제 #11
0
 void Blockchange1(Player p, int x, int y, int z, short type)
 {
     p.ClearBlockChange();
     //p.SendMessage("tile: " + x + " " + y + " " + z + " " + type);
     p.SendBlockChange(x, (byte)y, z, p.level.GetBlock(x, y, z), (byte)0);
     type = p.cuboidpos.type;
     p.cuboidpos = new Pos { x = x, y = y, z = z, type = type };
     p.OnBlockChange += Blockchange2;
 }
예제 #12
0
 public override void Use(Player p, params string[] args)
 {
     p.ClearBlockChange();
     p.OnBlockChange += Blockchange1;
     p.SendMessage("Place/delete a block to get info.");
 }
예제 #13
0
 void Blockchange1(Player p, int x, int y, int z, short type)
 {
     p.ClearBlockChange();
     new GenTrees().Normal(p.level, x, y, z, (byte)p.BlockChangeObject);
 }