use of logisticspipes.logisticspipes.IRoutedItem in project LogisticsPipes by RS485.
the class PipeBlockRequestTable method enabledUpdateEntity.
@Override
public void enabledUpdateEntity() {
super.enabledUpdateEntity();
ItemStack stack = toSortInv.getStackInSlot(0);
if (!stack.isEmpty()) {
if (delay > 0) {
delay--;
return;
}
IRoutedItem itemToSend = SimpleServiceLocator.routedItemHelper.createNewTravelItem(stack);
SimpleServiceLocator.logisticsManager.assignDestinationFor(itemToSend, getRouter().getSimpleID(), false);
if (itemToSend.getDestinationUUID() != null) {
EnumFacing dir = getRouteLayer().getOrientationForItem(itemToSend, null);
super.queueRoutedItem(itemToSend, dir.getOpposite());
spawnParticle(Particles.OrangeParticle, 4);
toSortInv.clearInventorySlotContents(0);
} else {
delay = 100;
}
} else {
delay = 0;
}
}
use of logisticspipes.logisticspipes.IRoutedItem in project LogisticsPipes by RS485.
the class PipeFluidInsertion method enabledUpdateEntity.
@Override
public void enabledUpdateEntity() {
super.enabledUpdateEntity();
List<Integer> tempJamList = new ArrayList<>();
if (!localJamList.isEmpty()) {
List<Pair<Integer, Integer>> toRemove = new ArrayList<>();
for (Pair<Integer, Integer> part : localJamList) {
part.setValue2(part.getValue2() - 1);
if (part.getValue2() <= 0) {
toRemove.add(part);
} else {
tempJamList.add(part.getValue1());
}
}
if (!toRemove.isEmpty()) {
localJamList.removeAll(toRemove);
}
}
PipeFluidTransportLogistics transport = (PipeFluidTransportLogistics) this.transport;
for (EnumFacing dir : EnumFacing.VALUES) {
FluidStack stack = transport.sideTanks[dir.ordinal()].getFluid();
if (stack == null) {
continue;
}
stack = stack.copy();
if (nextSendMax[dir.ordinal()] > 0 && stack.amount < transport.sideTanks[dir.ordinal()].getCapacity()) {
nextSendMax[dir.ordinal()]--;
continue;
}
if (nextSendMin[dir.ordinal()] > 0) {
nextSendMin[dir.ordinal()]--;
continue;
}
Pair<Integer, FluidSinkReply> result = SimpleServiceLocator.logisticsFluidManager.getBestReply(FluidIdentifierStack.getFromStack(stack), getRouter(), tempJamList);
if (result == null || result.getValue2().sinkAmount <= 0) {
nextSendMax[dir.ordinal()] = 100;
nextSendMin[dir.ordinal()] = 10;
continue;
}
if (!useEnergy((int) (0.01 * result.getValue2().getSinkAmountInt()))) {
nextSendMax[dir.ordinal()] = 100;
nextSendMin[dir.ordinal()] = 10;
continue;
}
FluidStack toSend = transport.sideTanks[dir.ordinal()].drain(result.getValue2().getSinkAmountInt(), true);
ItemIdentifierStack liquidContainer = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(FluidIdentifierStack.getFromStack(toSend));
IRoutedItem routed = SimpleServiceLocator.routedItemHelper.createNewTravelItem(liquidContainer);
routed.setDestination(result.getValue1());
routed.setTransportMode(TransportMode.Passive);
this.queueRoutedItem(routed, dir);
nextSendMax[dir.ordinal()] = 100;
nextSendMin[dir.ordinal()] = 5;
}
}
Aggregations