Search in sources :

Example 6 with IAirHandler

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;
        }
    }
}
Also used : IPressurizable(me.desht.pneumaticcraft.api.item.IPressurizable) IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) IItemHandler(net.minecraftforge.items.IItemHandler) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IAirHandler

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;
}
Also used : IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) EnumFacing(net.minecraft.util.EnumFacing)

Example 8 with IAirHandler

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) PacketDescriptionPacketRequest(me.desht.pneumaticcraft.common.network.PacketDescriptionPacketRequest) IPneumaticMachine(me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine) TileEntityPneumaticBase(me.desht.pneumaticcraft.common.tileentity.TileEntityPneumaticBase) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with IAirHandler

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");
    }
}
Also used : IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler)

Example 10 with IAirHandler

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());
    }
}
Also used : IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IAirHandler (me.desht.pneumaticcraft.api.tileentity.IAirHandler)14 EnumFacing (net.minecraft.util.EnumFacing)6 Pair (org.apache.commons.lang3.tuple.Pair)6 TileEntity (net.minecraft.tileentity.TileEntity)3 IPneumaticMachine (me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 MutablePair (org.apache.commons.lang3.tuple.MutablePair)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IPressurizable (me.desht.pneumaticcraft.api.item.IPressurizable)1 TubeModule (me.desht.pneumaticcraft.common.block.tubes.TubeModule)1 PacketDescriptionPacketRequest (me.desht.pneumaticcraft.common.network.PacketDescriptionPacketRequest)1 LuaConstant (me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaConstant)1 LuaMethod (me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaMethod)1 TileEntityPneumaticBase (me.desht.pneumaticcraft.common.tileentity.TileEntityPneumaticBase)1 ItemStack (net.minecraft.item.ItemStack)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 IItemHandler (net.minecraftforge.items.IItemHandler)1