示例#1
0
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (worldObj.isRemote) {
      return;
    }

    if ((currentBuilder == null || currentBuilder.isDone(this)) && box.isInitialized()) {
      box.reset();

      sendNetworkUpdate();

      return;
    }

    iterateBpt(false);

    if (mode != Mode.Off) {
      if (getWorldObj().getWorldInfo().getGameType() == GameType.CREATIVE) {
        build();
      } else if (getBattery().getEnergyStored() > POWER_ACTIVATION) {
        build();
      }
    }

    if (!isBuilding && this.isBuildingBlueprint()) {
      updateRequirements();
    }
    isBuilding = this.isBuildingBlueprint();

    if (done) {
      return;
    } else if (getBattery().getEnergyStored() < 25) {
      return;
    }
  }
示例#2
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;
    }
  }
示例#3
0
 public Box() {
   reset();
 }
示例#4
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);
          }
        }
      }
    }
  }
示例#5
0
  public void iterateBpt(boolean forceIterate) {
    if (getStackInSlot(0) == null || !(getStackInSlot(0).getItem() instanceof ItemBlueprint)) {
      if (box.isInitialized()) {
        if (currentBuilder != null) {
          currentBuilder = null;
        }

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

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

        updateRequirements();

        sendNetworkUpdate();

        return;
      }
    }

    if (currentBuilder == null || (currentBuilder.isDone(this) || forceIterate)) {
      if (path != null && path.size() > 1) {
        if (currentPathIterator == null) {
          Iterator<BlockIndex> it = path.iterator();
          BlockIndex start = it.next();
          currentPathIterator =
              new PathIterator(
                  start,
                  it,
                  ForgeDirection.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]
                      .getOpposite());
        }

        if (currentBuilder != null && currentBuilder.isDone(this)) {
          currentBuilder.postProcessing(worldObj);
        }

        currentBuilder = currentPathIterator.next();

        if (currentBuilder != null) {
          box.reset();
          box.initialize(currentBuilder);
          sendNetworkUpdate();
        }

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

        if (currentPathIterator == null) {
          done = true;
        } else {
          done = false;
        }

        updateRequirements();
      } else {
        if (currentBuilder != null && currentBuilder.isDone(this)) {
          currentBuilder.postProcessing(worldObj);
          currentBuilder = recursiveBuilder.nextBuilder();

          updateRequirements();
        } else {
          BlueprintBase bpt = instanciateBlueprint();

          if (bpt != null) {
            recursiveBuilder =
                new RecursiveBlueprintBuilder(
                    bpt,
                    worldObj,
                    xCoord,
                    yCoord,
                    zCoord,
                    ForgeDirection.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]
                        .getOpposite());

            currentBuilder = recursiveBuilder.nextBuilder();

            updateRequirements();
          }
        }

        if (currentBuilder == null) {
          done = true;
        } else {
          box.initialize(currentBuilder);
          sendNetworkUpdate();
          done = false;
        }
      }
    }

    if (done && getStackInSlot(0) != null) {
      boolean dropBlueprint = true;
      for (int i = 1; i < getSizeInventory(); ++i) {
        if (getStackInSlot(i) == null) {
          setInventorySlotContents(i, getStackInSlot(0));
          dropBlueprint = false;
          break;
        }
      }
      if (dropBlueprint) {
        InvUtils.dropItems(getWorldObj(), getStackInSlot(0), xCoord, yCoord, zCoord);
      }

      setInventorySlotContents(0, null);
      box.reset();
    }
  }