예제 #1
0
  public void startScan(boolean start) {
    if (!worldObj.isRemote) {
      if (!start) {
        scanning.setValue(false);
        notifyBlockUpdate();
        return;
      }

      int r = radius.getValue();
      // Only on server
      int y1 = yCoord - r;
      if (y1 < 0) {
        y1 = 0;
      }
      c1.setCoordinate(new Coordinate(xCoord - r, y1, zCoord - r));
      int y2 = yCoord + r;
      if (y2 >= worldObj.getHeight()) {
        y2 = worldObj.getHeight() - 1;
      }
      c2.setCoordinate(new Coordinate(xCoord + r, y2, zCoord + r));

      scanning.setValue(true);
      cur.setCoordinate(c1.getCoordinate());

      inventories.clear();
      notifyBlockUpdate();
    }
  }
예제 #2
0
 // Advance the 'cur' index to the next block. Return false when done.
 // When done 'scanning' will be set to false as well.
 private boolean advanceCurrent() {
   Coordinate c = cur.getCoordinate();
   int cx = c.getX();
   int cy = c.getY();
   int cz = c.getZ();
   cx++;
   Coordinate lo = c1.getCoordinate();
   Coordinate up = c2.getCoordinate();
   if (cx > up.getX()) {
     cx = lo.getX();
     cy++;
     if (cy > up.getY()) {
       cy = lo.getY();
       cz++;
       if (cz > up.getZ()) {
         scanning.setValue(false);
         notifyBlockUpdate();
         return false;
       }
     }
   }
   cur.setCoordinate(new Coordinate(cx, cy, cz));
   notifyBlockUpdate();
   return true;
 }
예제 #3
0
 @Override
 public void writeToNBT(NBTTagCompound tagCompound) {
   super.writeToNBT(tagCompound);
   tagCompound.setBoolean("scanning", scanning.getValue());
   c1.writeToNBT(tagCompound, "c1");
   c2.writeToNBT(tagCompound, "c2");
   cur.writeToNBT(tagCompound, "cur");
   inventories.writeToNBT(tagCompound, "inv");
 }
예제 #4
0
 @Override
 public void readFromNBT(NBTTagCompound tagCompound) {
   super.readFromNBT(tagCompound);
   scanning.setValue(tagCompound.getBoolean("scanning"));
   c1.readFromNBT(tagCompound, "c1");
   c2.readFromNBT(tagCompound, "c2");
   cur.readFromNBT(tagCompound, "cur");
   inventories.readFromNBT(tagCompound, "inv");
 }
예제 #5
0
  @Override
  protected void checkStateServer() {
    super.checkStateServer();
    if (scanning.getValue()) {
      int rf = StorageScannerConfiguration.rfPerOperation;
      rf = (int) (rf * (2.0f - getInfusedFactor()) / 2.0f);

      if (getEnergyStored(ForgeDirection.DOWN) < rf) {
        return;
      }
      consumeEnergy(rf);

      int scans = StorageScannerConfiguration.scansPerOperation;

      scans = scans * (int) (getInfusedFactor() + 1.01f);

      for (int i = 0; i < scans; i++) {
        Coordinate c = cur.getCoordinate();
        checkInventoryStatus(c.getX(), c.getY(), c.getZ());
        if (!advanceCurrent()) {
          return;
        }
      }
    }
  }
예제 #6
0
 public int getProgress() {
   int z1 = c1.getCoordinate().getZ();
   int z2 = c2.getCoordinate().getZ();
   int z = cur.getCoordinate().getZ();
   return (z - z1) * 100 / (z2 - z1);
 }