Search in sources :

Example 1 with ILandingPadAttachable

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();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILandingPadAttachable(micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 2 with ILandingPadAttachable

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ILandingPadAttachable(micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable) BlockPos(net.minecraft.util.BlockPos) TileEntityLaunchController(micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)

Aggregations

ILandingPadAttachable (micdoodle8.mods.galacticraft.api.tile.ILandingPadAttachable)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)1 TileEntityLaunchController (micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController)1 BlockPos (net.minecraft.util.BlockPos)1