Search in sources :

Example 1 with IAirHandler

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));
}
Also used : IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) LuaMethod(me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaMethod) LuaConstant(me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaConstant)

Example 2 with IAirHandler

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));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) EnumFacing(net.minecraft.util.EnumFacing) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with IAirHandler

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

Example 4 with IAirHandler

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());
}
Also used : IAirHandler(me.desht.pneumaticcraft.api.tileentity.IAirHandler) Pair(org.apache.commons.lang3.tuple.Pair)

Example 5 with IAirHandler

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

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