use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityArclamp method revertAir.
private void revertAir() {
if (this.airToRestore.isEmpty())
return;
if (this.usingLightList == null) {
this.usingLightList = this.worldObj.isRemote ? usingLightListClient : usingLightListServer;
}
int index = 0;
for (BlockVec3 vec : this.airToRestore) {
this.setDarkerAir(vec);
}
if (!this.usingLightList.getAndSet(true)) {
for (BlockVec3 vec : this.airToRestore) {
index = this.checkLightPartA(EnumSkyBlock.BLOCK, vec.toBlockPos(), index);
}
this.checkLightPartB(EnumSkyBlock.BLOCK, index);
this.usingLightList.set(false);
}
this.airToRestore.clear();
this.checkLightFor(EnumSkyBlock.BLOCK, this.pos);
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityOxygen method produceOxygen.
public boolean produceOxygen(EnumFacing outputDirection) {
int provide = this.getOxygenProvide(outputDirection);
if (provide > 0) {
TileEntity outputTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, outputDirection);
FluidNetwork outputNetwork = NetworkHelper.getFluidNetworkFromTile(outputTile, outputDirection);
if (outputNetwork != null) {
int gasRequested = outputNetwork.getRequest();
if (gasRequested > 0) {
int usedGas = outputNetwork.emitToBuffer(new FluidStack(GCFluids.fluidOxygenGas, Math.min(gasRequested, provide)), true);
this.drawOxygen(usedGas, true);
return true;
}
} else if (outputTile instanceof IOxygenReceiver) {
float requestedOxygen = ((IOxygenReceiver) outputTile).getOxygenRequest(outputDirection.getOpposite());
if (requestedOxygen > 0) {
int acceptedOxygen = ((IOxygenReceiver) outputTile).receiveOxygen(outputDirection.getOpposite(), provide, true);
this.drawOxygen(acceptedOxygen, true);
return true;
}
}
// else if (EnergyConfigHandler.isMekanismLoaded())
// {
// //TODO Oxygen item handling - internal tank (IGasItem)
// //int acceptedOxygen = GasTransmission.addGas(itemStack, type, amount);
// //this.drawOxygen(acceptedOxygen, true);
//
// if (outputTile instanceof IGasHandler && ((IGasHandler) outputTile).canReceiveGas(outputDirection.getOpposite(), (Gas) EnergyConfigHandler.gasOxygen))
// {
// GasStack toSend = new GasStack((Gas) EnergyConfigHandler.gasOxygen, (int) Math.floor(provide));
// int acceptedOxygen = 0;
// try {
// acceptedOxygen = ((IGasHandler) outputTile).receiveGas(outputDirection.getOpposite(), toSend);
// } catch (Exception e) { }
// this.drawOxygen(acceptedOxygen, true);
// return true;
// }
// }
}
return false;
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityFluidPipe method canConnect.
@Override
public boolean canConnect(EnumFacing direction, NetworkType type) {
TileEntity adjacentTile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, direction);
if (type == NetworkType.FLUID) {
if (adjacentTile instanceof IColorable) {
IBlockState state = this.worldObj.getBlockState(this.getPos());
IBlockState adjacentTileState = adjacentTile.getWorld().getBlockState(adjacentTile.getPos());
byte thisCol = this.getColor(state);
byte otherCol = ((IColorable) adjacentTile).getColor(adjacentTileState);
return thisCol == otherCol || thisCol == EnumDyeColor.WHITE.getDyeDamage() || otherCol == EnumDyeColor.WHITE.getDyeDamage();
}
return true;
}
return false;
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityFuelLoader method update.
@Override
public void update() {
super.update();
if (!this.worldObj.isRemote) {
this.loadedFuelLastTick = false;
final FluidStack liquidContained = FluidUtil.getFluidContained(this.containingItems[1]);
if (FluidUtil.isFuel(liquidContained)) {
FluidUtil.loadFromContainer(this.fuelTank, GCFluids.fluidFuel, this.containingItems, 1, liquidContained.amount);
}
if (this.ticks % 100 == 0) {
this.attachedFuelable = null;
BlockVec3 thisVec = new BlockVec3(this);
for (final EnumFacing dir : EnumFacing.VALUES) {
final TileEntity pad = thisVec.getTileEntityOnSide(this.worldObj, dir);
if (pad instanceof TileEntityMulti) {
final TileEntity mainTile = ((TileEntityMulti) pad).getMainBlockTile();
if (mainTile instanceof IFuelable) {
this.attachedFuelable = (IFuelable) mainTile;
break;
}
} else if (pad instanceof IFuelable) {
this.attachedFuelable = (IFuelable) pad;
break;
}
}
}
if (this.fuelTank != null && this.fuelTank.getFluid() != null && this.fuelTank.getFluid().amount > 0) {
final FluidStack liquid = new FluidStack(GCFluids.fluidFuel, 2);
if (this.attachedFuelable != null && this.hasEnoughEnergyToRun && !this.disabled) {
int filled = this.attachedFuelable.addFuel(liquid, true);
this.loadedFuelLastTick = filled > 0;
this.fuelTank.drain(filled, true);
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class EntityTieredRocket method onUpdate.
@Override
public void onUpdate() {
if (this.getWaitForPlayer()) {
if (this.riddenByEntity != null) {
if (this.ticks >= 40) {
if (!this.worldObj.isRemote) {
Entity e = this.riddenByEntity;
e.mountEntity(null);
e.mountEntity(this);
GCLog.debug("Remounting player in rocket.");
}
this.setWaitForPlayer(false);
this.motionY = -0.5D;
} else {
this.motionX = this.motionY = this.motionZ = 0.0D;
this.riddenByEntity.motionX = this.riddenByEntity.motionY = this.riddenByEntity.motionZ = 0;
}
} else {
this.motionX = this.motionY = this.motionZ = 0.0D;
}
}
super.onUpdate();
if (!this.worldObj.isRemote) {
if (this.launchCooldown > 0) {
this.launchCooldown--;
}
if (this.preGenIterator != null) {
if (this.preGenIterator.hasNext()) {
MinecraftServer mcserver;
if (this.worldObj instanceof WorldServer) {
mcserver = ((WorldServer) this.worldObj).getMinecraftServer();
BlockVec3 coords = this.preGenIterator.next();
World w = mcserver.worldServerForDimension(coords.y);
if (w != null) {
w.getChunkFromChunkCoords(coords.x, coords.z);
// Pregen a second chunk if still on launchpad (low strain on server)
if (this.launchPhase < EnumLaunchPhase.LAUNCHED.ordinal() && this.preGenIterator.hasNext()) {
coords = this.preGenIterator.next();
w = mcserver.worldServerForDimension(coords.y);
w.getChunkFromChunkCoords(coords.x, coords.z);
}
}
}
} else {
this.preGenIterator = null;
EntityTieredRocket.preGenInProgress = false;
}
}
}
if (this.rumble > 0) {
this.rumble--;
} else if (this.rumble < 0) {
this.rumble++;
}
if (this.riddenByEntity != null) {
final double rumbleAmount = this.rumble / (double) (37 - 5 * Math.max(this.getRocketTier(), 5));
this.riddenByEntity.posX += rumbleAmount;
this.riddenByEntity.posZ += rumbleAmount;
}
if (this.launchPhase >= EnumLaunchPhase.IGNITED.ordinal()) {
this.performHurtAnimation();
this.rumble = (float) this.rand.nextInt(3) - 3;
}
if (!this.worldObj.isRemote) {
this.lastLastMotionY = this.lastMotionY;
this.lastMotionY = this.motionY;
}
}
Aggregations