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);
}
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()));
}
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()));
}
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()));
}
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()));
}
Aggregations