Search in sources :

Example 6 with ChassiTargetInformation

use of logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation in project LogisticsPipes by RS485.

the class PipeTransportLogistics method handleTileReachedServer_internal.

protected final void handleTileReachedServer_internal(LPTravelingItemServer arrivingItem, TileEntity tile, EnumFacing dir) {
    if (getPipe() instanceof PipeItemsFluidSupplier) {
        ((PipeItemsFluidSupplier) getPipe()).endReached(arrivingItem, tile);
        if (arrivingItem.getItemIdentifierStack().getStackSize() <= 0) {
            return;
        }
    }
    markChunkModified(tile);
    if (arrivingItem.getInfo() != null && arrivingItem.getArrived() && isRouted) {
        getRoutedPipe().notifyOfItemArival(arrivingItem.getInfo());
    }
    if (getPipe() instanceof FluidRoutedPipe) {
        if (((FluidRoutedPipe) getPipe()).endReached(arrivingItem, tile)) {
            return;
        }
    }
    boolean isSpecialConnectionInformationTransition = false;
    if (SimpleServiceLocator.specialtileconnection.needsInformationTransition(tile)) {
        isSpecialConnectionInformationTransition = true;
        SimpleServiceLocator.specialtileconnection.transmit(tile, arrivingItem);
    }
    if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
        if (passToNextPipe(arrivingItem, tile)) {
            return;
        }
    } else {
        IInventoryUtil util = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(tile, dir.getOpposite());
        if (util != null && isRouted) {
            getRoutedPipe().getCacheHolder().trigger(CacheTypes.Inventory);
            // destroy the item on exit if it isn't exitable
            if (!isSpecialConnectionInformationTransition && isItemUnwanted(arrivingItem.getItemIdentifierStack())) {
                return;
            }
            // last chance for chassi to back out
            if (arrivingItem.getTransportMode() != TransportMode.Active && !getRoutedPipe().getTransportLayer().stillWantItem(arrivingItem)) {
                reverseItem(arrivingItem);
                return;
            }
            final ISlotUpgradeManager slotManager;
            {
                ModulePositionType slot = null;
                int positionInt = -1;
                if (arrivingItem.getInfo().targetInfo instanceof ChassiTargetInformation) {
                    positionInt = ((ChassiTargetInformation) arrivingItem.getInfo().targetInfo).getModuleSlot();
                    slot = ModulePositionType.SLOT;
                } else if (LogisticsPipes.isDEBUG() && container.pipe instanceof PipeLogisticsChassis) {
                    System.out.println(arrivingItem);
                    new RuntimeException("[ItemInsertion] Information weren't ment for a chassi pipe").printStackTrace();
                }
                slotManager = getRoutedPipe().getUpgradeManager(slot, positionInt);
            }
            if (arrivingItem.getAdditionalTargetInformation() instanceof ITargetSlotInformation) {
                ITargetSlotInformation information = (ITargetSlotInformation) arrivingItem.getAdditionalTargetInformation();
                if (util instanceof ISpecialInsertion) {
                    int slot = information.getTargetSlot();
                    int amount = information.getAmount();
                    if (util.getSizeInventory() > slot) {
                        ItemStack content = util.getStackInSlot(slot);
                        ItemStack toAdd = arrivingItem.getItemIdentifierStack().makeNormalStack();
                        final int amountLeft = Math.max(0, amount - content.getCount());
                        toAdd.setCount(Math.min(toAdd.getCount(), amountLeft));
                        if (toAdd.getCount() > 0) {
                            if (util.getSizeInventory() > slot) {
                                int added = ((ISpecialInsertion) util).addToSlot(toAdd, slot);
                                arrivingItem.getItemIdentifierStack().lowerStackSize(added);
                            }
                        }
                    }
                    if (information.isLimited()) {
                        if (arrivingItem.getItemIdentifierStack().getStackSize() > 0) {
                            reverseItem(arrivingItem);
                        }
                        return;
                    }
                }
            }
            // sneaky insertion
            if (!getRoutedPipe().getUpgradeManager().hasCombinedSneakyUpgrade() || slotManager.hasOwnSneakyUpgrade()) {
                EnumFacing insertion = arrivingItem.output.getOpposite();
                if (slotManager.hasSneakyUpgrade()) {
                    insertion = slotManager.getSneakyOrientation();
                }
                if (insertArrivingItem(arrivingItem, tile, insertion))
                    return;
            } else {
                EnumFacing[] dirs = getRoutedPipe().getUpgradeManager().getCombinedSneakyOrientation();
                for (EnumFacing insertion : dirs) {
                    if (insertion == null) {
                        continue;
                    }
                    if (insertArrivingItem(arrivingItem, tile, insertion))
                        return;
                }
            }
            if (arrivingItem.getItemIdentifierStack().getStackSize() > 0) {
                reverseItem(arrivingItem);
            }
            // the item is handled
            return;
        }
    // end of insert into IInventory
    }
    dropItem(arrivingItem);
}
Also used : ITargetSlotInformation(logisticspipes.interfaces.routing.ITargetSlotInformation) FluidRoutedPipe(logisticspipes.pipes.basic.fluid.FluidRoutedPipe) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) EnumFacing(net.minecraft.util.EnumFacing) PipeLogisticsChassis(logisticspipes.pipes.PipeLogisticsChassis) ModulePositionType(logisticspipes.modules.LogisticsModule.ModulePositionType) PipeItemsFluidSupplier(logisticspipes.pipes.PipeItemsFluidSupplier) ISpecialInsertion(logisticspipes.interfaces.ISpecialInsertion) ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) ItemStack(net.minecraft.item.ItemStack) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager)

Example 7 with ChassiTargetInformation

use of logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation in project LogisticsPipes by RS485.

the class ModuleCrafter method registerPosition.

@Override
public void registerPosition(@Nonnull ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.ItemSink, 0, true, false, 1, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Example 8 with ChassiTargetInformation

use of logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation in project LogisticsPipes by RS485.

the class ModuleEnchantmentSink method registerPosition.

@Override
public void registerPosition(@Nonnull ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.EnchantmentItemSink, 0, true, false, 1, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Example 9 with ChassiTargetInformation

use of logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation in project LogisticsPipes by RS485.

the class ModuleModBasedItemSink method registerPosition.

@Override
public void registerPosition(@Nonnull ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.ModBasedItemSink, 0, true, false, 5, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Example 10 with ChassiTargetInformation

use of logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation in project LogisticsPipes by RS485.

the class ModulePolymorphicItemSink method registerPosition.

@Override
public void registerPosition(@Nonnull ModulePositionType slot, int positionInt) {
    super.registerPosition(slot, positionInt);
    _sinkReply = new SinkReply(FixedPriority.ItemSink, 0, true, false, 3, 0, new ChassiTargetInformation(getPositionInt()));
}
Also used : ChassiTargetInformation(logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation) SinkReply(logisticspipes.utils.SinkReply)

Aggregations

ChassiTargetInformation (logisticspipes.pipes.PipeLogisticsChassis.ChassiTargetInformation)12 SinkReply (logisticspipes.utils.SinkReply)11 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)1 ISlotUpgradeManager (logisticspipes.interfaces.ISlotUpgradeManager)1 ISpecialInsertion (logisticspipes.interfaces.ISpecialInsertion)1 ITargetSlotInformation (logisticspipes.interfaces.routing.ITargetSlotInformation)1 ModulePositionType (logisticspipes.modules.LogisticsModule.ModulePositionType)1 PipeItemsFluidSupplier (logisticspipes.pipes.PipeItemsFluidSupplier)1 PipeLogisticsChassis (logisticspipes.pipes.PipeLogisticsChassis)1 FluidRoutedPipe (logisticspipes.pipes.basic.fluid.FluidRoutedPipe)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1