use of micdoodle8.mods.galacticraft.api.world.IExitHeight in project Galacticraft by micdoodle8.
the class EntitySpaceshipBase method onUpdate.
@Override
public void onUpdate() {
this.ticks++;
super.onUpdate();
if (this.addToTelemetry) {
this.addToTelemetry = false;
for (BlockVec3Dim vec : new ArrayList<BlockVec3Dim>(this.telemetryList)) {
TileEntity t1 = vec.getTileEntityNoLoad();
if (t1 instanceof TileEntityTelemetry && !t1.isInvalid()) {
if (((TileEntityTelemetry) t1).linkedEntity == this)
((TileEntityTelemetry) t1).addTrackedEntity(this);
}
}
}
if (this.riddenByEntity != null) {
this.riddenByEntity.fallDistance = 0.0F;
}
if (this.posY > (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) && this.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
this.onReachAtmosphere();
// if (this.worldObj.isRemote)
// this.posY = 1 + (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200);
}
if (this.rollAmplitude > 0) {
this.rollAmplitude--;
}
if (this.shipDamage > 0) {
this.shipDamage--;
}
if (!this.worldObj.isRemote) {
if (this.posY < 0.0D) {
this.setDead();
} else if (this.posY > (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) + (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() ? 355 : 100)) {
if (this.riddenByEntity instanceof EntityPlayerMP) {
GCPlayerStats stats = GCPlayerStats.get(this.riddenByEntity);
if (stats.isUsingPlanetSelectionGui()) {
this.setDead();
}
} else
this.setDead();
}
if (this.timeSinceLaunch > 50 && this.onGround) {
this.failRocket();
}
}
if (this.launchPhase == EnumLaunchPhase.UNIGNITED.ordinal()) {
this.timeUntilLaunch = this.getPreLaunchWait();
}
if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
this.timeSinceLaunch++;
} else {
this.timeSinceLaunch = 0;
}
if (this.timeUntilLaunch > 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
this.timeUntilLaunch--;
}
AxisAlignedBB box = null;
box = this.getEntityBoundingBox().expand(0.2D, 0.2D, 0.2D);
final List<?> var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box);
if (var15 != null && !var15.isEmpty()) {
for (int var52 = 0; var52 < var15.size(); ++var52) {
final Entity var17 = (Entity) var15.get(var52);
if (var17 != this.riddenByEntity) {
var17.applyEntityCollision(this);
}
}
}
if (this.timeUntilLaunch == 0 && this.launchPhase == EnumLaunchPhase.IGNITED.ordinal()) {
this.setLaunchPhase(EnumLaunchPhase.LAUNCHED);
this.onLaunch();
}
if (this.rotationPitch > 90) {
this.rotationPitch = 90;
}
if (this.rotationPitch < -90) {
this.rotationPitch = -90;
}
this.motionX = -(50 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
this.motionZ = -(50 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * Math.sin(this.rotationPitch * 0.01 / Constants.RADIANS_TO_DEGREES_D));
if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal()) {
this.motionX = this.motionY = this.motionZ = 0.0F;
}
if (this.worldObj.isRemote) {
this.setPosition(this.posX, this.posY, this.posZ);
if (this.shouldMoveClientSide()) {
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
} else {
this.moveEntity(this.motionX, this.motionY, this.motionZ);
}
this.setRotation(this.rotationYaw, this.rotationPitch);
if (this.worldObj.isRemote) {
this.setPosition(this.posX, this.posY, this.posZ);
}
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (!this.worldObj.isRemote && this.ticks % 3 == 0) {
GalacticraftCore.packetPipeline.sendToDimension(new PacketDynamic(this), this.worldObj.provider.getDimensionId());
// PacketDispatcher.sendPacketToAllInDimension(GCCorePacketManager.getPacket(GalacticraftCore.CHANNELENTITIES,
// this, this.getNetworkedData(new ArrayList())),
// this.worldObj.provider.getDimensionId());
}
}
use of micdoodle8.mods.galacticraft.api.world.IExitHeight in project Galacticraft by micdoodle8.
the class EntityTieredRocket method onReachAtmosphere.
@Override
public void onReachAtmosphere() {
// Launch controlled
if (this.destinationFrequency != -1) {
if (this.worldObj.isRemote) {
// stop the sounds on the client - but do not reset, the rocket may start again
this.stopRocketSound();
return;
}
this.setTarget(true, this.destinationFrequency);
if (this.targetVec != null) {
if (this.targetDimension != this.worldObj.provider.getDimensionId()) {
WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension);
if (targetDim != null && targetDim.worldObj instanceof WorldServer) {
boolean dimensionAllowed = this.targetDimension == ConfigManagerCore.idDimensionOverworld;
if (targetDim instanceof IGalacticraftWorldProvider) {
if (((IGalacticraftWorldProvider) targetDim).canSpaceshipTierPass(this.getRocketTier()))
dimensionAllowed = true;
else
dimensionAllowed = false;
} else // No rocket flight to non-Galacticraft dimensions other than the Overworld allowed unless config
if ((this.targetDimension > 1 || this.targetDimension < -1) && marsConfigAllDimsAllowed != null) {
try {
if (marsConfigAllDimsAllowed.getBoolean(null)) {
dimensionAllowed = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (dimensionAllowed) {
if (this.riddenByEntity != null) {
WorldUtil.transferEntityToDimension(this.riddenByEntity, this.targetDimension, (WorldServer) targetDim.worldObj, false, this);
} else {
Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, (WorldServer) targetDim.worldObj, false, null);
if (e instanceof EntityAutoRocket) {
e.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5f);
((EntityAutoRocket) e).setLaunchPhase(EnumLaunchPhase.LANDING);
((EntityAutoRocket) e).setWaitForPlayer(false);
} else {
GCLog.info("Error: failed to recreate the unmanned rocket in landing mode on target planet.");
e.setDead();
this.setDead();
}
}
return;
}
}
// No destination world found - in this situation continue into regular take-off (as if Not launch controlled)
} else {
// Same dimension controlled rocket flight
this.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
// Stop any lateral motion, otherwise it will update to an incorrect x,z position first tick after spawning above target
this.motionX = this.motionZ = 0.0D;
// Small upward motion initially, to keep clear of own flame trail from launch
this.motionY = 0.1D;
if (this.riddenByEntity != null) {
WorldUtil.forceMoveEntityToPos(this.riddenByEntity, (WorldServer) this.worldObj, new Vector3(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F), false);
this.setWaitForPlayer(true);
GCLog.debug("Rocket repositioned, waiting for player");
}
this.setLaunchPhase(EnumLaunchPhase.LANDING);
// Do not destroy the rocket, we still need it!
return;
}
} else {
// Launch controlled launch but no valid target frequency = rocket loss [INVESTIGATE]
GCLog.info("Error: the launch controlled rocket failed to find a valid landing spot when it reached space.");
this.fuelTank.drain(Integer.MAX_VALUE, true);
this.posY = Math.max(255, (this.worldObj.provider instanceof IExitHeight ? ((IExitHeight) this.worldObj.provider).getYCoordinateToTeleport() : 1200) - 200);
return;
}
}
// Not launch controlled
if (!this.worldObj.isRemote) {
if (this.riddenByEntity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) this.riddenByEntity;
this.onTeleport(player);
GCPlayerStats stats = GCPlayerStats.get(player);
WorldUtil.toCelestialSelection(player, stats, this.getRocketTier());
}
// Destroy any rocket which reached the top of the atmosphere and is not controlled by a Launch Controller
this.setDead();
}
// Client side, non-launch controlled, do nothing - no reason why it can't continue flying until the GUICelestialSelection activates
}
Aggregations