コード例 #1
0
ファイル: TileLaser.java プロジェクト: NervezXx/BuildCraft
  protected void removeLaser() {

    if (laser != null) {
      laser.setDead();
      laser = null;
    }
  }
コード例 #2
0
ファイル: TileLaser.java プロジェクト: NervezXx/BuildCraft
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (!CoreProxy.proxy.isSimulating(worldObj)) return;

    // If a gate disabled us, remove laser and do nothing.
    if (lastMode == ActionMachineControl.Mode.Off) {
      removeLaser();
      return;
    }

    // Check for available tables if none is linked to this laser.
    if (!isValidTable())
      if (canFindTable()) {
        findTable();
      }

    // If we still don't have a valid table or the existing has
    // become invalid, we disable the laser and do nothing.
    if (!isValidTable()) {
      removeLaser();
      return;
    }

    // Disable the laser and do nothing if no energy is available.
    if (powerHandler.getEnergyStored() == 0) {
      removeLaser();
      return;
    }

    // We have a table and can work, so we create a laser if
    // necessary.
    if (laser == null) {
      createLaser();
    }

    // We have a laser and may update it
    if (laser != null && canUpdateLaser()) {
      updateLaser();
    }

    // Consume power and transfer it to the table.
    float power = powerHandler.useEnergy(0, getMaxPowerSent(), true);
    laserTarget.receiveLaserEnergy(power);

    if (laser != null) {
      laser.pushPower(power);
    }

    onPowerSent(power);

    sendNetworkUpdate();
  }
コード例 #3
0
ファイル: TileLaser.java プロジェクト: NervezXx/BuildCraft
  protected void updateLaser() {

    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    double px = 0, py = 0, pz = 0;

    switch (ForgeDirection.values()[meta]) {
      case WEST:
        px = -0.3;
        break;
      case EAST:
        px = 0.3;
        break;
      case DOWN:
        py = -0.3;
        break;
      case UP:
        py = 0.3;
        break;
      case NORTH:
        pz = -0.3;
        break;
      case SOUTH:
      default:
        pz = 0.3;
        break;
    }

    Position head = new Position(xCoord + 0.5 + px, yCoord + 0.5 + py, zCoord + 0.5 + pz);
    Position tail =
        new Position(
            laserTarget.getXCoord() + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F,
            laserTarget.getYCoord() + 9F / 16F,
            laserTarget.getZCoord() + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F);

    laser.setPositions(head, tail);

    if (!laser.isVisible()) {
      laser.show();
    }
  }