use of logisticspipes.utils.item.ItemIdentifierStack 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 (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
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, Integer> result = SimpleServiceLocator.logisticsFluidManager.getBestReply(stack, getRouter(), tempJamList);
if (result == null || result.getValue1() == null || result.getValue1() == 0 || result.getValue2() == 0) {
nextSendMax[dir.ordinal()] = 100;
nextSendMin[dir.ordinal()] = 10;
continue;
}
if (!useEnergy((int) (0.01 * result.getValue2()))) {
nextSendMax[dir.ordinal()] = 100;
nextSendMin[dir.ordinal()] = 10;
continue;
}
FluidStack toSend = transport.sideTanks[dir.ordinal()].drain(result.getValue2(), true);
ItemIdentifierStack liquidContainer = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(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;
}
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class PipeItemsInvSysConnector method getExpectedItems.
public Set<ItemIdentifierStack> getExpectedItems() {
// got to be a TreeMap, because a TreeSet doesn't have the ability to retrieve the key.
Set<ItemIdentifierStack> list = new TreeSet<>();
for (Entry<ItemIdentifier, List<ItemRoutingInformation>> entry : itemsOnRoute.entrySet()) {
if (entry.getValue().isEmpty()) {
continue;
}
ItemIdentifierStack currentStack = new ItemIdentifierStack(entry.getKey(), 0);
for (ItemRoutingInformation e : entry.getValue()) {
currentStack.setStackSize(currentStack.getStackSize() + e.getItem().getStackSize());
}
list.add(currentStack);
}
return list;
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class PipeItemsProviderLogistics method updateInv.
private void updateInv(EntityPlayer player) {
if (localModeWatchers.size() == 0 && player == null) {
return;
}
displayList.clear();
displayMap.clear();
getAllItems(displayMap, new ArrayList<>(0));
displayList.ensureCapacity(displayMap.size());
displayList.addAll(displayMap.entrySet().stream().map(item -> new ItemIdentifierStack(item.getKey(), item.getValue())).collect(Collectors.toList()));
if (!oldList.equals(displayList)) {
oldList.clear();
oldList.ensureCapacity(displayList.size());
oldList.addAll(displayList);
MainProxy.sendToPlayerList(PacketHandler.getPacket(ChestContent.class).setIdentList(displayList).setPosX(getX()).setPosY(getY()).setPosZ(getZ()), localModeWatchers);
} else if (player != null) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(ChestContent.class).setIdentList(displayList).setPosX(getX()).setPosY(getY()).setPosZ(getZ()), player);
}
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class CraftingPipeSign method getRenderData.
@Override
public IPipeSignData getRenderData(CoreRoutedPipe pipe) {
PipeItemsCraftingLogistics cpipe = (PipeItemsCraftingLogistics) pipe;
if (cpipe != null) {
List<ItemIdentifierStack> craftables = cpipe.getCraftedItems();
if (craftables != null && craftables.size() > 0) {
ItemIdentifierStack itemIdentifierStack = craftables.get(0);
ModuleCrafter logisticsMod = cpipe.getLogisticsModule();
return new CraftingPipeSignData(itemIdentifierStack, logisticsMod.satelliteId);
} else {
return new CraftingPipeSignData(null, -1);
}
}
return null;
}
use of logisticspipes.utils.item.ItemIdentifierStack in project LogisticsPipes by RS485.
the class LogisticsCraftingTable method importRecipe.
@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
if (!(tile instanceof LogisticsCraftingTableTileEntity)) {
return false;
}
LogisticsCraftingTableTileEntity bench = (LogisticsCraftingTableTileEntity) tile;
ItemIdentifierStack result = bench.resultInv.getIDStackInSlot(0);
if (result == null) {
return false;
}
inventory.setInventorySlotContents(9, result);
// Import
for (int i = 0; i < bench.matrix.getSizeInventory(); i++) {
if (i >= inventory.getSizeInventory() - 2) {
break;
}
final ItemStack newStack = bench.matrix.getStackInSlot(i) == null ? null : bench.matrix.getStackInSlot(i).copy();
if (newStack != null && newStack.stackSize > 1) {
newStack.stackSize = 1;
}
inventory.setInventorySlotContents(i, newStack);
}
if (!bench.isFuzzy()) {
inventory.compact_first(9);
}
return true;
}
Aggregations