Interface Crafting, and fixed crash with import bus gui.
This commit is contained in:
@@ -24,6 +24,7 @@ import appeng.container.slot.SlotRestrictedInput;
|
|||||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||||
import appeng.items.contents.NetworkToolViewer;
|
import appeng.items.contents.NetworkToolViewer;
|
||||||
import appeng.items.tools.ToolNetworkTool;
|
import appeng.items.tools.ToolNetworkTool;
|
||||||
|
import appeng.parts.automation.PartExportBus;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
|
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
|
||||||
@@ -196,8 +197,9 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||||||
protected void loadSettingsFromHost(IConfigManager cm)
|
protected void loadSettingsFromHost(IConfigManager cm)
|
||||||
{
|
{
|
||||||
this.fzMode = (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE );
|
this.fzMode = (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE );
|
||||||
this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY );
|
|
||||||
this.rsMode = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED );
|
this.rsMode = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||||
|
if ( myte instanceof PartExportBus )
|
||||||
|
this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void standardDetectAndSendChanges()
|
protected void standardDetectAndSendChanges()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import appeng.api.implementations.tiles.ICraftingMachine;
|
|||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.networking.GridFlags;
|
import appeng.api.networking.GridFlags;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingLink;
|
||||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
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;
|
||||||
@@ -62,6 +63,9 @@ import appeng.util.Platform;
|
|||||||
import appeng.util.inv.AdaptorIInventory;
|
import appeng.util.inv.AdaptorIInventory;
|
||||||
import appeng.util.inv.IInventoryDestination;
|
import appeng.util.inv.IInventoryDestination;
|
||||||
import appeng.util.inv.WrapperInvSlot;
|
import appeng.util.inv.WrapperInvSlot;
|
||||||
|
import appeng.util.item.AEItemStack;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
|
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
|
||||||
IConfigureableObject, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
IConfigureableObject, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
||||||
@@ -69,6 +73,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
|
|
||||||
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||||
final IAEItemStack requireWork[] = new IAEItemStack[] { null, null, null, null, null, null, null, null };
|
final IAEItemStack requireWork[] = new IAEItemStack[] { null, null, null, null, null, null, null, null };
|
||||||
|
final MultiCraftingTracker craftingTracker;
|
||||||
|
|
||||||
boolean hasConfig = false;
|
boolean hasConfig = false;
|
||||||
AENetworkProxy gridProxy;
|
AENetworkProxy gridProxy;
|
||||||
@@ -186,6 +191,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
cm.registerSetting( Settings.BLOCK, YesNo.NO );
|
cm.registerSetting( Settings.BLOCK, YesNo.NO );
|
||||||
|
|
||||||
iHost = ih;
|
iHost = ih;
|
||||||
|
craftingTracker = new MultiCraftingTracker( iHost, 9 );
|
||||||
mySrc = fluids.changeSource = items.changeSource = new MachineSource( iHost );
|
mySrc = fluids.changeSource = items.changeSource = new MachineSource( iHost );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +246,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
config.writeToNBT( data, "config" );
|
config.writeToNBT( data, "config" );
|
||||||
patterns.writeToNBT( data, "patterns" );
|
patterns.writeToNBT( data, "patterns" );
|
||||||
storage.writeToNBT( data, "storage" );
|
storage.writeToNBT( data, "storage" );
|
||||||
|
craftingTracker.writeToNBT( data );
|
||||||
|
|
||||||
NBTTagList waitingToSend = new NBTTagList();
|
NBTTagList waitingToSend = new NBTTagList();
|
||||||
if ( this.waitingToSend != null )
|
if ( this.waitingToSend != null )
|
||||||
@@ -271,6 +278,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
craftingTracker.readFromNBT( data );
|
||||||
config.readFromNBT( data, "config" );
|
config.readFromNBT( data, "config" );
|
||||||
patterns.readFromNBT( data, "patterns" );
|
patterns.readFromNBT( data, "patterns" );
|
||||||
storage.readFromNBT( data, "storage" );
|
storage.readFromNBT( data, "storage" );
|
||||||
@@ -388,7 +396,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
destination = gridProxy.getStorage().getItemInventory();
|
destination = gridProxy.getStorage().getItemInventory();
|
||||||
IEnergySource src = gridProxy.getEnergy();
|
IEnergySource src = gridProxy.getEnergy();
|
||||||
|
|
||||||
if ( itemStack.getStackSize() > 0 )
|
if ( craftingTracker.isBusy( x ) )
|
||||||
|
changed = handleCrafting( x, adaptor, itemStack ) || changed;
|
||||||
|
else if ( itemStack.getStackSize() > 0 )
|
||||||
{
|
{
|
||||||
// make sure strange things didn't happen...
|
// make sure strange things didn't happen...
|
||||||
if ( adaptor.simulateAdd( itemStack.getItemStack() ) != null )
|
if ( adaptor.simulateAdd( itemStack.getItemStack() ) != null )
|
||||||
@@ -405,6 +415,8 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
if ( issue != null )
|
if ( issue != null )
|
||||||
throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" );
|
throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
changed = handleCrafting( x, adaptor, itemStack ) || changed;
|
||||||
}
|
}
|
||||||
else if ( itemStack.getStackSize() < 0 )
|
else if ( itemStack.getStackSize() < 0 )
|
||||||
{
|
{
|
||||||
@@ -451,6 +463,24 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean handleCrafting(int x, InventoryAdaptor d, IAEItemStack itemStack)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
||||||
|
{
|
||||||
|
return craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, getTile().getWorldObj(), gridProxy.getGrid(),
|
||||||
|
gridProxy.getCrafting(), mySrc );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public IInventory getConfig()
|
public IInventory getConfig()
|
||||||
{
|
{
|
||||||
return config;
|
return config;
|
||||||
@@ -652,8 +682,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
|
|
||||||
private void cancelCrafting()
|
private void cancelCrafting()
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
craftingTracker.cancel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src, IStorageMonitorable myInterface)
|
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src, IStorageMonitorable myInterface)
|
||||||
@@ -819,6 +848,10 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
drops.add( is );
|
drops.add( is );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ItemStack is : upgrades)
|
||||||
|
if ( is != null )
|
||||||
|
drops.add( is );
|
||||||
|
|
||||||
for (ItemStack is : storage)
|
for (ItemStack is : storage)
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
drops.add( is );
|
drops.add( is );
|
||||||
@@ -858,4 +891,35 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||||
|
{
|
||||||
|
return craftingTracker.getRequestedJobs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IAEItemStack injectCratedItems(ICraftingLink link, IAEItemStack aquired, Actionable mode)
|
||||||
|
{
|
||||||
|
int x = craftingTracker.getSlot( link );
|
||||||
|
|
||||||
|
if ( aquired != null && x >= 0 && x <= requireWork.length )
|
||||||
|
{
|
||||||
|
slotInv.setSlot( x );
|
||||||
|
|
||||||
|
if ( mode == Actionable.SIMULATE )
|
||||||
|
return AEItemStack.create( adaptor.simulateAdd( aquired.getItemStack() ) );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IAEItemStack is = AEItemStack.create( adaptor.addItems( aquired.getItemStack() ) );
|
||||||
|
updatePlan( x );
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aquired;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void jobStateChange(ICraftingLink link)
|
||||||
|
{
|
||||||
|
craftingTracker.jobStateChange( link );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.implementations.IUpgradeableHost;
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.networking.crafting.ICraftingProvider;
|
import appeng.api.networking.crafting.ICraftingProvider;
|
||||||
|
import appeng.api.networking.crafting.ICraftingRequester;
|
||||||
import appeng.api.networking.security.IActionHost;
|
import appeng.api.networking.security.IActionHost;
|
||||||
|
|
||||||
public interface IInterfaceHost extends IActionHost, ICraftingProvider, IUpgradeableHost
|
public interface IInterfaceHost extends IActionHost, ICraftingProvider, IUpgradeableHost, ICraftingRequester
|
||||||
{
|
{
|
||||||
|
|
||||||
DualityInterface getInterfaceDuality();
|
DualityInterface getInterfaceDuality();
|
||||||
|
|||||||
@@ -184,4 +184,48 @@ public class MultiCraftingTracker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSlot(ICraftingLink link)
|
||||||
|
{
|
||||||
|
if ( links != null )
|
||||||
|
{
|
||||||
|
for (int x = 0; x < links.length; x++)
|
||||||
|
{
|
||||||
|
if ( links[x] == link )
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel()
|
||||||
|
{
|
||||||
|
if ( links != null )
|
||||||
|
{
|
||||||
|
for (ICraftingLink l : links)
|
||||||
|
{
|
||||||
|
if ( l != null )
|
||||||
|
l.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
links = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( jobs != null )
|
||||||
|
{
|
||||||
|
for (Future<ICraftingJob> l : jobs)
|
||||||
|
{
|
||||||
|
if ( l != null )
|
||||||
|
l.cancel( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
jobs = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBusy(int slot)
|
||||||
|
{
|
||||||
|
return getLink( slot ) != null || getJob( slot ) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
{
|
{
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
inventory.getItemList().resetStatus();
|
inventory.getItemList().resetStatus();
|
||||||
AELog.error( e );
|
// AELog.error( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
public class PartExportBus extends PartSharedItemBus implements IGridTickable, ICraftingRequester
|
public class PartExportBus extends PartSharedItemBus implements IGridTickable, ICraftingRequester
|
||||||
{
|
{
|
||||||
|
|
||||||
MultiCraftingTracker cratingTracker = new MultiCraftingTracker( this, 9 );
|
final MultiCraftingTracker cratingTracker = new MultiCraftingTracker( this, 9 );
|
||||||
BaseActionSource mySrc;
|
final BaseActionSource mySrc;
|
||||||
|
|
||||||
public PartExportBus(ItemStack is) {
|
public PartExportBus(ItemStack is) {
|
||||||
super( PartExportBus.class, is );
|
super( PartExportBus.class, is );
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.Upgrades;
|
import appeng.api.config.Upgrades;
|
||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingLink;
|
||||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||||
@@ -43,6 +45,9 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
|||||||
import appeng.tile.inventory.InvOperation;
|
import appeng.tile.inventory.InvOperation;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.inv.IInventoryDestination;
|
import appeng.util.inv.IInventoryDestination;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@@ -361,4 +366,22 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
|
|||||||
return duality.getInstalledUpgrades( u );
|
return duality.getInstalledUpgrades( u );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||||
|
{
|
||||||
|
return duality.getRequestedJobs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAEItemStack injectCratedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
||||||
|
{
|
||||||
|
return duality.injectCratedItems( link, items, mode );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void jobStateChange(ICraftingLink link)
|
||||||
|
{
|
||||||
|
duality.jobStateChange( link );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.Upgrades;
|
import appeng.api.config.Upgrades;
|
||||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||||
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.crafting.ICraftingLink;
|
||||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||||
@@ -40,6 +42,8 @@ import appeng.tile.inventory.InvOperation;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.inv.IInventoryDestination;
|
import appeng.util.inv.IInventoryDestination;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
public class TileInterface extends AENetworkInvTile implements IGridTickable, ISegmentedInventory, ITileStorageMonitorable, IStorageMonitorable,
|
public class TileInterface extends AENetworkInvTile implements IGridTickable, ISegmentedInventory, ITileStorageMonitorable, IStorageMonitorable,
|
||||||
IInventoryDestination, IInterfaceHost, IConfigureableObject
|
IInventoryDestination, IInterfaceHost, IConfigureableObject
|
||||||
{
|
{
|
||||||
@@ -262,4 +266,21 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
|||||||
return duality.getInstalledUpgrades( u );
|
return duality.getInstalledUpgrades( u );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||||
|
{
|
||||||
|
return duality.getRequestedJobs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAEItemStack injectCratedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
||||||
|
{
|
||||||
|
return duality.injectCratedItems( link, items, mode );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void jobStateChange(ICraftingLink link)
|
||||||
|
{
|
||||||
|
duality.jobStateChange( link );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user