Crafting is now possible ( not complete but possible )
This commit is contained in:
@@ -35,6 +35,11 @@ public class CraftingJob implements Runnable
|
||||
public CraftingTreeNode tree;
|
||||
private BaseActionSource actionSrc;
|
||||
|
||||
public IAEItemStack getOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
public CraftingJob(ICraftingHost host, NBTTagCompound data) {
|
||||
jobHost = host;
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
@@ -178,4 +183,5 @@ public class CraftingJob implements Runnable
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.me.cache.CraftingCache;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
|
||||
public class CraftingTreeProcess
|
||||
{
|
||||
@@ -140,4 +141,12 @@ public class CraftingTreeProcess
|
||||
for (CraftingTreeNode pro : nodes.keySet())
|
||||
pro.setSimulate();
|
||||
}
|
||||
|
||||
public void setJob(MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src) throws CraftBranchFailure
|
||||
{
|
||||
craftingCPUCluster.addCrafting( details, crafts );
|
||||
|
||||
for (CraftingTreeNode pro : nodes.keySet())
|
||||
pro.setJob( storage, craftingCPUCluster, src );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,39 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
final boolean logMissing;
|
||||
final IItemList<IAEItemStack> missingCache;
|
||||
|
||||
public MECraftingInventory() {
|
||||
localCache = AEApi.instance().storage().createItemList();
|
||||
extractedCache = null;
|
||||
injectedCache = null;
|
||||
missingCache = null;
|
||||
this.logExtracted = false;
|
||||
this.logInjections = false;
|
||||
this.logMissing = false;
|
||||
target = null;
|
||||
par = null;
|
||||
}
|
||||
|
||||
public MECraftingInventory(MECraftingInventory parrent) {
|
||||
this.target = parrent;
|
||||
this.logExtracted = parrent.logExtracted;
|
||||
this.logInjections = parrent.logInjections;
|
||||
this.logMissing = parrent.logMissing;
|
||||
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
missingCache = null;
|
||||
|
||||
if ( logExtracted )
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
extractedCache = null;
|
||||
|
||||
if ( logInjections )
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
injectedCache = null;
|
||||
|
||||
localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
|
||||
par = parrent;
|
||||
@@ -44,9 +68,22 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
this.logExtracted = logExtracted;
|
||||
this.logInjections = logInjections;
|
||||
this.logMissing = logMissing;
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
missingCache = null;
|
||||
|
||||
if ( logExtracted )
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
extractedCache = null;
|
||||
|
||||
if ( logInjections )
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
injectedCache = null;
|
||||
|
||||
localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
par = null;
|
||||
}
|
||||
@@ -120,12 +157,6 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
public void moveItemsToStorage(IItemList<IAEItemStack> storage)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void commit(BaseActionSource src)
|
||||
{
|
||||
if ( logInjections )
|
||||
|
||||
Reference in New Issue
Block a user