Fixes #4683: Hopefully LazyOptional works as advertised (#4684)

This commit is contained in:
yueh
2020-09-02 21:36:40 +02:00
committed by GitHub
parent f0d0595c8f
commit 39e038d916
@@ -96,16 +96,15 @@ public class FluidImportBusPart extends SharedFluidBusPart {
}
final TileEntity te = this.getConnectedTE();
LazyOptional<IFluidHandler> fhOpt = LazyOptional.empty();
if (te != null) {
te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, this.getSide().getFacing().getOpposite());
}
if (fhOpt.isPresent()) {
try {
final IFluidHandler fh = fhOpt.orElse(null);
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory(this.getChannel());
LazyOptional<IFluidHandler> fhOpt = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,
this.getSide().getFacing().getOpposite());
if (fhOpt.isPresent()) {
try {
final IFluidHandler fh = fhOpt.orElseThrow(() -> new IllegalStateException());
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getInventory(this.getChannel());
if (fh != null) {
final FluidStack fluidStack = fh.drain(this.calculateAmountToSend(), FluidAction.SIMULATE);
if (this.filterEnabled() && !this.isInFilter(fluidStack)) {
@@ -128,12 +127,11 @@ public class FluidImportBusPart extends SharedFluidBusPart {
}
return TickRateModulation.IDLE;
} catch (GridAccessException e) {
// skip
}
} catch (GridAccessException e) {
e.printStackTrace();
}
}
return TickRateModulation.SLEEP;
}