Finished Crafting EmitterLogic.
This commit is contained in:
parent
bcdc47622c
commit
b82857b68f
8 changed files with 84 additions and 3 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ public class CraftingTreeNode
|
|||
|
||||
boolean canEmit = false;
|
||||
boolean cannotUse = false;
|
||||
|
||||
long missing = 0;
|
||||
long howManyEmitted = 0;
|
||||
|
||||
CraftingJob job;
|
||||
IItemList<IAEItemStack> 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() );
|
||||
|
||||
|
|
10
me/cache/CraftingGridCache.java
vendored
10
me/cache/CraftingGridCache.java
vendored
|
@ -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() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<IAEItemStack> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue