Crafting is now possible ( not complete but possible )
This commit is contained in:
@@ -16,10 +16,10 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.implementations.tiles.ICraftingMachine;
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingMedium;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
@@ -152,6 +152,15 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||
waitingToSend = new LinkedList();
|
||||
|
||||
waitingToSend.add( is );
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getTick().wakeDevice( gridProxy.getNode() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
public DualityInterface(AENetworkProxy prox, IInterfaceHost ih) {
|
||||
@@ -554,6 +563,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||
{
|
||||
if ( hasItemsToSend() )
|
||||
pushItemsOut( EnumSet.allOf( ForgeDirection.class ) );
|
||||
|
||||
boolean couldDoWork = updateStorage();
|
||||
return hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) : TickRateModulation.SLEEP;
|
||||
}
|
||||
@@ -642,7 +654,45 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where)
|
||||
public boolean isBusy()
|
||||
{
|
||||
if ( hasItemsToSend() )
|
||||
return true;
|
||||
|
||||
boolean busy = false;
|
||||
|
||||
if ( isBlocking() )
|
||||
{
|
||||
EnumSet<ForgeDirection> possibleDirections = iHost.getTargets();
|
||||
TileEntity tile = iHost.getTileEntity();
|
||||
World w = tile.getWorldObj();
|
||||
|
||||
for (ForgeDirection s : possibleDirections)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ );
|
||||
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||
if ( ad != null )
|
||||
{
|
||||
if ( ad.simulateRemove( 1, null, null ) != null )
|
||||
{
|
||||
busy = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return busy;
|
||||
}
|
||||
|
||||
private boolean isBlocking()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
|
||||
{
|
||||
if ( hasItemsToSend() )
|
||||
return false;
|
||||
@@ -654,9 +704,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||
for (ForgeDirection s : possibleDirections)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ );
|
||||
if ( te instanceof ICraftingMedium )
|
||||
if ( te instanceof ICraftingMachine )
|
||||
{
|
||||
if ( ((ICraftingMedium) te).pushPattern( patternDetails, table, s.getOpposite() ) )
|
||||
if ( ((ICraftingMachine) te).pushPattern( patternDetails, table, s.getOpposite() ) )
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -686,7 +736,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||
|
||||
private void pushItemsOut(EnumSet<ForgeDirection> possibleDirections)
|
||||
{
|
||||
if ( hasItemsToSend() )
|
||||
if ( !hasItemsToSend() )
|
||||
return;
|
||||
|
||||
TileEntity tile = iHost.getTileEntity();
|
||||
@@ -700,6 +750,8 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
||||
for (ForgeDirection s : possibleDirections)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ );
|
||||
if ( te == null )
|
||||
continue;
|
||||
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||
if ( ad != null )
|
||||
|
||||
@@ -19,11 +19,13 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PatternHelper implements ICraftingPatternDetails, Comparable<PatternHelper>
|
||||
{
|
||||
|
||||
final ItemStack patternItem;
|
||||
private IAEItemStack aepattern;
|
||||
|
||||
final InventoryCrafting crafting = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
final InventoryCrafting testFrame = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
@@ -118,6 +120,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
|
||||
isCrafting = encodedValue.getBoolean( "crafting" );
|
||||
patternItem = is;
|
||||
aepattern = AEItemStack.create( is );
|
||||
|
||||
List<IAEItemStack> in = new ArrayList();
|
||||
List<IAEItemStack> out = new ArrayList();
|
||||
@@ -317,4 +320,15 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
return ItemSorters.compareInt( o.priority, priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return aepattern.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return aepattern.equals( ((PatternHelper) obj).aepattern );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user