diff --git a/client/gui/implementations/GuiLevelEmitter.java b/client/gui/implementations/GuiLevelEmitter.java index d9d77739..ff91a1f8 100644 --- a/client/gui/implementations/GuiLevelEmitter.java +++ b/client/gui/implementations/GuiLevelEmitter.java @@ -12,6 +12,7 @@ import appeng.api.config.LevelType; import appeng.api.config.RedstoneMode; import appeng.api.config.Settings; import appeng.api.config.Upgrades; +import appeng.api.config.YesNo; import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiNumberBox; import appeng.container.implementations.ContainerLevelEmitter; @@ -32,6 +33,7 @@ public class GuiLevelEmitter extends GuiUpgradeable GuiButton minus1, minus10, minus100, minus1000; GuiImgButton levelMode; + GuiImgButton craftingMode; public GuiLevelEmitter(InventoryPlayer inventoryPlayer, PartLevelEmitter te) { super( new ContainerLevelEmitter( inventoryPlayer, te ) ); @@ -57,6 +59,7 @@ public class GuiLevelEmitter extends GuiUpgradeable levelMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL ); redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL ); fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + craftingMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO ); int a = AEConfig.instance.levelByStackAmounts( 0 ); int b = AEConfig.instance.levelByStackAmounts( 1 ); @@ -76,6 +79,7 @@ public class GuiLevelEmitter extends GuiUpgradeable buttonList.add( levelMode ); buttonList.add( redstoneMode ); buttonList.add( fuzzyMode ); + buttonList.add( craftingMode ); } @Override @@ -87,6 +91,9 @@ public class GuiLevelEmitter extends GuiUpgradeable try { + if ( btn == craftingMode ) + NetworkHandler.instance.sendToServer( new PacketConfigButton( craftingMode.getSetting(), backwards ) ); + if ( btn == levelMode ) NetworkHandler.instance.sendToServer( new PacketConfigButton( levelMode.getSetting(), backwards ) ); } @@ -143,6 +150,7 @@ public class GuiLevelEmitter extends GuiUpgradeable protected void handleButtonVisiblity() { + craftingMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ); fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ); } @@ -204,6 +212,9 @@ public class GuiLevelEmitter extends GuiUpgradeable super.drawFG( offsetX, offsetY, mouseX, mouseY ); + if ( craftingMode != null ) + craftingMode.set( ((ContainerLevelEmitter) cvb).cmType ); + if ( levelMode != null ) levelMode.set( ((ContainerLevelEmitter) cvb).lvType ); } diff --git a/container/implementations/ContainerLevelEmitter.java b/container/implementations/ContainerLevelEmitter.java index f562034d..9003d7a2 100644 --- a/container/implementations/ContainerLevelEmitter.java +++ b/container/implementations/ContainerLevelEmitter.java @@ -9,6 +9,7 @@ import appeng.api.config.LevelType; import appeng.api.config.RedstoneMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; +import appeng.api.config.YesNo; import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotRestrictedInput; @@ -83,6 +84,9 @@ public class ContainerLevelEmitter extends ContainerUpgradeable @GuiSync(3) public long EmitterValue = -1; + @GuiSync(4) + public YesNo cmType; + @Override public void detectAndSendChanges() { @@ -91,6 +95,7 @@ public class ContainerLevelEmitter extends ContainerUpgradeable if ( Platform.isServer() ) { this.EmitterValue = lvlEmitter.getReportingValue(); + this.cmType = (YesNo) this.myte.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ); this.lvType = (LevelType) this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE ); this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ); this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ); diff --git a/container/implementations/ContainerStorageBus.java b/container/implementations/ContainerStorageBus.java index a843c364..daf86868 100644 --- a/container/implementations/ContainerStorageBus.java +++ b/container/implementations/ContainerStorageBus.java @@ -10,6 +10,7 @@ import appeng.api.config.AccessRestriction; import appeng.api.config.FuzzyMode; import appeng.api.config.SecurityPermissions; import appeng.api.config.Settings; +import appeng.api.config.StorageFilter; import appeng.api.config.Upgrades; import appeng.api.storage.IMEInventory; import appeng.api.storage.data.IAEItemStack; @@ -31,6 +32,9 @@ public class ContainerStorageBus extends ContainerUpgradeable @GuiSync(3) public AccessRestriction rwMode = AccessRestriction.READ_WRITE; + @GuiSync(4) + public StorageFilter storageFilter = StorageFilter.EXTACTABLE_ONLY; + public ContainerStorageBus(InventoryPlayer ip, PartStorageBus te) { super( ip, te ); storageBus = te; @@ -97,6 +101,7 @@ public class ContainerStorageBus extends ContainerUpgradeable { this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ); this.rwMode = (AccessRestriction) this.myte.getConfigManager().getSetting( Settings.ACCESS ); + this.storageFilter = (StorageFilter) this.myte.getConfigManager().getSetting( Settings.STORAGE_FILTER ); } standardDetectAndSendChanges(); diff --git a/core/localization/ButtonToolTips.java b/core/localization/ButtonToolTips.java index 1e5df112..57ae22e7 100644 --- a/core/localization/ButtonToolTips.java +++ b/core/localization/ButtonToolTips.java @@ -34,7 +34,9 @@ public enum ButtonToolTips LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, TerminalStyle_Small, - Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc, CraftOnly, CraftEither, Craft, Mod, DosntDespawn; + Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc, CraftOnly, CraftEither, + + Craft, Mod, DosntDespawn, EmitterMode, CraftViaRedstone, EmitWhenCrafing, ReportInaccessibleItems, ReportInaccessibleItemsYes, ReportInaccessibleItemsNo; String root; diff --git a/crafting/CraftingTreeNode.java b/crafting/CraftingTreeNode.java index bd8fafe7..1d07cf3c 100644 --- a/crafting/CraftingTreeNode.java +++ b/crafting/CraftingTreeNode.java @@ -34,7 +34,9 @@ public class CraftingTreeNode boolean canEmit = false; boolean cannotUse = false; + long missing = 0; + long howManyEmitted = 0; CraftingJob job; IItemList used = AEApi.instance().storage().createItemList(); @@ -150,6 +152,17 @@ public class CraftingTreeNode } } + if ( canEmit ) + { + IAEItemStack wat = what.copy(); + wat.setStackSize( l ); + + howManyEmitted = wat.getStackSize(); + bytes += wat.getStackSize(); + + return wat; + } + exhausted = true; if ( nodes.size() == 1 ) @@ -267,6 +280,13 @@ public class CraftingTreeNode craftingCPUCluster.addStorage( ex ); } + if ( howManyEmitted > 0 ) + { + IAEItemStack i = what.copy(); + i.setStackSize( howManyEmitted ); + craftingCPUCluster.addEmitable( i ); + } + for (CraftingTreeProcess pro : nodes) pro.setJob( storage, craftingCPUCluster, src ); } @@ -280,6 +300,13 @@ public class CraftingTreeNode plan.add( o ); } + if ( howManyEmitted > 0 ) + { + IAEItemStack i = what.copy(); + i.setCountRequestable( howManyEmitted ); + plan.addRequestable( i ); + } + for (IAEItemStack i : used) plan.add( i.copy() ); diff --git a/me/cache/CraftingGridCache.java b/me/cache/CraftingGridCache.java index 0b23ae15..7ef8ba89 100644 --- a/me/cache/CraftingGridCache.java +++ b/me/cache/CraftingGridCache.java @@ -297,6 +297,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper // erase list. craftingMethods.clear(); craftableItems.clear(); + emitableItems.clear(); // re-create list.. for (ICraftingProvider cp : providers) @@ -375,6 +376,9 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper for (IAEItemStack st : craftableItems.keySet()) out.addCrafting( st ); + for (IAEItemStack st : emitableItems) + out.addCrafting( st ); + return out; } @@ -568,4 +572,10 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper return emitableItems.contains( what ); } + @Override + public void setEmitable(IAEItemStack what) + { + emitableItems.add( what.copy() ); + } + } diff --git a/me/cluster/implementations/CraftingCPUCluster.java b/me/cluster/implementations/CraftingCPUCluster.java index a3d1bb83..8b2c5e1b 100644 --- a/me/cluster/implementations/CraftingCPUCluster.java +++ b/me/cluster/implementations/CraftingCPUCluster.java @@ -684,6 +684,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU IAEItemStack cItem = AEItemStack.create( output ); postChange( cItem, machineSrc ); waitingFor.add( cItem ); + postCraftingStatusChange( cItem ); } } } @@ -791,6 +792,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU IItemList list; getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL ); + for (IAEItemStack ge : list) postChange( ge, machineSrc ); @@ -853,6 +855,12 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU inventory.injectItems( extractItems, Actionable.MODULATE, null ); } + public void addEmitable(IAEItemStack i) + { + waitingFor.add( i ); + postCraftingStatusChange( i ); + } + public void addCrafting(ICraftingPatternDetails details, long crafts) { TaskProgress i = tasks.get( details ); @@ -950,6 +958,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } waitingFor = readList( (NBTTagList) data.getTag( "waitingFor" ) ); + for (IAEItemStack is : waitingFor) + postCraftingStatusChange( is.copy() ); } public void writeToNBT(NBTTagCompound data) @@ -1066,7 +1076,8 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public boolean isMaking(IAEItemStack what) { - return waitingFor.findPrecise( what ) != null; + IAEItemStack wat = waitingFor.findPrecise( what ); + return wat != null && wat.getStackSize() > 0; } } diff --git a/parts/automation/PartLevelEmitter.java b/parts/automation/PartLevelEmitter.java index 17d3801b..67d1397e 100644 --- a/parts/automation/PartLevelEmitter.java +++ b/parts/automation/PartLevelEmitter.java @@ -31,6 +31,7 @@ import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.energy.IEnergyWatcher; import appeng.api.networking.energy.IEnergyWatcherHost; import appeng.api.networking.events.MENetworkChannelsChanged; +import appeng.api.networking.events.MENetworkCraftingPatternChange; import appeng.api.networking.events.MENetworkEventSubscribe; import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.networking.security.BaseActionSource; @@ -185,9 +186,18 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH if ( myCraftingWatcher != null ) myCraftingWatcher.clear(); + try + { + proxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, proxy.getNode() ) ); + } + catch (GridAccessException e1) + { + // :/ + } + if ( getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) { - if ( myCraftingWatcher != null ) + if ( myCraftingWatcher != null && myStack != null ) myCraftingWatcher.add( myStack ); return;