Search in sources :

Example 1 with PipeFluidTransportLogistics

use of logisticspipes.transport.PipeFluidTransportLogistics in project LogisticsPipes by RS485.

the class PipeFluidExtractor method extractFrom.

private void extractFrom(IFluidHandler container, ForgeDirection side) {
    int i = side.ordinal();
    FluidStack contained = ((PipeFluidTransportLogistics) transport).getTankInfo(side)[0].fluid;
    int amountMissing = ((PipeFluidTransportLogistics) transport).getSideCapacity() - (contained != null ? contained.amount : 0);
    if (liquidToExtract[i] < Math.min(PipeFluidExtractor.flowRate, amountMissing)) {
        if (this.useEnergy(PipeFluidExtractor.energyPerFlow)) {
            liquidToExtract[i] += Math.min(PipeFluidExtractor.flowRate, amountMissing);
        }
    }
    FluidStack extracted = container.drain(side.getOpposite(), liquidToExtract[i] > PipeFluidExtractor.flowRate ? PipeFluidExtractor.flowRate : liquidToExtract[i], false);
    int inserted = 0;
    if (extracted != null) {
        inserted = ((PipeFluidTransportLogistics) transport).fill(side, extracted, true);
        container.drain(side.getOpposite(), inserted, true);
    }
    liquidToExtract[i] -= inserted;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics)

Example 2 with PipeFluidTransportLogistics

use of logisticspipes.transport.PipeFluidTransportLogistics in project LogisticsPipes by RS485.

the class LogisticsRenderPipe method renderFluids.

// BC copy, except where marked with XXX
private void renderFluids(CoreUnroutedPipe pipe, double x, double y, double z) {
    // XXX PipeTransportFluids trans = pipe.transport;
    PipeFluidTransportLogistics trans = (PipeFluidTransportLogistics) (pipe.transport);
    boolean needsRender = false;
    for (int i = 0; i < 7; ++i) {
        FluidStack fluidStack = trans.renderCache[i];
        if (fluidStack != null && fluidStack.amount > 0) {
            needsRender = true;
            break;
        }
    }
    if (!needsRender) {
        return;
    }
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glTranslatef((float) x, (float) y, (float) z);
    int skylight = pipe.container.getWorld().getSkyBlockTypeBrightness(EnumSkyBlock.Sky, pipe.getX(), pipe.getY(), pipe.getZ());
    int blocklight = pipe.container.getWorld().getSkyBlockTypeBrightness(EnumSkyBlock.Block, pipe.getX(), pipe.getY(), pipe.getZ());
    // sides
    boolean sides = false, above = false;
    for (int i = 0; i < 6; ++i) {
        FluidStack fluidStack = trans.renderCache[i];
        if (fluidStack != null && fluidStack.amount > 0) {
            DisplayFluidList d = getListFromBuffer(fluidStack, skylight, blocklight, fluidStack.getFluid().getLuminosity(fluidStack), pipe.container.getWorldObj());
            if (d == null) {
                continue;
            }
            // XXX int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
            int stage = (int) ((float) fluidStack.amount / (float) (trans.getSideCapacity()) * (LogisticsRenderPipe.LIQUID_STAGES - 1));
            if (stage >= LogisticsRenderPipe.LIQUID_STAGES) {
                stage = LogisticsRenderPipe.LIQUID_STAGES - 1;
            }
            if (stage < 0) {
                stage = 0;
            }
            GL11.glPushMatrix();
            int list = 0;
            switch(ForgeDirection.VALID_DIRECTIONS[i]) {
                case UP:
                    above = true;
                    list = d.sideVertical[stage];
                    break;
                case DOWN:
                    GL11.glTranslatef(0, -0.75F, 0);
                    list = d.sideVertical[stage];
                    break;
                case EAST:
                case WEST:
                case SOUTH:
                case NORTH:
                    sides = true;
                    // Yes, this is kind of ugly, but was easier than transform the coordinates above.
                    GL11.glTranslatef(0.5F, 0.0F, 0.5F);
                    GL11.glRotatef(angleY[i], 0, 1, 0);
                    GL11.glRotatef(angleZ[i], 0, 0, 1);
                    GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
                    list = d.sideHorizontal[stage];
                    break;
                default:
            }
            bindTexture(TextureMap.locationBlocksTexture);
            FluidRenderer.setColorForFluidStack(fluidStack);
            GL11.glCallList(list);
            GL11.glPopMatrix();
        }
    }
    // CENTER
    FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];
    if (fluidStack != null && fluidStack.amount > 0) {
        DisplayFluidList d = getListFromBuffer(fluidStack, skylight, blocklight, fluidStack.getFluid().getLuminosity(fluidStack), pipe.container.getWorldObj());
        if (d != null) {
            // XXX int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
            int stage = (int) ((float) fluidStack.amount / (float) (trans.getInnerCapacity()) * (LogisticsRenderPipe.LIQUID_STAGES - 1));
            bindTexture(TextureMap.locationBlocksTexture);
            FluidRenderer.setColorForFluidStack(fluidStack);
            if (above) {
                GL11.glCallList(d.centerVertical[stage]);
            }
            if (!above || sides) {
                GL11.glCallList(d.centerHorizontal[stage]);
            }
        }
    }
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}
Also used : PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 3 with PipeFluidTransportLogistics

use of logisticspipes.transport.PipeFluidTransportLogistics in project LogisticsPipes by RS485.

the class FluidRoutedPipe method endReached.

public boolean endReached(LPTravelingItemServer arrivingItem, TileEntity tile) {
    if (canInsertToTanks() && MainProxy.isServer(getWorld())) {
        getCacheHolder().trigger(CacheTypes.Inventory);
        if (arrivingItem.getItemIdentifierStack() == null || !(arrivingItem.getItemIdentifierStack().getItem().isFluidContainer())) {
            return false;
        }
        if (getRouter().getSimpleID() != arrivingItem.getDestination()) {
            return false;
        }
        int filled;
        FluidIdentifierStack liquid = SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(arrivingItem.getItemIdentifierStack());
        if (isConnectableTank(tile, arrivingItem.output, false)) {
            // Try to put liquid into all adjacent tanks.
            for (Pair<NeighborTileEntity<TileEntity>, ITankUtil> util : PipeFluidUtil.INSTANCE.getAdjacentTanks(this, false)) {
                filled = util.getValue2().fill(liquid, true);
                liquid.lowerAmount(filled);
                if (liquid.getAmount() != 0) {
                    continue;
                }
                return true;
            }
            // Try inserting the liquid into the pipe side tank
            filled = ((PipeFluidTransportLogistics) transport).sideTanks[arrivingItem.output.ordinal()].fill(liquid.makeFluidStack(), true);
            if (filled == liquid.getAmount()) {
                return true;
            }
            liquid.lowerAmount(filled);
        }
        // Try inserting the liquid into the pipe internal tank
        filled = ((PipeFluidTransportLogistics) transport).internalTank.fill(liquid.makeFluidStack(), true);
        if (filled == liquid.getAmount()) {
            return true;
        }
        // If liquids still exist,
        liquid.lowerAmount(filled);
        // TODO: FIX THIS
        if (this instanceof IRequireReliableFluidTransport) {
            ((IRequireReliableFluidTransport) this).liquidNotInserted(liquid.getFluid(), liquid.getAmount());
        }
        IRoutedItem routedItem = SimpleServiceLocator.routedItemHelper.createNewTravelItem(SimpleServiceLocator.logisticsFluidManager.getFluidContainer(liquid));
        Pair<Integer, FluidSinkReply> replies = SimpleServiceLocator.logisticsFluidManager.getBestReply(liquid, getRouter(), routedItem.getJamList());
        if (replies == null) {
            // clear destination without marking item as lost
            routedItem.setDestination(0);
        } else {
            int dest = replies.getValue1();
            routedItem.setDestination(dest);
        }
        routedItem.setTransportMode(TransportMode.Passive);
        this.queueRoutedItem(routedItem, arrivingItem.output.getOpposite());
        return true;
    }
    return false;
}
Also used : FluidIdentifierStack(logisticspipes.utils.FluidIdentifierStack) ITankUtil(logisticspipes.interfaces.ITankUtil) FluidSinkReply(logisticspipes.utils.FluidSinkReply) IRoutedItem(logisticspipes.logisticspipes.IRoutedItem) NeighborTileEntity(network.rs485.logisticspipes.connection.NeighborTileEntity) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) IRequireReliableFluidTransport(logisticspipes.interfaces.routing.IRequireReliableFluidTransport)

Example 4 with PipeFluidTransportLogistics

use of logisticspipes.transport.PipeFluidTransportLogistics in project LogisticsPipes by RS485.

the class LogisticsRenderPipe method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
    double distance = Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosX - tileentity.xCoord, 2) + Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosY - tileentity.yCoord, 2) + Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosZ - tileentity.zCoord, 2);
    if (tileentity instanceof LogisticsTileGenericPipe) {
        LogisticsTileGenericPipe pipe = ((LogisticsTileGenericPipe) tileentity);
        if (pipe.pipe == null) {
            return;
        }
        if (pipe.pipe instanceof CoreRoutedPipe) {
            renderPipeSigns((CoreRoutedPipe) pipe.pipe, x, y, z, partialTickTime);
        }
        if (LogisticsRenderPipe.config.isUseNewRenderer()) {
            LogisticsRenderPipe.secondRenderer.renderTileEntityAt((LogisticsTileGenericPipe) tileentity, x, y, z, partialTickTime, distance);
        }
        if (LogisticsRenderPipe.config.getRenderPipeContentDistance() * LogisticsRenderPipe.config.getRenderPipeContentDistance() < distance) {
            return;
        }
        bcRenderer.renderWires(pipe, x, y, z);
        // dynamically render pluggables (like gates)
        bcRenderer.dynamicRenderPluggables(pipe, x, y, z);
        if (!pipe.isOpaque()) {
            if (pipe.pipe.transport instanceof PipeFluidTransportLogistics) {
                renderFluids(pipe.pipe, x, y, z);
            }
            if (pipe.pipe.transport instanceof PipeTransportLogistics) {
                renderSolids(pipe.pipe, x, y, z, partialTickTime);
            }
        }
    }
}
Also used : PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics)

Example 5 with PipeFluidTransportLogistics

use of logisticspipes.transport.PipeFluidTransportLogistics in project LogisticsPipes by RS485.

the class PipeFluidUpdate method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsTileGenericPipe pipe = this.getPipe(player.world);
    if (pipe == null || pipe.pipe == null) {
        return;
    }
    if (!(pipe.pipe.transport instanceof PipeFluidTransportLogistics)) {
        return;
    }
    ((PipeFluidTransportLogistics) pipe.pipe.transport).renderCache = renderCache;
}
Also used : PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Aggregations

PipeFluidTransportLogistics (logisticspipes.transport.PipeFluidTransportLogistics)9 FluidStack (net.minecraftforge.fluids.FluidStack)5 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)3 FluidIdentifierStack (logisticspipes.utils.FluidIdentifierStack)3 ITankUtil (logisticspipes.interfaces.ITankUtil)2 IRequireReliableFluidTransport (logisticspipes.interfaces.routing.IRequireReliableFluidTransport)2 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)2 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)2 FluidSinkReply (logisticspipes.utils.FluidSinkReply)2 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)2 Pair (logisticspipes.utils.tuples.Pair)2 FluidTank (net.minecraftforge.fluids.FluidTank)2 NeighborTileEntity (network.rs485.logisticspipes.connection.NeighborTileEntity)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 LogisticsPipes (logisticspipes.LogisticsPipes)1 IRequestFluid (logisticspipes.interfaces.routing.IRequestFluid)1