Crafting is now possible ( not complete but possible )
This commit is contained in:
@@ -3,12 +3,15 @@ package appeng.crafting;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.cache.CraftingCache;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
|
||||
public class CraftingTreeNode
|
||||
{
|
||||
@@ -29,6 +32,9 @@ public class CraftingTreeNode
|
||||
boolean cannotUse = false;
|
||||
long missing = 0;
|
||||
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().createItemList();
|
||||
boolean exhausted = false;
|
||||
|
||||
boolean sim;
|
||||
|
||||
public CraftingTreeNode(CraftingCache cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth) {
|
||||
@@ -83,6 +89,8 @@ public class CraftingTreeNode
|
||||
|
||||
if ( available != null )
|
||||
{
|
||||
if ( !exhausted )
|
||||
used.add( available );
|
||||
l -= available.getStackSize();
|
||||
|
||||
if ( l == 0 )
|
||||
@@ -97,6 +105,8 @@ public class CraftingTreeNode
|
||||
|
||||
if ( available != null )
|
||||
{
|
||||
if ( !exhausted )
|
||||
used.add( available );
|
||||
l -= available.getStackSize();
|
||||
|
||||
if ( l == 0 )
|
||||
@@ -104,6 +114,8 @@ public class CraftingTreeNode
|
||||
}
|
||||
}
|
||||
|
||||
exhausted = true;
|
||||
|
||||
if ( nodes.size() == 1 )
|
||||
{
|
||||
CraftingTreeProcess pro = nodes.get( 0 );
|
||||
@@ -182,8 +194,26 @@ public class CraftingTreeNode
|
||||
{
|
||||
sim = true;
|
||||
missing = 0;
|
||||
used.resetStatus();
|
||||
exhausted = false;
|
||||
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
pro.setSimulate();
|
||||
}
|
||||
|
||||
public void setJob(MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src) throws CraftBranchFailure
|
||||
{
|
||||
for (IAEItemStack i : used)
|
||||
{
|
||||
IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src );
|
||||
|
||||
if ( ex == null || ex.getStackSize() != i.getStackSize() )
|
||||
throw new CraftBranchFailure( i, i.getStackSize() );
|
||||
|
||||
craftingCPUCluster.addStorage( ex );
|
||||
}
|
||||
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
pro.setJob( storage, craftingCPUCluster, src );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user