use of micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable in project Galacticraft by micdoodle8.
the class EntityAutoRocket method updateControllerSettings.
public void updateControllerSettings(IFuelDock dock) {
HashSet<ILandingPadAttachable> connectedTiles = dock.getConnectedTiles();
try {
for (ILandingPadAttachable updatedTile : connectedTiles) {
if (controllerClass.isInstance(updatedTile)) {
// This includes a check for whether it has enough energy to run (if it doesn't, then a launch would not go to the destination frequency and the rocket would be lost!)
Boolean autoLaunchEnabled = controllerClass.getField("controlEnabled").getBoolean(updatedTile);
this.activeLaunchController = new BlockVec3((TileEntity) updatedTile);
if (autoLaunchEnabled) {
this.autoLaunchSetting = EnumAutoLaunch.values()[controllerClass.getField("launchDropdownSelection").getInt(updatedTile)];
switch(this.autoLaunchSetting) {
case INSTANT:
// Small countdown to give player a moment to exit the Launch Controller GUI
if (this.autoLaunchCountdown <= 0 || this.autoLaunchCountdown > 12)
this.autoLaunchCountdown = 12;
break;
// TODO: if autoLaunchCountdown > 0 add some smoke (but not flame) particle effects or other pre-flight test feedback so the player knows something is happening
case TIME_10_SECONDS:
if (this.autoLaunchCountdown <= 0 || this.autoLaunchCountdown > 200)
this.autoLaunchCountdown = 200;
break;
case TIME_30_SECONDS:
if (this.autoLaunchCountdown <= 0 || this.autoLaunchCountdown > 600)
this.autoLaunchCountdown = 600;
break;
case TIME_1_MINUTE:
if (this.autoLaunchCountdown <= 0 || this.autoLaunchCountdown > 1200)
this.autoLaunchCountdown = 1200;
break;
default:
break;
}
} else {
// This LaunchController is out of power, disabled, invalid target or set not to launch
// No auto launch - but maybe another connectedTile will have some launch settings?
this.autoLaunchSetting = null;
this.autoLaunchCountdown = 0;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable in project Galacticraft by micdoodle8.
the class TileEntityLandingPad method testConnectedTile.
private void testConnectedTile(int x, int z, HashSet<ILandingPadAttachable> connectedTiles) {
BlockPos testPos = new BlockPos(x, this.getPos().getY(), z);
if (!this.worldObj.isBlockLoaded(testPos, false))
return;
final TileEntity tile = this.worldObj.getTileEntity(testPos);
if (tile instanceof ILandingPadAttachable && ((ILandingPadAttachable) tile).canAttachToLandingPad(this.worldObj, this.getPos())) {
connectedTiles.add((ILandingPadAttachable) tile);
if (GalacticraftCore.isPlanetsLoaded && tile instanceof TileEntityLaunchController) {
((TileEntityLaunchController) tile).setAttachedPad(this);
}
}
}
Aggregations