@Override public void onPadDestroyed() { if (!this.isDead && this.launchPhase != EnumLaunchPhase.LAUNCHED.ordinal()) { this.dropShipAsItem(); this.setDead(); } }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override public void onUpdate() { super.onUpdate(); int i; if (this.timeUntilLaunch >= 100) { i = Math.abs(this.timeUntilLaunch / 100); } else { i = 1; } if ((this.getLaunched() || this.launchPhase == EnumLaunchPhase.IGNITED.ordinal() && this.rand.nextInt(i) == 0) && !ConfigManagerCore.disableSpaceshipParticles && this.hasValidFuel()) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { this.spawnParticles(this.getLaunched()); } } if (this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal() && this.hasValidFuel()) { if (!this.landing) { double d = this.timeSinceLaunch / 150; d = Math.min(d, 1); if (d != 0.0) { this.motionY = -d * Math.cos((this.rotationPitch - 180) * Math.PI / 180.0D); } } else { this.motionY -= 0.008D; } double multiplier = 1.0D; if (this.worldObj.provider instanceof IGalacticraftWorldProvider) { multiplier = ((IGalacticraftWorldProvider) this.worldObj.provider).getFuelUsageMultiplier(); if (multiplier <= 0) { multiplier = 1; } } if (this.timeSinceLaunch % MathHelper.floor_double(3 * (1 / multiplier)) == 0) { this.removeFuel(1); if (!this.hasValidFuel()) this.stopRocketSound(); } } else if (!this.hasValidFuel() && this.getLaunched() && !this.worldObj.isRemote) { if (Math.abs(Math.sin(this.timeSinceLaunch / 1000)) / 10 != 0.0) { this.motionY -= Math.abs(Math.sin(this.timeSinceLaunch / 1000)) / 20; } } }
@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(); } }
@Override public boolean canBeTargeted(Object entity) { return this.launchPhase == EnumLaunchPhase.LAUNCHED.getPhase() && this.timeSinceLaunch > 50; }
@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(); } }