Search in sources :

Example 1 with IPneumaticMachine

use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.

the class ModuleRegulatorTube method renderModule.

@Override
protected void renderModule() {
    super.renderModule();
    if (isFake()) {
        if (!hasTicked) {
            TileEntityPneumaticBase tile = (TileEntityPneumaticBase) getTube();
            NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.xCoord, tile.yCoord, tile.zCoord));
            TileEntity neighbor = tile.getWorldObj().getTileEntity(tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
            inLine = neighbor instanceof IPneumaticMachine;
            if (inLine) {
                inverted = ((IPneumaticMachine) neighbor).getAirHandler().getPressure(dir) > tile.getPressure(ForgeDirection.UNKNOWN);
                NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.xCoord, neighbor.yCoord, neighbor.zCoord));
            }
            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();
        GL11.glColor4d(1, 1, 1, 1);
        GL11.glPopMatrix();
        GL11.glDisable(GL11.GL_BLEND);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketDescriptionPacketRequest(pneumaticCraft.common.network.PacketDescriptionPacketRequest) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) TileEntityPneumaticBase(pneumaticCraft.common.tileentity.TileEntityPneumaticBase)

Example 2 with IPneumaticMachine

use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.

the class WailaPneumaticHandler method addTipToMachine.

public static void addTipToMachine(List<String> currenttip, IWailaDataAccessor accessor) {
    NBTTagCompound tCompound = accessor.getNBTData();
    TileEntity te = accessor.getTileEntity();
    if (te instanceof IPneumaticMachine) {
        addTipToMachine(currenttip, (IPneumaticMachine) te, tCompound.getFloat("pressure"));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 3 with IPneumaticMachine

use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.

the class TileEntityPressureTube method updateConnections.

public void updateConnections(World world, int x, int y, int z) {
    sidesConnected = new boolean[6];
    boolean hasModule = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
        IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
        if (machine != null) {
            sidesConnected[direction.ordinal()] = isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite());
        } else if (te instanceof ISidedPneumaticMachine) {
            sidesConnected[direction.ordinal()] = ((ISidedPneumaticMachine) te).getAirHandler(direction.getOpposite()) != null;
        }
        if (modules[direction.ordinal()] != null) {
            hasModule = true;
        }
    }
    int sidesCount = 0;
    for (boolean bool : sidesConnected) {
        if (bool)
            sidesCount++;
    }
    if (sidesCount == 1 && !hasModule) {
        for (int i = 0; i < 6; i++) {
            if (sidesConnected[i]) {
                if (isConnectedTo(ForgeDirection.getOrientation(i).getOpposite()))
                    sidesConnected[i ^ 1] = true;
                break;
            }
        }
    }
    for (int i = 0; i < 6; i++) {
        if (modules[i] != null && modules[i].isInline())
            sidesConnected[i] = false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISidedPneumaticMachine(pneumaticCraft.api.tileentity.ISidedPneumaticMachine)

Example 4 with IPneumaticMachine

use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.

the class TileEntityUVLightBox method updateConnections.

public void updateConnections() {
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        if (isConnectedTo(direction)) {
            boolean checkingLeft = ForgeDirection.getOrientation(getBlockMetadata()).getRotation(ForgeDirection.UP) == direction;
            TileEntity te = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
            if (te instanceof IPneumaticMachine) {
                /*sidesConnected[direction.ordinal()]*/
                boolean isConnected = ((IPneumaticMachine) te).isConnectedTo(direction.getOpposite());
                if (checkingLeft)
                    leftConnected = isConnected;
                else
                    rightConnected = isConnected;
            } else {
                /*sidesConnected[direction.ordinal()]*/
                if (checkingLeft)
                    leftConnected = false;
                else
                    rightConnected = false;
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 5 with IPneumaticMachine

use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.

the class ProgWidgetPressureCondition method getEvaluator.

@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {

        @Override
        protected boolean evaluate(ChunkPosition pos) {
            TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
            if (te instanceof IPneumaticMachine) {
                IAirHandler airHandler = ((IPneumaticMachine) te).getAirHandler();
                float pressure = Float.MIN_VALUE;
                for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                    if (getSides()[d.ordinal()]) {
                        pressure = Math.max(airHandler.getPressure(d), pressure);
                    }
                }
                return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? pressure == ((ICondition) widget).getRequiredCount() : pressure >= ((ICondition) widget).getRequiredCount();
            }
            return false;
        }
    };
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAirHandler(pneumaticCraft.api.tileentity.IAirHandler) DroneAIBlockCondition(pneumaticCraft.common.ai.DroneAIBlockCondition) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ChunkPosition(net.minecraft.world.ChunkPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Aggregations

IPneumaticMachine (pneumaticCraft.api.tileentity.IPneumaticMachine)11 TileEntity (net.minecraft.tileentity.TileEntity)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 IAirHandler (pneumaticCraft.api.tileentity.IAirHandler)4 ArrayList (java.util.ArrayList)3 ISidedPneumaticMachine (pneumaticCraft.api.tileentity.ISidedPneumaticMachine)3 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 Pair (org.apache.commons.lang3.tuple.Pair)2 IPressurizable (pneumaticCraft.api.item.IPressurizable)2 IInventory (net.minecraft.inventory.IInventory)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 IChatComponent (net.minecraft.util.IChatComponent)1 ChunkPosition (net.minecraft.world.ChunkPosition)1 MutablePair (org.apache.commons.lang3.tuple.MutablePair)1 IHeatExchangerLogic (pneumaticCraft.api.IHeatExchangerLogic)1 IHeatExchanger (pneumaticCraft.api.tileentity.IHeatExchanger)1 IManoMeasurable (pneumaticCraft.api.tileentity.IManoMeasurable)1 DroneAIBlockCondition (pneumaticCraft.common.ai.DroneAIBlockCondition)1