Compare commits

...
Author SHA1 Message Date
Martin Robertz efd579bfae update 2025-03-23 13:06:01 +01:00
Guillaume Mercier b0583a32cb Make the fluid monitor more resilient.
- Add checks via the can drain and can fill methods of fluid tanks to prevent dupe bugs like the one encountered with the blockhead sink

the blockhead sink doesn't check the fluid passed to it during the drain or fill calls so it ended up draining itself instead of the required fluid when ever it was working

Adding some some sort of logging if the fluid extracted and the fluid requested aren't the same would be a good idea, and since there is no caching from the simulate phase, it's going to have to be done in both phases. It shouldn't just void the output though since the changes will have already been applied to the tank by the time we void out the values and we can't assume the fill function would work properly if the drain doesn't.
2025-03-22 23:12:20 -04:00
2 changed files with 8 additions and 1 deletions

No files matched your search

+1 -1
View File
@@ -47,7 +47,7 @@ dependencies {
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.1.6-GTNH:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.5:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.5:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.6:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.189:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
@@ -57,6 +57,10 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
}
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
if (!this.handler.canFill(this.side, input.getFluid())) {
return null;
}
int filled = this.handler.fill(this.side, input.getFluidStack(), type == Actionable.MODULATE);
if (type == Actionable.MODULATE) {
@@ -73,6 +77,9 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
}
public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) {
if (!this.handler.canDrain(this.side, request.getFluid())) {
return null;
}
FluidStack removed = this.handler.drain(this.side, request.getFluidStack(), type == Actionable.MODULATE);
if (removed != null && removed.amount != 0) {
IAEFluidStack o = request.copy();