示例#1
0
 public boolean setBlock(int x, int y, int z, int id, int data, CompoundTag nbt) {
   if (nbt != null) {
     MainUtil.setPosition(nbt, x, y, z);
     setTile(x, y, z, nbt);
   }
   return setBlock(x, y, z, id, data);
 }
示例#2
0
 public void saveMemory() {
   MainUtil.sendAdmin(BBC.OOM.s());
   // Set memory limited
   MemUtil.memoryLimitedTask();
   // Clear block placement
   clear();
   Fawe.get().getWorldEdit().clearSessions();
   // GC
   System.gc();
   System.gc();
   // Unload chunks
 }
示例#3
0
 public void runTasks() {
   synchronized (this) {
     this.notifyAll();
   }
   if (getProgressTask() != null) {
     try {
       getProgressTask().run(ProgressType.DONE, 1);
     } catch (Throwable e) {
       e.printStackTrace();
     }
   }
   while (!tasks.isEmpty()) {
     Runnable task = tasks.poll();
     if (task != null) {
       try {
         task.run();
       } catch (Throwable e) {
         MainUtil.handleError(e);
       }
     }
   }
 }
  @Command(
      aliases = {"/set"},
      usage = "[pattern]",
      desc = "Set all blocks within selection",
      min = 1,
      max = 1)
  @CommandPermissions("worldedit.region.set")
  @Logging(REGION)
  public void set(
      Player player,
      EditSession editSession,
      LocalSession session,
      @Selection Region selection,
      Pattern to)
      throws WorldEditException {
    if (selection instanceof CuboidRegion
        && editSession.hasFastMode()
        && to instanceof BlockPattern) {
      try {
        CuboidRegion cuboid = (CuboidRegion) selection;
        RegionWrapper current =
            new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
        BaseBlock block = ((BlockPattern) to).getBlock();
        final FaweQueue queue = editSession.getQueue();
        final int minY = cuboid.getMinimumY();
        final int maxY = cuboid.getMaximumY();

        final int id = block.getId();
        final byte data = (byte) block.getData();
        final FaweChunk<?> fc = queue.getFaweChunk(0, 0);
        fc.fillCuboid(0, 15, minY, maxY, 0, 15, id, data);
        fc.optimize();

        int bcx = (current.minX) >> 4;
        int bcz = (current.minZ) >> 4;

        int tcx = (current.maxX) >> 4;
        int tcz = (current.maxZ) >> 4;
        // [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
        MainUtil.chunkTaskSync(
            current,
            new RunnableVal<int[]>() {
              @Override
              public void run(int[] value) {
                FaweChunk newChunk;
                if (value[6] == 0) {
                  newChunk = fc.copy(true);
                  newChunk.setLoc(queue, value[0], value[1]);
                } else {
                  int bx = value[2] & 15;
                  int tx = value[4] & 15;
                  int bz = value[3] & 15;
                  int tz = value[5] & 15;
                  if (bx == 0 && tx == 15 && bz == 0 && tz == 15) {
                    newChunk = fc.copy(true);
                    newChunk.setLoc(queue, value[0], value[1]);
                  } else {
                    newChunk = queue.getFaweChunk(value[0], value[1]);
                    newChunk.fillCuboid(
                        value[2] & 15,
                        value[4] & 15,
                        minY,
                        maxY,
                        value[3] & 15,
                        value[5] & 15,
                        id,
                        data);
                  }
                }
                newChunk.addToQueue();
              }
            });
        queue.enqueue();
        long start = System.currentTimeMillis();
        BBC.OPERATION.send(player, BBC.VISITOR_BLOCK.format(cuboid.getArea()));
        queue.flush();
        BBC.ACTION_COMPLETE.send(player, (System.currentTimeMillis() - start) / 1000d);
        return;
      } catch (Throwable e) {
        MainUtil.handleError(e);
      }
    }
    int affected = editSession.setBlocks(selection, Patterns.wrap(to));
    BBC.OPERATION.send(player, affected);
  }