示例#1
0
        public override bool ApplyToolBuild(WorldEdit worldEdit, Block block, BlockPos pos, ushort oldBlockId, BlockFacing onBlockFace, Vec3f hitPos, bool didOffset)
        {
            if (heights == null)
            {
                return(false);
            }

            worldEdit.Good("Ok, placing blocks, this may take a while");

            int      width  = heights.GetLength(0);
            int      length = heights.GetLength(1);
            BlockPos tmpPos = new BlockPos();

            IBlockAccessor blockAccessorBulk = worldEdit.sapi.World.BulkBlockAccessor;

            for (int x = 0; x < width; x++)
            {
                for (int z = 0; z < length; z++)
                {
                    int height = heights[x, z];

                    tmpPos.Set(pos.X + x - width / 2, pos.Y, pos.Z + z - length / 2);

                    for (int y = 0; y < height; y++)
                    {
                        blockAccessorBulk.SetBlock(block.BlockId, tmpPos);
                        tmpPos.Up();
                    }
                }
            }

            blockAccessorBulk.Commit();

            return(false);
        }
示例#2
0
        public override bool OnWorldEditCommand(WorldEdit worldEdit, CmdArgs args)
        {
            switch (args[0])
            {
            case "ims":
                if (args.Length <= 1)
                {
                    worldEdit.Bad("Please specify a filename");
                    return(true);
                }

                TryLoadHeightMap(worldEdit, args[1]);
                return(true);
            }

            return(false);
        }
        public bool OnExecute(CommandSender sender, string command, string[] args)
        {
            if (args.Length < 2)
            {
                sender.SendMessage("/edit set [id...]");
                return false;
            }

            Player player = (Player)sender;
            World world = player.World;

            WorldEdit edit = WorldEdit.Instance;
            PositionData data = edit.PositionManager.getPositionData(player.Name);

            RandomBlockSelector selector = new RandomBlockSelector(args[1]);
            Tuple<Vector3, Vector3> tuple = data.GetSortPosition();
            Vector3 pos1 = tuple.Item1;
            Vector3 pos2 = tuple.Item2;

            Stopwatch sw = new Stopwatch();
            sw.Start();
            int count = 0;

            for (int x = pos1.FloorX; x <= pos2.FloorX; ++x)
            {
                for (int y = pos1.FloorY; y <= pos2.FloorY; ++y)
                {
                    for (int z = pos1.FloorZ; z <= pos2.FloorZ; ++z)
                    {
                        world.SetBlock(new Vector3(x, y, z), selector.GetBlock());
                        count++;
                    }
                }
            }

            sw.Stop();
            TimeSpan ts = sw.Elapsed;
            player.SendMessage($"§b{count}ブロックの設置完了 {ts.Seconds}.{ts.Milliseconds}秒");
            return true;
        }
示例#4
0
        public void TryLoadHeightMap(WorldEdit worldEdit, string filename)
        {
            string folderPath = worldEdit.sapi.GetOrCreateDataPath("Heightmaps");
            string filePath   = Path.Combine(folderPath, filename);

            if (!File.Exists(filePath))
            {
                worldEdit.Bad("No such file found.");
                return;
            }

            Bitmap bmp = null;

            try
            {
                bmp = new Bitmap(filePath);
            } catch (Exception e)
            {
                worldEdit.Bad("Unable to load {0}: {1}", filePath, e);
                return;
            }

            heights = new int[bmp.Width, bmp.Height];

            for (int x = 0; x < bmp.Width; x++)
            {
                for (int y = 0; y < bmp.Height; y++)
                {
                    heights[x, y] = bmp.GetPixel(x, y).R;
                }
            }

            worldEdit.Good("Ok, loaded {0}x{1} image", bmp.Width, bmp.Height);

            bmp.Dispose();
        }
示例#5
0
 public Wand(WorldEdit plugin)
 {
     Plugin = plugin;
 }
示例#6
0
 public Set(WorldEdit plugin)
 {
     Plugin = plugin;
 }
示例#7
0
 public Pos1(WorldEdit plugin)
 {
     Plugin = plugin;
 }