From facc1b4ef48343705b1c6271bbf38c8fb896209b Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Tue, 10 Aug 2021 23:43:44 -0300 Subject: [PATCH] prevent crafting job to be fired if its a pattern failed previously till the lack of ingredient that caused the failure is satisfied --- gradle.properties | 2 +- .../java/appeng/crafting/CraftingJob.java | 15 +- .../appeng/crafting/CraftingTreeNode.java | 32 ++++ .../appeng/crafting/CraftingTreeProcess.java | 18 +- .../java/appeng/helpers/DualityInterface.java | 20 +-- .../appeng/helpers/MultiCraftingTracker.java | 18 +- .../appeng/me/cache/CraftingGridCache.java | 14 +- .../appeng/me/cache/GridStorageCache.java | 18 ++ .../java/appeng/me/cache/NetworkMonitor.java | 64 +++++++ .../me/helpers/PatternStatusManager.java | 166 ++++++++++++++++++ .../parts/automation/PartExportBus.java | 31 ++-- 11 files changed, 346 insertions(+), 52 deletions(-) create mode 100644 src/main/java/appeng/me/helpers/PatternStatusManager.java diff --git a/gradle.properties b/gradle.properties index 2cced3398..205149652 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ aechannel=stable aebuild=7 aegroup=appeng aebasename=appliedenergistics2 -trousers=omni-fixes-v46e +trousers=omni-fixes-v47 ######################################################### # Versions # diff --git a/src/main/java/appeng/crafting/CraftingJob.java b/src/main/java/appeng/crafting/CraftingJob.java index e3f2a84f7..b4e746efd 100644 --- a/src/main/java/appeng/crafting/CraftingJob.java +++ b/src/main/java/appeng/crafting/CraftingJob.java @@ -22,6 +22,7 @@ package appeng.crafting; import java.util.HashMap; import java.util.concurrent.TimeUnit; +import appeng.me.cache.CraftingGridCache; import com.google.common.base.Stopwatch; import net.minecraft.entity.player.EntityPlayer; @@ -71,6 +72,8 @@ public class CraftingJob implements Runnable, ICraftingJob private boolean done = false; private int time; private int incTime; + private final ICraftingGrid cc; + private final IStorageGrid sg; private World wrapWorld( final World w ) { @@ -84,10 +87,9 @@ public class CraftingJob implements Runnable, ICraftingJob this.actionSrc = actionSrc; this.callback = callback; - final ICraftingGrid cc = grid.getCache( ICraftingGrid.class ); - final IStorageGrid sg = grid.getCache( IStorageGrid.class ); - this.original = new MECraftingInventory( sg - .getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), actionSrc, false, false, false ); + this.cc = grid.getCache( ICraftingGrid.class ); + this.sg = grid.getCache( IStorageGrid.class ); + this.original = new MECraftingInventory( sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), actionSrc, false, false, false ); this.setTree( this.getCraftingTree( cc, what ) ); this.availableCheck = null; @@ -380,6 +382,11 @@ public class CraftingJob implements Runnable, ICraftingJob } } + public void addIncompletablePattern( ICraftingPatternDetails details, IAEItemStack stack ) + { + ( (CraftingGridCache) cc ).getPatternDebtManager().put( details, stack ); + } + private static class TwoIntegers { private final long perOp = 0; diff --git a/src/main/java/appeng/crafting/CraftingTreeNode.java b/src/main/java/appeng/crafting/CraftingTreeNode.java index b7cba1bf1..7426a5d6c 100644 --- a/src/main/java/appeng/crafting/CraftingTreeNode.java +++ b/src/main/java/appeng/crafting/CraftingTreeNode.java @@ -22,7 +22,10 @@ package appeng.crafting; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Optional; +import appeng.util.item.OreHelper; +import appeng.util.item.OreReference; import com.google.common.collect.Lists; import net.minecraft.world.World; @@ -117,6 +120,11 @@ public class CraftingTreeNode return this.parent.notRecursive( details ); } + public CraftingTreeProcess getParent() + { + return parent; + } + IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException { this.job.handlePausing(); @@ -318,6 +326,7 @@ public class CraftingTreeNode if( this.missing > 0 ) { job.addMissing( this.getStack( this.missing ) ); + addMissingIAEStack(); } // missing = 0; @@ -329,6 +338,29 @@ public class CraftingTreeNode } } + void addMissingIAEStack() + { + if( parent != null ) + { + parent.addMissingIAEStack(); + if( missing > 0 ) + { + if( this.parent.details.canSubstitute() && this.getSlot() >= 0 ) + { + final List substitutes = this.parent.details.getSubstituteInputs( this.slot ); + for( IAEItemStack stack : substitutes ) + { + job.addIncompletablePattern( this.getParent().details, stack.copy().setStackSize( this.missing ) ); + } + } + else + { + job.addIncompletablePattern( this.getParent().details, this.getStack( this.missing ) ); + } + } + } + } + IAEItemStack getStack( final long size ) { final IAEItemStack is = this.what.copy(); diff --git a/src/main/java/appeng/crafting/CraftingTreeProcess.java b/src/main/java/appeng/crafting/CraftingTreeProcess.java index 43aa7bf5a..f09921647 100644 --- a/src/main/java/appeng/crafting/CraftingTreeProcess.java +++ b/src/main/java/appeng/crafting/CraftingTreeProcess.java @@ -23,11 +23,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import appeng.me.cache.CraftingGridCache; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraftforge.fml.common.FMLCommonHandler; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -66,7 +65,7 @@ public class CraftingTreeProcess this.depth = depth; final World world = job.getWorld(); - if( details.isCraftable() ) + if( !( (CraftingGridCache) cc ).getPatternDebtManager().containsIncompletablePattern( details ) && details.isCraftable() ) { final IAEItemStack[] list = details.getInputs(); @@ -174,6 +173,11 @@ public class CraftingTreeProcess return this.parent == null || this.parent.notRecursive( details ); } + public CraftingTreeNode getParent() + { + return parent; + } + long getTimes( final long remaining, final long stackSize ) { if( this.limitQty || this.fullSimulation ) @@ -317,4 +321,12 @@ public class CraftingTreeProcess pro.getPlan( plan ); } } + + public void addMissingIAEStack() + { + if( parent != null ) + { + parent.addMissingIAEStack(); + } + } } diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 15c1e67bc..d62484a9d 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -24,9 +24,12 @@ import java.util.*; import javax.annotation.Nullable; import appeng.api.definitions.IItemDefinition; +import appeng.api.networking.crafting.*; import appeng.integration.modules.gregtech.GTCEInventoryAdaptor; +import appeng.me.cache.CraftingGridCache; import appeng.util.*; import appeng.util.inv.*; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableSet; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; @@ -65,10 +68,6 @@ import appeng.api.implementations.tiles.ICraftingMachine; import appeng.api.networking.GridFlags; import appeng.api.networking.IGrid; import appeng.api.networking.IGridNode; -import appeng.api.networking.crafting.ICraftingLink; -import appeng.api.networking.crafting.ICraftingPatternDetails; -import appeng.api.networking.crafting.ICraftingProvider; -import appeng.api.networking.crafting.ICraftingProviderHelper; import appeng.api.networking.energy.IEnergySource; import appeng.api.networking.events.MENetworkCraftingPatternChange; import appeng.api.networking.security.IActionHost; @@ -110,7 +109,6 @@ import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity; public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost { - private int[] failedCraftTriesSlot = {0,0,0,0,0,0,0,0,0}; public static final int NUMBER_OF_STORAGE_SLOTS = 9; public static final int NUMBER_OF_CONFIG_SLOTS = 9; @@ -931,17 +929,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null ) { - if (this.failedCraftTriesSlot[x] <= 0) - { - boolean crafted = this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(), - this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource ); - - if (crafted) this.failedCraftTriesSlot[x] = 0; - else{ - this.failedCraftTriesSlot[x] += 2; - } - } - this.failedCraftTriesSlot[x] -= 1; + return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource ); } } catch( final GridAccessException e ) diff --git a/src/main/java/appeng/helpers/MultiCraftingTracker.java b/src/main/java/appeng/helpers/MultiCraftingTracker.java index 464ef0716..9b04922ea 100644 --- a/src/main/java/appeng/helpers/MultiCraftingTracker.java +++ b/src/main/java/appeng/helpers/MultiCraftingTracker.java @@ -22,6 +22,9 @@ package appeng.helpers; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import appeng.api.networking.crafting.*; +import appeng.me.cache.CraftingGridCache; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableSet; import net.minecraft.nbt.NBTTagCompound; @@ -29,10 +32,6 @@ import net.minecraft.world.World; import appeng.api.AEApi; import appeng.api.networking.IGrid; -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.api.networking.crafting.ICraftingJob; -import appeng.api.networking.crafting.ICraftingLink; -import appeng.api.networking.crafting.ICraftingRequester; import appeng.api.networking.security.IActionSource; import appeng.api.storage.data.IAEItemStack; import appeng.util.InventoryAdaptor; @@ -132,6 +131,17 @@ public class MultiCraftingTracker final IAEItemStack aisC = ais.copy(); aisC.setStackSize( itemToCraft ); + CraftingGridCache cgc = (CraftingGridCache) cg; + + ImmutableCollection cl = cgc.getCraftingFor( aisC, null, 0, w ); + for( ICraftingPatternDetails craftingPatternDetails : cl ) + { + if( cgc.getPatternDebtManager().containsIncompletablePattern( craftingPatternDetails ) ) + { + return false; + } + } + this.setJob( x, cg.beginCraftingJob( w, g, mySrc, aisC, null ) ); } } diff --git a/src/main/java/appeng/me/cache/CraftingGridCache.java b/src/main/java/appeng/me/cache/CraftingGridCache.java index 76ee54a91..eaa91efa8 100644 --- a/src/main/java/appeng/me/cache/CraftingGridCache.java +++ b/src/main/java/appeng/me/cache/CraftingGridCache.java @@ -35,7 +35,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; -import appeng.api.storage.data.IAEFluidStack; +import appeng.me.helpers.PatternStatusManager; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; @@ -267,16 +267,17 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper // coalesce change events during a grid traversal to a single rebuild if (pauseRebuilds != 0) { - rebuildNeeded.add(this); + rebuildNeeded.add( this ); return; } - final Object2ObjectMap> oldItems = new Object2ObjectOpenHashMap<>(this.craftableItems); + final Object2ObjectMap> oldItems = new Object2ObjectOpenHashMap<>( this.craftableItems ); // erase list. this.craftingMethods.clear(); this.craftableItems.clear(); this.emitableItems.clear(); + ( (GridStorageCache) this.storageGrid ).clearDebts(); // re-create list.. for( final ICraftingProvider provider : this.craftingProviders ) @@ -648,7 +649,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper public boolean hasCpu( final ICraftingCPU cpu ) { - if (cpu instanceof CraftingCPUCluster) + if( cpu instanceof CraftingCPUCluster ) { return this.craftingCPUClusters.contains( (CraftingCPUCluster) cpu ); } @@ -660,6 +661,11 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper return this.interestManager; } + public PatternStatusManager getPatternDebtManager() + { + return ( (GridStorageCache) this.storageGrid ).getPatternStatusManager(); + } + private static class ActiveCpuIterator implements Iterator { diff --git a/src/main/java/appeng/me/cache/GridStorageCache.java b/src/main/java/appeng/me/cache/GridStorageCache.java index 15f7cd395..820df3c2b 100644 --- a/src/main/java/appeng/me/cache/GridStorageCache.java +++ b/src/main/java/appeng/me/cache/GridStorageCache.java @@ -26,7 +26,10 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.me.helpers.PatternStatusManager; import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; import appeng.api.AEApi; @@ -65,6 +68,10 @@ public class GridStorageCache implements IStorageGrid private final HashSet inactiveCellProviders = new HashSet<>(); private final SetMultimap interests = HashMultimap.create(); private final GenericInterestManager interestManager = new GenericInterestManager<>( this.interests ); + private final Multimap patternDetails2IAEStackMultimap = HashMultimap.create(); + private final Multimap iaeStack2PatternDetailsMultimap = HashMultimap.create(); + private final PatternStatusManager patternStatusManager = new PatternStatusManager( this.patternDetails2IAEStackMultimap, this.iaeStack2PatternDetailsMultimap ); + private final HashMap watchers = new HashMap<>(); private Map, NetworkInventoryHandler> storageNetworks; private Map, NetworkMonitor> storageMonitors; @@ -304,6 +311,17 @@ public class GridStorageCache implements IStorageGrid return this.interestManager; } + public PatternStatusManager getPatternStatusManager() + { + return this.patternStatusManager; + } + + public void clearDebts() + { + this.patternDetails2IAEStackMultimap.clear(); + this.iaeStack2PatternDetailsMultimap.clear(); + } + IGrid getGrid() { return this.myGrid; diff --git a/src/main/java/appeng/me/cache/NetworkMonitor.java b/src/main/java/appeng/me/cache/NetworkMonitor.java index 5ec5cb76a..29060f276 100644 --- a/src/main/java/appeng/me/cache/NetworkMonitor.java +++ b/src/main/java/appeng/me/cache/NetworkMonitor.java @@ -25,6 +25,8 @@ import javax.annotation.Nullable; import appeng.api.AEApi; import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; +import appeng.api.config.FuzzyMode; +import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.networking.events.MENetworkStorageEvent; import appeng.api.networking.security.IActionSource; import appeng.api.storage.IMEInventoryHandler; @@ -33,6 +35,7 @@ import appeng.api.storage.IMEMonitorHandlerReceiver; import appeng.api.storage.IStorageChannel; import appeng.api.storage.channels.IFluidStorageChannel; import appeng.api.storage.channels.IItemStorageChannel; +import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; import appeng.me.storage.ItemWatcher; @@ -268,6 +271,67 @@ public class NetworkMonitor> implements IMEMonitor this.myGridCache.getInterestManager().disableTransactions(); } } + if( changedItem instanceof IAEItemStack ) + { + if( this.myGridCache.getPatternStatusManager().containsMissingIAEStack( changedItem ) ) + { + this.myGridCache.getPatternStatusManager().enableTransactions(); + + for( ICraftingPatternDetails craftingPatternDetails : this.myGridCache.getPatternStatusManager().getIncompletablePattern( changedItem ) ) + { + for( IAEStack stack : this.myGridCache.getPatternStatusManager().getMissingIAEStack( craftingPatternDetails ) ) + { + if( craftingPatternDetails.canSubstitute() ) + { + if( ( (IAEItemStack) stack ).getItem().isDamageable() ) + { + if( ( (IAEStack) changedItem ).fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) ) + { + if( changedItem.getStackSize() > 0 ) + { + this.myGridCache.getPatternStatusManager().remove( craftingPatternDetails, stack ); + } + } + } + else + { + if( ( (IAEItemStack) stack ).sameOre( (IAEItemStack) changedItem ) ) + { + if( changedItem.getStackSize() > 0 ) + { + if( changedItem.getStackSize() >= stack.getStackSize() ) + { + this.myGridCache.getPatternStatusManager().remove( craftingPatternDetails, stack ); + } + else + { + stack.decStackSize( changedItem.getStackSize() ); + } + } + } + } + } + else if( stack.equals( changedItem ) ) + { + if( changedItem.getStackSize() > 0 ) + { + if( changedItem.getStackSize() >= stack.getStackSize() ) + { + this.myGridCache.getPatternStatusManager().remove( craftingPatternDetails, stack ); + } + else + { + stack.decStackSize( changedItem.getStackSize() ); + } + } + } + } + } + + this.myGridCache.getPatternStatusManager().disableTransactions(); + + } + } } this.notifyListenersOfChange( changes, src ); diff --git a/src/main/java/appeng/me/helpers/PatternStatusManager.java b/src/main/java/appeng/me/helpers/PatternStatusManager.java new file mode 100644 index 000000000..719f8a3b9 --- /dev/null +++ b/src/main/java/appeng/me/helpers/PatternStatusManager.java @@ -0,0 +1,166 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.me.helpers; + + +import appeng.api.config.FuzzyMode; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; +import com.google.common.collect.Multimap; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + + +public class PatternStatusManager +{ + + private final Multimap patternDetailsIAEStackMultimap; + private final Multimap iaeStackPatternDetailsMultimap; + + private List transactions = null; + private int transDepth = 0; + + public PatternStatusManager( final Multimap interests, final Multimap interested ) + { + this.patternDetailsIAEStackMultimap = interests; + this.iaeStackPatternDetailsMultimap = interested; + } + + public void enableTransactions() + { + if( this.transDepth == 0 ) + { + this.transactions = new ArrayList<>(); + } + + this.transDepth++; + } + + public void disableTransactions() + { + this.transDepth--; + + if( this.transDepth == 0 ) + { + final List myActions = this.transactions; + this.transactions = null; + + for( final SavedTransactions t : myActions ) + { + if( t.put ) + { + this.put( t.patternDetails, t.stack ); + } + else + { + this.remove( t.patternDetails, t.stack ); + } + } + } + } + + public boolean put( final ICraftingPatternDetails craftingPatternDetails, final IAEStack debtStack ) + { + if( this.transactions != null ) + { + this.transactions.add( new SavedTransactions( true, craftingPatternDetails, debtStack ) ); + return true; + } + else + { + this.iaeStackPatternDetailsMultimap.put( debtStack, craftingPatternDetails ); + return this.patternDetailsIAEStackMultimap.put( craftingPatternDetails, debtStack ); + } + } + + public boolean remove( final ICraftingPatternDetails craftingPatternDetails, final IAEStack debtStack ) + { + if( this.transactions != null ) + { + this.transactions.add( new SavedTransactions( false, craftingPatternDetails, debtStack ) ); + return true; + } + else + { + this.iaeStackPatternDetailsMultimap.remove( debtStack, craftingPatternDetails ); + return this.patternDetailsIAEStackMultimap.remove( craftingPatternDetails, debtStack ); + } + } + + public boolean containsIncompletablePattern( final ICraftingPatternDetails craftingPatternDetails ) + { + return this.patternDetailsIAEStackMultimap.containsKey( craftingPatternDetails ); + } + + public boolean containsMissingIAEStack( final IAEStack stack ) + { + if( ( (IAEItemStack) stack ).getItem().isDamageable() ) + { + for( IAEStack i : iaeStackPatternDetailsMultimap.keySet() ) + { + if( i.fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) ) + { + return true; + } + } + return false; + } + return this.iaeStackPatternDetailsMultimap.containsKey( stack ); + } + + public Collection getMissingIAEStack( final ICraftingPatternDetails patternDetails ) + { + return this.patternDetailsIAEStackMultimap.get( patternDetails ); + } + + public Collection getIncompletablePattern( final IAEStack stack ) + { + Collection a = new ArrayList<>(); + if( ( (IAEItemStack) stack ).getItem().isDamageable() ) + { + for( IAEStack i : iaeStackPatternDetailsMultimap.keySet() ) + { + if( i.fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) ) + { + a.addAll( this.iaeStackPatternDetailsMultimap.get( i ) ); + } + } + return a; + } + return this.iaeStackPatternDetailsMultimap.get( stack ); + } + + private class SavedTransactions + { + + private final boolean put; + private final ICraftingPatternDetails patternDetails; + private final IAEStack stack; + + public SavedTransactions( final boolean putOperation, final ICraftingPatternDetails myPatternDetails, final IAEStack stack ) + { + this.put = putOperation; + this.patternDetails = myPatternDetails; + this.stack = stack; + } + } +} diff --git a/src/main/java/appeng/parts/automation/PartExportBus.java b/src/main/java/appeng/parts/automation/PartExportBus.java index 2619350b2..4498be108 100644 --- a/src/main/java/appeng/parts/automation/PartExportBus.java +++ b/src/main/java/appeng/parts/automation/PartExportBus.java @@ -19,6 +19,9 @@ package appeng.parts.automation; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.me.cache.CraftingGridCache; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -150,18 +153,14 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest final IAEItemStack ais = this.getConfig().getAEStackInSlot( slotToExport ); - if( ais == null || this.itemToSend <= 0 ) continue; + if( ais == null || this.itemToSend <= 0 ) + { + continue; + } - if ( this.craftOnly() ) { - if (this.failedCraftTriesSlot[x] <= 0) { - - this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), - this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething; - - if (this.didSomething) this.failedCraftTriesSlot[x] = 0; - else this.failedCraftTriesSlot[x] += 2; - } - this.failedCraftTriesSlot[x] -= 1; + if( this.craftOnly() ) + { + this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething; continue; } @@ -188,15 +187,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest if( this.itemToSend == before && this.isCraftingEnabled() ) { - if (this.failedCraftTriesSlot[x] <= 0) { - - this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), - this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething; - - if (this.didSomething) this.failedCraftTriesSlot[x] = 0; - else this.failedCraftTriesSlot[x] += 2; - } - this.failedCraftTriesSlot[x] -= 1; + this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething; } }