예제 #1
0
  public void createUtilsIfNeeded() {
    if (bluePrintBuilder == null) {

      if (!box.isInitialized()) {
        setBoundaries(loadDefaultBoundaries);
      }

      initializeBluePrintBuilder();
    }

    if (builderDone) {

      box.deleteLasers();

      if (arm == null) {
        createArm();
      }

      if (findTarget(false)) {
        isDigging = true;
      }

    } else {

      box.createLasers(worldObj, LaserKind.Stripes);
      isDigging = true;
    }
  }
예제 #2
0
  @Override
  public void destroy() {
    if (box.isInitialized()) {
      box.deleteLasers();
    }

    if (builderRobot != null) {
      builderRobot.setDead();
      builderRobot = null;
    }

    cleanPathLasers();
  }
예제 #3
0
  @Override
  public void destroy() {

    if (arm != null) {
      arm.setDead();
    }

    if (builder != null) {
      builder.setDead();
    }

    box.deleteLasers();
    arm = null;
  }
예제 #4
0
  @Override
  public void updateEntity() {

    super.updateEntity();

    if ((bluePrintBuilder == null || bluePrintBuilder.done)
        && box.isInitialized()
        && (builderRobot == null || builderRobot.done())) {

      box.deleteLasers();
      box.reset();

      if (CoreProxy.proxy.isSimulating(worldObj)) {
        sendNetworkUpdate();
      }

      return;
    }

    if (!box.isInitialized() && bluePrintBuilder == null && builderRobot != null) {
      builderRobot.setDead();
      builderRobot = null;
    }
  }
예제 #5
0
  public void iterateBpt() {
    if (items[0] == null || !(items[0].getItem() instanceof ItemBptBase)) {

      if (bluePrintBuilder != null) {
        bluePrintBuilder = null;
      }

      if (builderRobot != null) {
        builderRobot.setDead();
        builderRobot = null;
      }

      if (box.isInitialized()) {
        box.deleteLasers();
        box.reset();
      }

      if (currentPathIterator != null) {
        currentPathIterator = null;
      }

      return;
    }

    if (bluePrintBuilder == null || bluePrintBuilder.done) {
      if (path != null && path.size() > 1) {
        if (currentPathIterator == null) {
          Iterator<BlockIndex> it = path.iterator();
          BlockIndex start = it.next();
          currentPathIterator = new PathIterator(start, it);
        }

        if (bluePrintBuilder != null && builderRobot != null) {
          builderRobot.markEndOfBlueprint(bluePrintBuilder);
        }

        bluePrintBuilder = currentPathIterator.next();

        if (bluePrintBuilder != null) {
          box.deleteLasers();
          box.reset();
          box.initialize(bluePrintBuilder);
          box.createLasers(worldObj, LaserKind.Stripes);
        }

        if (builderRobot != null) {
          builderRobot.setBox(box);
        }

        if (bluePrintBuilder == null) {
          currentPathIterator = currentPathIterator.iterate();
        }

        if (currentPathIterator == null) {
          done = true;
        }
      } else {
        if (bluePrintBuilder != null && bluePrintBuilder.done) {
          if (builderRobot != null) {
            builderRobot.markEndOfBlueprint(bluePrintBuilder);
          }

          done = true;
          bluePrintBuilder = null;
        } else {
          bluePrintBuilder =
              instanciateBluePrint(
                  xCoord,
                  yCoord,
                  zCoord,
                  Orientations.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]
                      .reverse());

          if (bluePrintBuilder != null) {
            box.initialize(bluePrintBuilder);
            box.createLasers(worldObj, LaserKind.Stripes);
          }
        }
      }
    }
  }
예제 #6
0
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (inProcess && arm != null) {

      arm.setArmSpeed(0);
      float energyToUse = 2 + powerProvider.getEnergyStored() / 1000;

      boolean enoughStep =
          (0.015 + energyToUse / 200F)
              > (1F
                  / 32F); // (otherwise the movement is rounded to 0 and the energy absorbed with no
                          // movement)
      if (enoughStep) {
        float energy = powerProvider.useEnergy(energyToUse, energyToUse, true);

        if (energy > 0) {
          arm.doMove(0.015 + energy / 200F);
        }
      }
    }

    if (arm != null) {
      double[] head = arm.getHead();
      headPosX = head[0];
      headPosY = head[1];
      headPosZ = head[2];

      speed = arm.getArmSpeed();
    }

    if (ProxyCore.proxy.isSimulating(worldObj)) {
      sendNetworkUpdate();
    }
    if (inProcess || !isDigging) {
      return;
    }

    createUtilsIfNeeded();

    if (bluePrintBuilder != null) {

      builderDone = bluePrintBuilder.done;
      if (!builderDone) {

        buildFrame();
        return;

      } else {

        if (builder != null && builder.done()) {

          box.deleteLasers();
          builder.setDead();
          builder = null;
        }
      }
    }

    if (builder == null) {
      dig();
    }
  }