use of mekanism.api.chemical.slurry.ISlurryHandler in project Mekanism by mekanism.
the class BoxedChemicalAcceptorCache method isChemicalAcceptorAndListen.
public boolean isChemicalAcceptorAndListen(@Nullable TileEntity tile, Direction side) {
// TODO: Improve this to make it easier to add more chemical types
Direction opposite = side.getOpposite();
LazyOptional<IGasHandler> gasAcceptor = CapabilityUtils.getCapability(tile, Capabilities.GAS_HANDLER_CAPABILITY, opposite);
LazyOptional<IInfusionHandler> infusionAcceptor = CapabilityUtils.getCapability(tile, Capabilities.INFUSION_HANDLER_CAPABILITY, opposite);
LazyOptional<IPigmentHandler> pigmentAcceptor = CapabilityUtils.getCapability(tile, Capabilities.PIGMENT_HANDLER_CAPABILITY, opposite);
LazyOptional<ISlurryHandler> slurryAcceptor = CapabilityUtils.getCapability(tile, Capabilities.SLURRY_HANDLER_CAPABILITY, opposite);
if (gasAcceptor.isPresent() || infusionAcceptor.isPresent() || pigmentAcceptor.isPresent() || slurryAcceptor.isPresent()) {
BoxedChemicalHandler chemicalHandler = new BoxedChemicalHandler();
if (gasAcceptor.isPresent()) {
chemicalHandler.addGasHandler(gasAcceptor);
}
if (infusionAcceptor.isPresent()) {
chemicalHandler.addInfusionHandler(infusionAcceptor);
}
if (pigmentAcceptor.isPresent()) {
chemicalHandler.addPigmentHandler(pigmentAcceptor);
}
if (slurryAcceptor.isPresent()) {
chemicalHandler.addSlurryHandler(slurryAcceptor);
}
// Update the cached acceptor and if it changed, add a listener to it to listen for invalidation
updateCachedAcceptorAndListen(side, tile, chemicalHandler);
return true;
}
return false;
}
Aggregations