use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class LogisticsFluidManager method getBestReply.
@Override
public Pair<Integer, Integer> getBestReply(FluidStack stack, IRouter sourceRouter, List<Integer> jamList) {
for (ExitRoute candidateRouter : sourceRouter.getIRoutersByCost()) {
if (!candidateRouter.containsFlag(PipeRoutingConnectionType.canRouteTo)) {
continue;
}
if (candidateRouter.destination.getSimpleID() == sourceRouter.getSimpleID()) {
continue;
}
if (jamList.contains(candidateRouter.destination.getSimpleID())) {
continue;
}
if (candidateRouter.destination.getPipe() == null || !candidateRouter.destination.getPipe().isEnabled()) {
continue;
}
CoreRoutedPipe pipe = candidateRouter.destination.getPipe();
if (!(pipe instanceof IFluidSink)) {
continue;
}
int amount = ((IFluidSink) pipe).sinkAmount(stack);
if (amount > 0) {
Pair<Integer, Integer> result = new Pair<>(candidateRouter.destination.getSimpleID(), amount);
return result;
}
}
Pair<Integer, Integer> result = new Pair<>(0, 0);
return result;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class LogisticsManager method getBestReply.
private Triplet<Integer, SinkReply, List<IFilter>> getBestReply(ItemIdentifier stack, IRouter sourceRouter, List<ExitRoute> validDestinations, boolean excludeSource, List<Integer> jamList, Triplet<Integer, SinkReply, List<IFilter>> result, boolean allowDefault) {
if (result == null) {
result = new Triplet<>(null, null, null);
}
outer: for (ExitRoute candidateRouter : validDestinations) {
if (excludeSource) {
if (candidateRouter.destination.getId().equals(sourceRouter.getId())) {
continue;
}
}
if (jamList.contains(candidateRouter.destination.getSimpleID())) {
continue;
}
if (!candidateRouter.containsFlag(PipeRoutingConnectionType.canRouteTo)) {
continue;
}
for (IFilter filter : candidateRouter.filters) {
if (filter.blockRouting() || (filter.isBlocked() == filter.isFilteredItem(stack))) {
continue outer;
}
}
SinkReply reply = LogisticsManager.canSink(candidateRouter.destination, sourceRouter, excludeSource, stack, result.getValue2(), false, allowDefault);
if (reply == null) {
continue;
}
if (result.getValue1() == null) {
result.setValue1(candidateRouter.destination.getSimpleID());
result.setValue2(reply);
List<IFilter> list = new LinkedList<>();
result.setValue3(list);
continue;
}
if (reply.fixedPriority.ordinal() > result.getValue2().fixedPriority.ordinal()) {
result.setValue1(candidateRouter.destination.getSimpleID());
result.setValue2(reply);
List<IFilter> list = new LinkedList<>();
result.setValue3(list);
continue;
}
if (reply.fixedPriority == result.getValue2().fixedPriority && reply.customPriority > result.getValue2().customPriority) {
result.setValue1(candidateRouter.destination.getSimpleID());
result.setValue2(reply);
List<IFilter> list = new LinkedList<>();
result.setValue3(list);
continue;
}
}
if (result.getValue1() != null) {
CoreRoutedPipe pipe = SimpleServiceLocator.routerManager.getRouterUnsafe(result.getValue1(), false).getPipe();
pipe.useEnergy(result.getValue2().energyUse);
pipe.spawnParticle(Particles.BlueParticle, 10);
}
return result;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class PipeController method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
LogisticsTileGenericPipe tile = getPipe(player.getEntityWorld());
if (tile == null || !(tile.pipe instanceof CoreRoutedPipe)) {
return null;
}
final CoreRoutedPipe pipe = (CoreRoutedPipe) tile.pipe;
DummyContainer dummy = new DummyContainer(player, null, pipe.getOriginalUpgradeManager().getGuiController(), new IGuiOpenControler() {
//Network Statistics
@Override
public void guiOpenedByPlayer(EntityPlayer player) {
pipe.playerStartWatching(player, 0);
}
@Override
public void guiClosedByPlayer(EntityPlayer player) {
pipe.playerStopWatching(player, 0);
}
});
dummy.addNormalSlotsForPlayerInventory(0, 0);
// TAB_1 SLOTS
for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
dummy.addUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot, 8 + pipeSlot * 18, 18, itemStack -> {
if (itemStack == null) {
return false;
}
if (itemStack.getItem() == LogisticsPipes.UpgradeItem) {
if (!LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null).isAllowedForPipe(pipe)) {
return false;
}
} else {
return false;
}
return true;
});
}
for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
dummy.addSneakyUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot + 9, 8 + pipeSlot * 18, 48, itemStack -> {
if (itemStack == null) {
return false;
}
if (itemStack.getItem() == LogisticsPipes.UpgradeItem) {
IPipeUpgrade upgrade = LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null);
if (!(upgrade instanceof SneakyUpgrade) && !(upgrade instanceof SneakyUpgradeConfig)) {
return false;
}
if (!upgrade.isAllowedForPipe(pipe)) {
return false;
}
} else {
return false;
}
return true;
});
}
// TAB_2 SLOTS
dummy.addStaticRestrictedSlot(0, pipe.getOriginalUpgradeManager().getSecInv(), 8 + 8 * 18, 18, itemStack -> {
if (itemStack == null) {
return false;
}
if (itemStack.getItem() != LogisticsPipes.LogisticsItemCard) {
return false;
}
if (itemStack.getItemDamage() != LogisticsItemCard.SEC_CARD) {
return false;
}
return SimpleServiceLocator.securityStationManager.isAuthorized(UUID.fromString(itemStack.getTagCompound().getString("UUID")));
}, 1);
dummy.addRestrictedSlot(0, tile.logicController.diskInv, 14, 36, LogisticsPipes.LogisticsItemDisk);
return dummy;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class ItemAmountSignGui method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
LogisticsTileGenericPipe pipe = getPipe(player.getEntityWorld());
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
return null;
}
ItemAmountPipeSign sign = ((ItemAmountPipeSign) ((CoreRoutedPipe) pipe.pipe).getPipeSign(dir));
DummyContainer dummy = new DummyContainer(player.inventory, sign.itemTypeInv);
dummy.addDummySlot(0, 0, 0);
dummy.addNormalSlotsForPlayerInventory(0, 0);
return dummy;
}
use of logisticspipes.pipes.basic.CoreRoutedPipe in project LogisticsPipes by RS485.
the class RequestAmountTaskSubGui method processPacket.
@Override
public void processPacket(EntityPlayer player) {
LogisticsStatisticsTileEntity tile = this.getTile(player.getEntityWorld(), LogisticsStatisticsTileEntity.class);
CoreRoutedPipe pipe = tile.getConnectedPipe();
if (pipe == null) {
return;
}
Map<ItemIdentifier, Integer> _availableItems = SimpleServiceLocator.logisticsManager.getAvailableItems(pipe.getRouter().getIRoutersByCost());
LinkedList<ItemIdentifier> _craftableItems = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
TreeSet<ItemIdentifierStack> _allItems = new TreeSet<>();
for (Entry<ItemIdentifier, Integer> item : _availableItems.entrySet()) {
ItemIdentifierStack newStack = item.getKey().makeStack(item.getValue());
_allItems.add(newStack);
}
for (ItemIdentifier item : _craftableItems) {
if (_availableItems.containsKey(item)) {
continue;
}
_allItems.add(item.makeStack(0));
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(AmountTaskSubGui.class).setIdentSet(_allItems), player);
}
Aggregations