use of mekanism.common.content.network.distribution.ChemicalHandlerTarget in project Mekanism by mekanism.
the class BoxedChemicalNetwork method tickEmit.
private <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<CHEMICAL>> long tickEmit(@Nonnull STACK stack) {
ChemicalType chemicalType = ChemicalType.getTypeFor(stack);
Collection<Map<Direction, LazyOptional<BoxedChemicalHandler>>> acceptorValues = acceptorCache.getAcceptorValues();
ChemicalHandlerTarget<CHEMICAL, STACK, IChemicalHandler<CHEMICAL, STACK>> target = new ChemicalHandlerTarget<>(stack, acceptorValues.size() * 2);
for (Map<Direction, LazyOptional<BoxedChemicalHandler>> acceptors : acceptorValues) {
for (LazyOptional<BoxedChemicalHandler> lazyAcceptor : acceptors.values()) {
lazyAcceptor.ifPresent(acceptor -> {
IChemicalHandler<CHEMICAL, STACK> handler = acceptor.getHandlerFor(chemicalType);
if (handler != null && ChemicalUtil.canInsert(handler, stack)) {
target.addHandler(handler);
}
});
}
}
return EmitUtils.sendToAcceptors(target, stack.getAmount(), stack);
}
Aggregations