Ejemplo n.º 1
0
 @Override
 public void onPadDestroyed() {
   if (!this.isDead && this.launchPhase != EnumLaunchPhase.LAUNCHED.ordinal()) {
     this.dropShipAsItem();
     this.setDead();
   }
 }
Ejemplo n.º 2
0
  @Override
  protected void failRocket() {
    if (this.shouldCancelExplosion()) {
      for (int i = -3; i <= 3; i++) {
        BlockPos pos =
            new BlockPos(
                (int) Math.floor(this.posX),
                (int) Math.floor(this.posY + i),
                (int) Math.floor(this.posZ));
        if (this.landing
            && this.targetVec != null
            && this.worldObj.getTileEntity(pos) instanceof IFuelDock
            && this.posY - this.targetVec.getY() < 5) {
          for (int x = MathHelper.floor_double(this.posX) - 1;
              x <= MathHelper.floor_double(this.posX) + 1;
              x++) {
            for (int y = MathHelper.floor_double(this.posY - 3.0D);
                y <= MathHelper.floor_double(this.posY) + 1;
                y++) {
              for (int z = MathHelper.floor_double(this.posZ) - 1;
                  z <= MathHelper.floor_double(this.posZ) + 1;
                  z++) {
                BlockPos pos1 = new BlockPos(x, y, z);
                TileEntity tile = this.worldObj.getTileEntity(pos1);

                if (tile instanceof IFuelDock) {
                  this.landEntity(pos1);
                  return;
                }
              }
            }
          }
        }
      }
    }

    if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal()) {
      super.failRocket();
    }
  }
Ejemplo n.º 3
0
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (!this.worldObj.isRemote) {
      if (this.statusMessageCooldown > 0) {
        this.statusMessageCooldown--;
      }

      if (this.statusMessageCooldown == 0
          && this.lastStatusMessageCooldown > 0
          && this.statusValid) {
        this.autoLaunch();
      }

      if (this.autoLaunchCountdown > 0
          && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
        this.autoLaunchCountdown--;

        if (this.autoLaunchCountdown <= 0) {
          this.autoLaunch();
        }
      }

      if (this.autoLaunchSetting == EnumAutoLaunch.ROCKET_IS_FUELED
          && this.fuelTank.getFluidAmount() == this.fuelTank.getCapacity()
          && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
        this.autoLaunch();
      }

      if (this.autoLaunchSetting == EnumAutoLaunch.INSTANT) {
        if (this.autoLaunchCountdown == 0
            && (!(this instanceof EntityTieredRocket) || this.riddenByEntity != null)) {
          this.autoLaunch();
        }
      }

      if (this.autoLaunchSetting == EnumAutoLaunch.REDSTONE_SIGNAL) {
        if (this.ticks % 25 == 0) {
          if (this.getLandingPad() != null && this.getLandingPad().getConnectedTiles() != null) {
            for (ILandingPadAttachable tile : this.getLandingPad().getConnectedTiles()) {
              if (this.worldObj.getTileEntity(((TileEntity) tile).getPos()) != null) {
                try {
                  Class<?> controllerClass =
                      Class.forName(
                          "micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController");

                  try {
                    controllerClass.cast(this.worldObj.getTileEntity(((TileEntity) tile).getPos()));
                  } catch (ClassCastException e) {
                    continue;
                  }

                  if (this.worldObj.isBlockIndirectlyGettingPowered(((TileEntity) tile).getPos())
                      > 0) {
                    this.autoLaunch();
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          }
        }
      }

      if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal() && this.hasValidFuel()) {
        if (this.landing
            && this.targetVec != null
            && this.worldObj.getTileEntity(this.targetVec) instanceof IFuelDock) {
          this.motionY =
              Math.max(
                  -2.0F,
                  (this.posY - this.getOnPadYOffset() - 0.4D - this.targetVec.getY()) / -70.0D);

          if (this.getEntityBoundingBox().minY - this.targetVec.getY() < 0.5F) {
            for (int x = MathHelper.floor_double(this.posX) - 1;
                x <= MathHelper.floor_double(this.posX) + 1;
                x++) {
              for (int y =
                      MathHelper.floor_double(
                              this.getEntityBoundingBox().minY - this.getOnPadYOffset() - 0.45D)
                          - 1;
                  y <= MathHelper.floor_double(this.getEntityBoundingBox().maxY) + 1;
                  y++) {
                for (int z = MathHelper.floor_double(this.posZ) - 1;
                    z <= MathHelper.floor_double(this.posZ) + 1;
                    z++) {
                  TileEntity tile = this.worldObj.getTileEntity(new BlockPos(x, y, z));

                  if (tile instanceof IFuelDock) {
                    this.failRocket();
                  }
                }
              }
            }
          }
        }
      }

      if (this.getLandingPad() != null && this.getLandingPad().getConnectedTiles() != null) {
        for (ILandingPadAttachable tile : this.getLandingPad().getConnectedTiles()) {
          if (this.worldObj.getTileEntity(((TileEntity) tile).getPos()) != null
              && this.worldObj.getTileEntity(((TileEntity) tile).getPos())
                  instanceof TileEntityFuelLoader) {
            if (tile instanceof TileEntityFuelLoader
                && ((TileEntityFuelLoader) tile).getEnergyStoredGC() > 0) {
              if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal()) {
                this.setPad(null);
              }
            }
          }
        }
      }

      this.lastStatusMessageCooldown = this.statusMessageCooldown;
    }

    if (this.launchPhase == EnumLaunchPhase.IGNITED.ordinal() || this.getLaunched()) {
      if (this.rocketSoundUpdater != null) {
        this.rocketSoundUpdater.update();
        this.rocketSoundToStop = true;
      }
    } else {
      // Not ignited - either because not yet launched, or because it has landed
      if (this.rocketSoundToStop) this.stopRocketSound();
    }
  }