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;
}
}
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();
}
}
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>();
}
}
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;
}
}
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;
}
}
Aggregations