use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class ModuleCharging method update.
@Override
public void update() {
super.update();
IItemHandler handler = getConnectedInventory();
if (handler != null) {
for (int i = 0; i < (upgraded ? 10 : 1) * PneumaticValues.CHARGING_STATION_CHARGE_RATE; i++) {
boolean charged = false;
for (int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack chargedItem = handler.getStackInSlot(slot);
if (chargedItem.getItem() instanceof IPressurizable) {
IPressurizable chargingItem = (IPressurizable) chargedItem.getItem();
IAirHandler airHandler = pressureTube.getAirHandler(null);
if (chargingItem.getPressure(chargedItem) > airHandler.getPressure() + 0.01F && chargingItem.getPressure(chargedItem) > 0F) {
chargingItem.addAir(chargedItem, -1);
airHandler.addAir(1);
charged = true;
} else if (chargingItem.getPressure(chargedItem) < airHandler.getPressure() - 0.01F && chargingItem.getPressure(chargedItem) < chargingItem.maxPressure(chargedItem)) {
// if there is pressure, and the item isn't fully charged yet..
chargingItem.addAir(chargedItem, 1);
airHandler.addAir(-1);
charged = true;
}
}
}
if (!charged)
break;
}
}
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class ModuleRegulatorTube method getMaxDispersion.
@Override
public int getMaxDispersion() {
IAirHandler connectedHandler = null;
for (Pair<EnumFacing, IAirHandler> entry : pressureTube.getAirHandler(null).getConnectedPneumatics()) {
if (entry.getKey().equals(dir)) {
connectedHandler = entry.getValue();
break;
}
}
if (connectedHandler == null)
return 0;
int maxDispersion = (int) ((getThreshold() - connectedHandler.getPressure()) * connectedHandler.getVolume());
if (maxDispersion < 0)
return 0;
return maxDispersion;
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class ModuleRegulatorTube method renderPreview.
@SideOnly(Side.CLIENT)
private void renderPreview() {
if (!hasTicked) {
TileEntityPneumaticBase tile = (TileEntityPneumaticBase) getTube();
NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.getPos()));
TileEntity neighbor = tile.getWorld().getTileEntity(tile.getPos().offset(dir));
inLine = neighbor instanceof IPneumaticMachine;
if (inLine) {
IAirHandler neighborHandler = ((IPneumaticMachine) neighbor).getAirHandler(dir);
inverted = neighborHandler != null && neighborHandler.getPressure() > tile.getAirHandler(null).getPressure();
NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.getPos()));
}
hasTicked = true;
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (inLine && !inverted) {
GL11.glColor4d(0, 1, 0, 0.3);
} else {
GL11.glColor4d(1, 0, 0, 0.3);
}
GL11.glPushMatrix();
GL11.glTranslated(0, 1, 0.2 + ClientTickHandler.TICKS % 20 * 0.015);
GL11.glRotated(90, 1, 0, 0);
RenderUtils.render3DArrow();
// 0.5 because we're rendering a preview
GL11.glColor4d(1, 1, 1, 0.5);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class TOPCallback method handlePneumatic.
public static void handlePneumatic(ProbeMode mode, IProbeInfo probeInfo, IPneumaticMachine pneumaticMachine) {
IAirHandler airHandler = pneumaticMachine.getAirHandler(null);
if (mode == ProbeMode.EXTENDED) {
probeInfo.text("Pressure:");
probeInfo.horizontal().element(new ElementPressure(pneumaticMachine)).vertical().text("").text(" \u2b05 " + PneumaticCraftUtils.roundNumberTo(airHandler.getPressure(), 2) + " bar");
} else {
probeInfo.text(TextFormatting.GRAY + "Pressure: " + TextFormatting.WHITE + PneumaticCraftUtils.roundNumberTo(airHandler.getPressure(), 2) + " bar");
}
}
use of me.desht.pneumaticcraft.api.tileentity.IAirHandler in project pnc-repressurized by TeamPneumatic.
the class WailaPneumaticHandler method addTipToMachine.
// public static void addTipToMachine(List<String> currenttip, IPneumaticMachine machine) {
// addTipToMachine(currenttip, machine, machine.getAirHandler(null).getPressure());
// }
private static void addTipToMachine(List<String> currenttip, IPneumaticMachine machine, float pressure) {
Map<String, String> values = new HashMap<>();
values.put("Pressure", PneumaticCraftUtils.roundNumberTo(pressure, 1) + " bar");
IAirHandler base = machine.getAirHandler(null);
values.put("Max Pressure", PneumaticCraftUtils.roundNumberTo(base.getDangerPressure(), 1) + " bar");
for (Map.Entry<String, String> entry : values.entrySet()) {
currenttip.add(entry.getKey() + ": " + TextFormatting.WHITE + entry.getValue());
}
}
Aggregations