use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class TileEntityPneumaticBase method addLuaMethods.
@Override
protected void addLuaMethods() {
super.addLuaMethods();
luaMethods.add(new LuaMethod("getPressure") {
@Override
public Object[] call(Object[] args) throws Exception {
if (args.length == 0) {
return new Object[] { airHandler.getPressure() };
} else if (args.length == 1) {
IAirHandler handler = getAirHandler(getDirForString((String) args[0]));
return new Object[] { handler != null ? handler.getPressure() : 0 };
} else {
throw new IllegalArgumentException("getPressure method requires 0 or 1 argument (direction: up, down, east, west, north, south)!");
}
}
});
luaMethods.add(new LuaConstant("getDangerPressure", dangerPressure));
luaMethods.add(new LuaConstant("getCriticalPressure", criticalPressure));
luaMethods.add(new LuaConstant("getDefaultVolume", defaultVolume));
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class TileEntityElevatorBase method updateConnections.
public void updateConnections() {
List<Pair<EnumFacing, IAirHandler>> connections = getAirHandler(null).getConnectedPneumatics();
Arrays.fill(sidesConnected, false);
for (Pair<EnumFacing, IAirHandler> entry : connections) {
sidesConnected[entry.getKey().ordinal()] = true;
}
if (getWorld().getBlockState(getPos().offset(EnumFacing.UP)).getBlock() != Blockss.ELEVATOR_BASE) {
coreElevator = this;
int i = -1;
TileEntity te = getWorld().getTileEntity(getPos().offset(EnumFacing.DOWN));
while (te instanceof TileEntityElevatorBase) {
((TileEntityElevatorBase) te).coreElevator = this;
i--;
te = getWorld().getTileEntity(getPos().add(0, i, 0));
}
}
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class TileEntityPressureTube method updateConnections.
private void updateConnections() {
sidesConnected = new boolean[6];
List<Pair<EnumFacing, IAirHandler>> connections = getAirHandler(null).getConnectedPneumatics();
Arrays.fill(sidesConnected, false);
for (Pair<EnumFacing, IAirHandler> entry : connections) {
sidesConnected[entry.getKey().ordinal()] = true;
}
boolean hasModule = false;
for (int i = 0; i < 6; i++) {
if (modules[i] != null) {
hasModule = true;
break;
}
}
int sidesCount = 0;
for (boolean bool : sidesConnected) {
if (bool)
sidesCount++;
}
if (sidesCount == 1 && !hasModule) {
for (int i = 0; i < 6; i++) {
if (sidesConnected[i]) {
EnumFacing opposite = EnumFacing.getFront(i).getOpposite();
if (isConnectedTo(opposite))
sidesConnected[opposite.ordinal()] = true;
break;
}
}
}
for (int i = 0; i < 6; i++) {
if (modules[i] != null && modules[i].isInline())
sidesConnected[i] = false;
}
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class TileEntityVacuumPump method update.
@Override
public void update() {
if (!getWorld().isRemote && turnTimer >= 0) {
turnTimer--;
}
if (!getWorld().isRemote && getAirHandler(getInputSide()).getPressure() > PneumaticValues.MIN_PRESSURE_VACUUM_PUMP && getAirHandler(getVacuumSide()).getPressure() > -1F && redstoneAllows()) {
if (!getWorld().isRemote && turnTimer == -1) {
turning = true;
}
// negative because it's pulling a vacuum.
getAirHandler(getVacuumSide()).addAir((int) (-PneumaticValues.PRODUCTION_VACUUM_PUMP * getSpeedMultiplierFromUpgrades()));
getAirHandler(getInputSide()).addAir((int) (-PneumaticValues.USAGE_VACUUM_PUMP * getSpeedUsageMultiplierFromUpgrades()));
turnTimer = 40;
}
if (turnTimer == 0) {
turning = false;
}
oldRotation = rotation;
if (getWorld().isRemote) {
if (turning) {
rotationSpeed = Math.min(rotationSpeed + 1, 20);
} else {
rotationSpeed = Math.max(rotationSpeed - 1, 0);
}
rotation += rotationSpeed;
}
super.update();
vacuumHandler.update();
IAirHandler inputHandler = getAirHandler(getInputSide());
List<Pair<EnumFacing, IAirHandler>> teList = inputHandler.getConnectedPneumatics();
if (teList.size() == 0)
inputHandler.airLeak(getInputSide());
teList = vacuumHandler.getConnectedPneumatics();
if (teList.size() == 0)
vacuumHandler.airLeak(getVacuumSide());
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class GuiPneumaticContainerBase method addPressureStatInfo.
protected void addPressureStatInfo(List<String> pressureStatText) {
TileEntityPneumaticBase pneumaticTile = (TileEntityPneumaticBase) te;
IAirHandler airHandler = pneumaticTile.getAirHandler(null);
pressureStatText.add("\u00a77Current Pressure:");
pressureStatText.add("\u00a70" + PneumaticCraftUtils.roundNumberTo(pneumaticTile.getPressure(), 1) + " bar.");
pressureStatText.add("\u00a77Current Air:");
pressureStatText.add("\u00a70" + (airHandler.getAir() + airHandler.getVolume()) + " mL.");
pressureStatText.add("\u00a77Volume:");
pressureStatText.add("\u00a70" + pneumaticTile.defaultVolume + " mL.");
int volumeLeft = airHandler.getVolume() - pneumaticTile.defaultVolume;
if (volumeLeft > 0) {
pressureStatText.add("\u00a70" + volumeLeft + " mL. (Volume Upgrades)");
pressureStatText.add("\u00a70--------+");
pressureStatText.add("\u00a70" + airHandler.getVolume() + " mL.");
}
}
Aggregations