Pattern registration still a work in progress.
This commit is contained in:
@@ -24,7 +24,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
|
|||||||
import appeng.api.networking.crafting.ICraftingProvider;
|
import appeng.api.networking.crafting.ICraftingProvider;
|
||||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
import appeng.api.networking.energy.IEnergySource;
|
import appeng.api.networking.energy.IEnergySource;
|
||||||
import appeng.api.networking.events.MECraftingPatternUpdate;
|
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||||
import appeng.api.networking.security.BaseActionSource;
|
import appeng.api.networking.security.BaseActionSource;
|
||||||
import appeng.api.networking.security.MachineSource;
|
import appeng.api.networking.security.MachineSource;
|
||||||
import appeng.api.networking.ticking.IGridTickable;
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
@@ -81,7 +81,10 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
|
|
||||||
public void updateCraftingList()
|
public void updateCraftingList()
|
||||||
{
|
{
|
||||||
Boolean accountedFor[] = new Boolean[patterns.getSizeInventory()];
|
Boolean accountedFor[] = new Boolean[] { false, false, false, false, false, false, false, false, false }; // 9...
|
||||||
|
|
||||||
|
assert (accountedFor.length == patterns.getSizeInventory());
|
||||||
|
|
||||||
if ( craftingList != null )
|
if ( craftingList != null )
|
||||||
{
|
{
|
||||||
Iterator<ICraftingPatternDetails> i = craftingList.iterator();
|
Iterator<ICraftingPatternDetails> i = craftingList.iterator();
|
||||||
@@ -109,6 +112,15 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
if ( accountedFor[x] == false )
|
if ( accountedFor[x] == false )
|
||||||
addToCraftingList( patterns.getStackInSlot( x ) );
|
addToCraftingList( patterns.getStackInSlot( x ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, gridProxy.getNode() ) );
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToCraftingList(ItemStack is)
|
public void addToCraftingList(ItemStack is)
|
||||||
@@ -460,16 +472,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
if ( inv == config )
|
if ( inv == config )
|
||||||
readConfig();
|
readConfig();
|
||||||
else if ( inv == patterns )
|
else if ( inv == patterns )
|
||||||
{
|
updateCraftingList();
|
||||||
try
|
|
||||||
{
|
|
||||||
gridProxy.getGrid().postEvent( new MECraftingPatternUpdate( this ) );
|
|
||||||
}
|
|
||||||
catch (GridAccessException e)
|
|
||||||
{
|
|
||||||
// :P
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( inv == storage && slot >= 0 )
|
else if ( inv == storage && slot >= 0 )
|
||||||
{
|
{
|
||||||
boolean had = hasWorkToDo();
|
boolean had = hasWorkToDo();
|
||||||
@@ -704,8 +707,11 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
@Override
|
@Override
|
||||||
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
||||||
{
|
{
|
||||||
for (ICraftingPatternDetails details : craftingList)
|
if ( craftingList != null )
|
||||||
craftingTracker.addCraftingOption( this, details );
|
{
|
||||||
|
for (ICraftingPatternDetails details : craftingList)
|
||||||
|
craftingTracker.addCraftingOption( this, details );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,9 +114,6 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
isCrafting = encodedValue.getBoolean( "crafting" );
|
isCrafting = encodedValue.getBoolean( "crafting" );
|
||||||
patternItem = is;
|
patternItem = is;
|
||||||
|
|
||||||
if ( isCrafting == false )
|
|
||||||
throw new RuntimeException( "Only crafting recipes supported." );
|
|
||||||
|
|
||||||
List<IAEItemStack> in = new ArrayList();
|
List<IAEItemStack> in = new ArrayList();
|
||||||
List<IAEItemStack> out = new ArrayList();
|
List<IAEItemStack> out = new ArrayList();
|
||||||
|
|
||||||
@@ -134,15 +131,17 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
testFrame.setInventorySlotContents( x, gs );
|
testFrame.setInventorySlotContents( x, gs );
|
||||||
}
|
}
|
||||||
|
|
||||||
standardRecipe = Platform.findMatchingRecipe( crafting, w );
|
|
||||||
correctOutput = standardRecipe.getCraftingResult( crafting );
|
|
||||||
|
|
||||||
if ( isCrafting )
|
if ( isCrafting )
|
||||||
{
|
{
|
||||||
|
standardRecipe = Platform.findMatchingRecipe( crafting, w );
|
||||||
|
correctOutput = standardRecipe.getCraftingResult( crafting );
|
||||||
out.add( AEApi.instance().storage().createItemStack( correctOutput ) );
|
out.add( AEApi.instance().storage().createItemStack( correctOutput ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
standardRecipe = null;
|
||||||
|
correctOutput = null;
|
||||||
|
|
||||||
for (int x = 0; x < outTag.tagCount(); x++)
|
for (int x = 0; x < outTag.tagCount(); x++)
|
||||||
{
|
{
|
||||||
ItemStack gs = ItemStack.loadItemStackFromNBT( inTag.getCompoundTagAt( x ) );
|
ItemStack gs = ItemStack.loadItemStackFromNBT( inTag.getCompoundTagAt( x ) );
|
||||||
@@ -158,6 +157,9 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
|
|
||||||
public boolean isValidItemForSlot(int slotIndex, ItemStack i, World w)
|
public boolean isValidItemForSlot(int slotIndex, ItemStack i, World w)
|
||||||
{
|
{
|
||||||
|
if ( isCrafting == false )
|
||||||
|
throw new RuntimeException( "Only crafting recipes supported." );
|
||||||
|
|
||||||
TestStatus result = getStatus( slotIndex, i );
|
TestStatus result = getStatus( slotIndex, i );
|
||||||
|
|
||||||
switch (result)
|
switch (result)
|
||||||
@@ -209,6 +211,9 @@ public class PatternHelper implements ICraftingPatternDetails
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getOutput(InventoryCrafting craftingInv, World w)
|
public ItemStack getOutput(InventoryCrafting craftingInv, World w)
|
||||||
{
|
{
|
||||||
|
if ( isCrafting == false )
|
||||||
|
throw new RuntimeException( "Only crafting recipes supported." );
|
||||||
|
|
||||||
for (int x = 0; x < craftingInv.getSizeInventory(); x++)
|
for (int x = 0; x < craftingInv.getSizeInventory(); x++)
|
||||||
{
|
{
|
||||||
if ( !isValidItemForSlot( x, craftingInv.getStackInSlot( x ), w ) )
|
if ( !isValidItemForSlot( x, craftingInv.getStackInSlot( x ), w ) )
|
||||||
|
|||||||
Reference in New Issue
Block a user