Search in sources :

Example 31 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class EntityTieredRocket method initiatePlanetsPreGen.

private void initiatePlanetsPreGen(int cx, int cz) {
    this.preGenList.clear();
    // If the server is at less than 20tps then maybe some of the outermost chunks won't be pre-generated but that's probably OK
    if (this.destinationFrequency == -1 && !EntityTieredRocket.preGenInProgress) {
        ArrayList<Integer> toPreGen = new ArrayList<>();
        for (Planet planet : GalaxyRegistry.getRegisteredPlanets().values()) {
            if (planet.getDimensionID() == this.dimension) {
                continue;
            }
            if (planet.getReachable() && planet.getTierRequirement() <= this.getRocketTier() && !planet.getUnlocalizedName().equals("planet.asteroids")) {
                toPreGen.add(planet.getDimensionID());
            }
        }
        if (toPreGen.size() > 0) {
            for (Integer dimID : toPreGen) {
                this.preGenList.add(new BlockVec3(cx, dimID, cz));
                if (ConfigManagerCore.enableDebug) {
                    GCLog.info("Starting terrain pregen for dimension " + dimID + " at " + (cx * 16 + 8) + ", " + (cz * 16 + 8));
                }
            }
            for (// concentric squares with radius r
            int r = 1; // concentric squares with radius r
            r < 12; // concentric squares with radius r
            r++) {
                int xmin = cx - r;
                int xmax = cx + r;
                int zmin = cz - r;
                int zmax = cz + r;
                for (// stop before i == r to avoid doing corners twice
                int i = -r; // stop before i == r to avoid doing corners twice
                i < r; // stop before i == r to avoid doing corners twice
                i++) {
                    for (Integer dimID : toPreGen) {
                        this.preGenList.add(new BlockVec3(xmin, dimID, cz + i));
                        this.preGenList.add(new BlockVec3(xmax, dimID, cz - i));
                        this.preGenList.add(new BlockVec3(cx - i, dimID, zmin));
                        this.preGenList.add(new BlockVec3(cx + i, dimID, zmax));
                    }
                }
            }
            this.preGenIterator = this.preGenList.iterator();
            EntityTieredRocket.preGenInProgress = true;
        }
    } else {
        this.preGenIterator = null;
    }
}
Also used : ArrayList(java.util.ArrayList) Planet(micdoodle8.mods.galacticraft.api.galaxies.Planet) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 32 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 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 33 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class ThreadFindSeal method unsealNearMapEdge.

/**
 * Literally the only difference from unseal() should be this:
 *        Block id = sideVec.getBlockID_noChunkLoad(world);
 *
 * In this code, there is a map edge check on the x, z coordinates (outside map edge at 30,000,000 blocks?)
 * This check is skipped in the "safe" version of the same code, for higher performance
 * because doing this check 50000 times when looking at blocks around a sealer at spawn is obviously dumb
 */
private void unsealNearMapEdge() {
    // Local variables are fractionally faster than statics
    Block breatheableAirID = GCBlocks.breatheableAir;
    Block breatheableAirIDBright = GCBlocks.brightBreatheableAir;
    Block oxygenSealerID = GCBlocks.oxygenSealer;
    Block fireBlock = Blocks.fire;
    Block airBlock = Blocks.air;
    Block airBlockBright = GCBlocks.brightAir;
    List<BlockVec3> toReplaceLocal = this.breatheableToReplace;
    LinkedList<BlockVec3> nextLayer = new LinkedList<>();
    World world = this.world;
    int side, bits;
    while (this.currentLayer.size() > 0) {
        for (BlockVec3 vec : this.currentLayer) {
            side = 0;
            bits = vec.sideDoneBits;
            do {
                if ((bits & (1 << side)) == 0) {
                    if (!checkedContains(vec, side)) {
                        BlockVec3 sideVec = vec.newVecSide(side);
                        Block id = sideVec.getBlockID_noChunkLoad(world);
                        if (id == breatheableAirID) {
                            toReplaceLocal.add(sideVec);
                            nextLayer.add(sideVec);
                            checkedAdd(sideVec);
                        } else if (id == breatheableAirIDBright) {
                            this.breatheableToReplaceBright.add(sideVec);
                            nextLayer.add(sideVec);
                            checkedAdd(sideVec);
                        } else if (id == fireBlock) {
                            this.fireToReplace.add(sideVec);
                            nextLayer.add(sideVec);
                            checkedAdd(sideVec);
                        } else if (id == oxygenSealerID) {
                            TileEntityOxygenSealer sealer = this.sealersAround.get(sideVec);
                            if (sealer != null && !this.sealers.contains(sealer)) {
                                if (side == 0) {
                                    // Accessing the vent side of the sealer, so add it
                                    this.otherSealers.add(sealer);
                                    checkedAdd(sideVec);
                                }
                            // if side is not 0, do not add to checked so can be rechecked from other sides
                            } else {
                                checkedAdd(sideVec);
                            }
                        } else {
                            if (id != null && id != airBlock && id != airBlockBright) {
                                // This test applies any necessary checkedAdd();
                                if (this.canBlockPassAirCheck(id, sideVec, side)) {
                                    // Look outbound through partially sealable blocks in case there is breatheableAir to clear beyond
                                    nextLayer.add(sideVec);
                                }
                            } else {
                                if (id != null)
                                    checkedAdd(sideVec);
                            }
                        }
                    }
                }
                side++;
            } while (side < 6);
        }
        // Set up the next layer as current layer for the while loop
        this.currentLayer = nextLayer;
        nextLayer = new LinkedList<BlockVec3>();
    }
}
Also used : TileEntityOxygenSealer(micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer) IPartialSealableBlock(micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock) World(net.minecraft.world.World) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 34 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityCargoUnloader method checkForCargoEntity.

public void checkForCargoEntity() {
    boolean foundFuelable = false;
    BlockVec3 thisVec = new BlockVec3(this);
    for (final EnumFacing dir : EnumFacing.VALUES) {
        final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
        if (pad != null && pad instanceof TileEntityMulti) {
            final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
            if (mainTile instanceof ICargoEntity) {
                this.attachedFuelable = (ICargoEntity) mainTile;
                foundFuelable = true;
                break;
            }
        } else if (pad != null && pad instanceof ICargoEntity) {
            this.attachedFuelable = (ICargoEntity) pad;
            foundFuelable = true;
            break;
        }
    }
    if (!foundFuelable) {
        this.attachedFuelable = null;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) ICargoEntity(micdoodle8.mods.galacticraft.api.entity.ICargoEntity) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 35 with BlockVec3

use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.

the class TileEntityCargoLoader method checkForCargoEntity.

public void checkForCargoEntity() {
    boolean foundFuelable = false;
    BlockVec3 thisVec = new BlockVec3(this);
    for (final EnumFacing dir : EnumFacing.VALUES) {
        final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
        if (pad != null && pad instanceof TileEntityMulti) {
            final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
            if (mainTile instanceof ICargoEntity) {
                this.attachedFuelable = (ICargoEntity) mainTile;
                foundFuelable = true;
                break;
            }
        } else if (pad != null && pad instanceof ICargoEntity) {
            this.attachedFuelable = (ICargoEntity) pad;
            foundFuelable = true;
            break;
        }
    }
    if (!foundFuelable) {
        this.attachedFuelable = null;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ICargoEntity(micdoodle8.mods.galacticraft.api.entity.ICargoEntity) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)104 TileEntity (net.minecraft.tileentity.TileEntity)44 EnumFacing (net.minecraft.util.EnumFacing)20 IBlockState (net.minecraft.block.state.IBlockState)14 BlockPos (net.minecraft.util.BlockPos)13 World (net.minecraft.world.World)10 IPartialSealableBlock (micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock)9 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)9 Block (net.minecraft.block.Block)9 ArrayList (java.util.ArrayList)7 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)7 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)7 NBTTagList (net.minecraft.nbt.NBTTagList)7 IConductor (micdoodle8.mods.galacticraft.api.transmission.tile.IConductor)6 TileEntityOxygenSealer (micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 Entity (net.minecraft.entity.Entity)5 LinkedList (java.util.LinkedList)4 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4