Search in sources :

Example 6 with FluidIdentifierStack

use of logisticspipes.utils.FluidIdentifierStack in project LogisticsPipes by RS485.

the class PipeFluidExtractor method extractFrom.

private void extractFrom(ITankUtil container, EnumFacing side) {
    int sideID = side.ordinal();
    FluidStack contained = ((PipeFluidTransportLogistics) transport).getTankProperties(side)[0].getContents();
    int amountMissing = ((PipeFluidTransportLogistics) transport).getSideCapacity() - (contained != null ? contained.amount : 0);
    if (liquidToExtract[sideID] < Math.min(PipeFluidExtractor.flowRate, amountMissing)) {
        if (this.useEnergy(PipeFluidExtractor.energyPerFlow)) {
            liquidToExtract[sideID] += Math.min(PipeFluidExtractor.flowRate, amountMissing);
        }
    }
    FluidIdentifierStack extracted = container.drain(Math.min(liquidToExtract[sideID], PipeFluidExtractor.flowRate), false);
    int inserted = 0;
    if (extracted != null) {
        inserted = ((PipeFluidTransportLogistics) transport).fill(side, extracted.makeFluidStack(), true);
        container.drain(inserted, true);
    }
    liquidToExtract[sideID] -= inserted;
}
Also used : FluidIdentifierStack(logisticspipes.utils.FluidIdentifierStack) FluidStack(net.minecraftforge.fluids.FluidStack) PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics)

Example 7 with FluidIdentifierStack

use of logisticspipes.utils.FluidIdentifierStack in project LogisticsPipes by RS485.

the class PipeItemsFluidSupplier method endReached.

public void endReached(LPTravelingItemServer data, TileEntity tile) {
    getCacheHolder().trigger(CacheTypes.Inventory);
    transport.markChunkModified(tile);
    notifyOfItemArival(data.getInfo());
    EnumFacing orientation = data.output.getOpposite();
    if (getOriginalUpgradeManager().hasSneakyUpgrade()) {
        orientation = getOriginalUpgradeManager().getSneakyOrientation();
    }
    ITankUtil util = SimpleServiceLocator.tankUtilFactory.getTankUtilForTE(tile, orientation);
    if (util == null) {
        return;
    }
    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
        return;
    }
    if (data.getItemIdentifierStack() == null) {
        return;
    }
    FluidIdentifierStack liquidId = FluidIdentifierStack.getFromStack(data.getItemIdentifierStack());
    if (liquidId == null) {
        return;
    }
    while (data.getItemIdentifierStack().getStackSize() > 0 && util.fill(liquidId, false) == liquidId.getAmount() && this.useEnergy(5)) {
        util.fill(liquidId, true);
        data.getItemIdentifierStack().lowerStackSize(1);
        Item item = data.getItemIdentifierStack().getItem().item;
        if (item.hasContainerItem(data.getItemIdentifierStack().makeNormalStack())) {
            Item containerItem = Objects.requireNonNull(item.getContainerItem());
            transport.sendItem(new ItemStack(containerItem, 1));
        }
    }
}
Also used : FluidIdentifierStack(logisticspipes.utils.FluidIdentifierStack) ITankUtil(logisticspipes.interfaces.ITankUtil) Item(net.minecraft.item.Item) EnumFacing(net.minecraft.util.EnumFacing) ItemStack(net.minecraft.item.ItemStack)

Example 8 with FluidIdentifierStack

use of logisticspipes.utils.FluidIdentifierStack in project LogisticsPipes by RS485.

the class LogisticsNewPipeItemBoxRenderer method doRenderItem.

@SideOnly(Side.CLIENT)
public void doRenderItem(@Nonnull ItemStack itemstack, float light, double x, double y, double z, double boxScale, double yaw, double pitch, double yawForPitch) {
    if (LogisticsNewRenderPipe.innerTransportBox == null)
        return;
    GL11.glPushMatrix();
    if (renderList == -1) {
        renderList = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(renderList, GL11.GL_COMPILE);
        SimpleServiceLocator.cclProxy.getRenderState().reset();
        SimpleServiceLocator.cclProxy.getRenderState().startDrawing(GL11.GL_QUADS, DefaultVertexFormats.OLDMODEL_POSITION_TEX_NORMAL);
        LogisticsNewRenderPipe.innerTransportBox.render(LogisticsNewRenderPipe.innerBoxTexture);
        SimpleServiceLocator.cclProxy.getRenderState().draw();
        GL11.glEndList();
    }
    GL11.glTranslated(x, y, z);
    Minecraft.getMinecraft().getTextureManager().bindTexture(LogisticsNewPipeItemBoxRenderer.BLOCKS);
    GL11.glScaled(boxScale, boxScale, boxScale);
    GL11.glRotated(yawForPitch, 0, 1, 0);
    GL11.glRotated(pitch, 1, 0, 0);
    GL11.glRotated(-yawForPitch, 0, 1, 0);
    GL11.glRotated(yaw, 0, 1, 0);
    GL11.glTranslated(-0.5, -0.5, -0.5);
    GL11.glCallList(renderList);
    GL11.glTranslated(0.5, 0.5, 0.5);
    GL11.glRotated(-pitch, 1, 0, 0);
    GL11.glRotated(-yaw, 0, 1, 0);
    GL11.glScaled(1 / boxScale, 1 / boxScale, 1 / boxScale);
    GL11.glTranslated(-0.5, -0.5, -0.5);
    if (!itemstack.isEmpty() && itemstack.getItem() instanceof LogisticsFluidContainer) {
        FluidIdentifierStack f = SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(ItemIdentifierStack.getFromStack(itemstack));
        if (f != null) {
        /*
				FluidContainerRenderer.skipNext = true;
				int list = getRenderListFor(f);
				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.glCallList(list);
				GL11.glPopAttrib();
				*/
        }
    }
    GL11.glPopMatrix();
}
Also used : FluidIdentifierStack(logisticspipes.utils.FluidIdentifierStack) LogisticsFluidContainer(logisticspipes.items.LogisticsFluidContainer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

FluidIdentifierStack (logisticspipes.utils.FluidIdentifierStack)8 FluidStack (net.minecraftforge.fluids.FluidStack)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 ITankUtil (logisticspipes.interfaces.ITankUtil)3 IProvideFluids (logisticspipes.interfaces.routing.IProvideFluids)3 LogisticsFluidContainer (logisticspipes.items.LogisticsFluidContainer)3 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)3 FluidIdentifier (logisticspipes.utils.FluidIdentifier)3 FluidSinkReply (logisticspipes.utils.FluidSinkReply)3 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)3 Pair (logisticspipes.utils.tuples.Pair)3 Optional (java.util.Optional)2 TreeSet (java.util.TreeSet)2 Collectors (java.util.stream.Collectors)2 Nullable (javax.annotation.Nullable)2 LPItems (logisticspipes.LPItems)2 IFluidSink (logisticspipes.interfaces.routing.IFluidSink)2