From c6c5d162a1292aa6b8a255104b76df9cb0aa7d98 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 18 Aug 2024 14:29:36 +0200 Subject: [PATCH] Fix fluid autocrafting (#221) * Fix fluid autocrafting Depends on https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial/pull/545 * update * update * rename * Add FluidCraftingInventoryHandler so that fluid crafting isn't handled in Pass 2 * update deps --------- Co-authored-by: hiroscho Co-authored-by: Dream Master --- dependencies.gradle | 20 +++++------ settings.gradle | 2 +- .../common/tile/TileFluidDiscretizer.java | 35 ++++++++++++++++++- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 4c43d268..29b5ba65 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -34,28 +34,28 @@ * For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph */ dependencies { - api('com.github.GTNewHorizons:NotEnoughItems:2.6.19-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-423-GTNH:dev') + api('com.github.GTNewHorizons:NotEnoughItems:2.6.25-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-428:dev') api('curse.maven:cofh-core-69162:2388751') api('com.github.GTNewHorizons:waila:1.8.1:dev') - implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.5:dev") + implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.11.6:dev") - compileOnly("com.github.GTNewHorizons:GTNHLib:0.3.3:dev") { transitive = false } + compileOnly("com.github.GTNewHorizons:GTNHLib:0.4.3:dev") { transitive = false } compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') - compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false } + compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false } compileOnly('com.github.GTNewHorizons:ForestryMC:4.9.7:dev') compileOnly('com.github.GTNewHorizons:EnderIO:2.8.17:dev') - compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.48.123:dev') { + compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.49.04:dev') { exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework' } compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false } - compileOnly('com.github.GTNewHorizons:OpenComputers:1.10.18-GTNH:dev') { transitive = false } - compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.6.21-GTNH:dev') { transitive = false } - compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.38:dev") { transitive = false } + compileOnly('com.github.GTNewHorizons:OpenComputers:1.10.20-GTNH:dev') { transitive = false } + compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.6.22-GTNH:dev') { transitive = false } + compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.42:dev") { transitive = false } runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.2:dev") - runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:0.3.3:dev") + runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:0.4.3:dev") } diff --git a/settings.gradle b/settings.gradle index 54797868..242692e5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,7 +17,7 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.25' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26' } diff --git a/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java b/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java index bedb3c53..e2173a12 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java @@ -264,9 +264,42 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost } } + private class FluidCraftingInventoryHandler extends MEInventoryHandler { + + public FluidCraftingInventoryHandler(IMEInventory i, StorageChannel channel) { + super(i, channel); + } + + @Override + public boolean isPrioritized(IAEFluidStack input) { + return true; + } + + @Override + public boolean canAccept(IAEFluidStack input) { + ICraftingGrid craftingGrid; + try { + craftingGrid = getProxy().getGrid().getCache(ICraftingGrid.class); + } catch (GridAccessException e) { + return false; + } + if (craftingGrid instanceof CraftingGridCache craftingGridCache) { + return craftingGridCache.canAccept(ItemFluidDrop.newAeStack(input)); + } + return false; + } + + @Override + public boolean isAutoCraftingInventory() { + return true; + } + } + private class FluidCraftingInventory implements IMEInventory { - private final MEInventoryHandler invHandler = new MEInventoryHandler<>(this, getChannel()); + private final MEInventoryHandler invHandler = new FluidCraftingInventoryHandler( + this, + getChannel()); FluidCraftingInventory() { invHandler.setPriority(Integer.MAX_VALUE);