From 3314e31bdc38fc9f60ac0a51948509aadf466557 Mon Sep 17 00:00:00 2001 From: hiroscho Date: Sat, 23 Nov 2024 00:27:51 +0100 Subject: [PATCH] Fix fluid is registered twice in crafting CPU (#237) Co-authored-by: Martin Robertz --- .../common/tile/TileFluidDiscretizer.java | 93 +------------------ 1 file changed, 2 insertions(+), 91 deletions(-) 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 e2173a126..57500298e 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileFluidDiscretizer.java @@ -12,7 +12,6 @@ import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.networking.GridFlags; -import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.events.MENetworkCellArrayUpdate; import appeng.api.networking.events.MENetworkChannelsChanged; @@ -31,11 +30,9 @@ import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; import appeng.helpers.IPriorityHost; import appeng.me.GridAccessException; -import appeng.me.cache.CraftingGridCache; import appeng.me.storage.MEInventoryHandler; import appeng.tile.grid.AENetworkTile; @@ -43,7 +40,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost private final BaseActionSource ownActionSource = new MachineSource(this); private final FluidDiscretizingInventory fluidDropInv = new FluidDiscretizingInventory(); - private final FluidCraftingInventory fluidCraftInv = new FluidCraftingInventory(); private boolean prevActiveState = false; public TileFluidDiscretizer() { @@ -60,12 +56,8 @@ public boolean canBeRotated() { @Override @SuppressWarnings("rawtypes") public List getCellArray(StorageChannel channel) { - if (getProxy().isActive()) { - if (channel == StorageChannel.ITEMS) { - return Collections.singletonList(fluidDropInv.invHandler); - } else if (channel == StorageChannel.FLUIDS) { - return Collections.singletonList(fluidCraftInv.invHandler); - } + if (channel == StorageChannel.ITEMS && getProxy().isActive()) { + return Collections.singletonList(fluidDropInv.invHandler); } return Collections.emptyList(); } @@ -263,85 +255,4 @@ public void onListUpdate() { // NO-OP } } - - 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 FluidCraftingInventoryHandler( - this, - getChannel()); - - FluidCraftingInventory() { - invHandler.setPriority(Integer.MAX_VALUE); - } - - @Override - @SuppressWarnings("rawtypes") - public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) { - ICraftingGrid craftingGrid; - try { - craftingGrid = getProxy().getGrid().getCache(ICraftingGrid.class); - } catch (GridAccessException e) { - return null; - } - if (craftingGrid instanceof CraftingGridCache) { - IAEStack remaining = ((CraftingGridCache) craftingGrid) - .injectItems(ItemFluidDrop.newAeStack(input), type, ownActionSource); - if (remaining instanceof IAEItemStack) { - return ItemFluidDrop.getAeFluidStack((IAEItemStack) remaining); - } - } - return null; - } - - @Override - public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) { - return null; - } - - @Override - public IItemList getAvailableItems(IItemList out, int iteration) { - return out; - } - - @Override - public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) { - return null; - } - - @Override - public StorageChannel getChannel() { - return StorageChannel.FLUIDS; - } - } }