parent
c5848fe323
commit
67213462db
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.config;
|
||||
|
||||
|
||||
public enum SchedulingMode
|
||||
{
|
||||
DEFAULT, ROUNDROBIN, RANDOM
|
||||
}
|
|
@ -55,13 +55,15 @@ public enum Settings
|
|||
|
||||
INTERFACE_TERMINAL( EnumSet.of( YesNo.YES, YesNo.NO ) ), CRAFT_VIA_REDSTONE( EnumSet.of( YesNo.YES, YesNo.NO ) ),
|
||||
|
||||
STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ), PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) );
|
||||
STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ), PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ),
|
||||
|
||||
SCHEDULING_MODE( EnumSet.allOf( SchedulingMode.class ) );
|
||||
|
||||
private final EnumSet<? extends Enum<?>> values;
|
||||
|
||||
Settings( @Nonnull EnumSet<? extends Enum<?>> possibleOptions )
|
||||
{
|
||||
if ( possibleOptions.isEmpty() )
|
||||
if( possibleOptions.isEmpty() )
|
||||
{
|
||||
throw new IllegalArgumentException( "Tried to instantiate an empty setting." );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.lwjgl.input.Mouse;
|
|||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
|
@ -38,6 +39,7 @@ import appeng.container.implementations.ContainerUpgradeable;
|
|||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
|
||||
|
||||
|
@ -50,6 +52,7 @@ public class GuiUpgradeable extends AEBaseGui
|
|||
GuiImgButton redstoneMode;
|
||||
GuiImgButton fuzzyMode;
|
||||
GuiImgButton craftMode;
|
||||
GuiImgButton schedulingMode;
|
||||
|
||||
public GuiUpgradeable( InventoryPlayer inventoryPlayer, IUpgradeableHost te )
|
||||
{
|
||||
|
@ -83,10 +86,12 @@ public class GuiUpgradeable extends AEBaseGui
|
|||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
|
||||
this.schedulingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
|
||||
|
||||
this.buttonList.add( this.craftMode );
|
||||
this.buttonList.add( this.redstoneMode );
|
||||
this.buttonList.add( this.fuzzyMode );
|
||||
this.buttonList.add( this.schedulingMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,6 +114,11 @@ public class GuiUpgradeable extends AEBaseGui
|
|||
{
|
||||
this.craftMode.set( this.cvb.cMode );
|
||||
}
|
||||
|
||||
if( this.schedulingMode != null )
|
||||
{
|
||||
this.schedulingMode.set( this.cvb.schedulingMode );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -142,6 +152,10 @@ public class GuiUpgradeable extends AEBaseGui
|
|||
{
|
||||
this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
}
|
||||
if( this.schedulingMode != null )
|
||||
{
|
||||
this.schedulingMode.setVisibility(this.bc.getInstalledUpgrades( Upgrades.CAPACITY ) > 0 && this.bc instanceof PartExportBus );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
|
@ -180,5 +194,10 @@ public class GuiUpgradeable extends AEBaseGui
|
|||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) );
|
||||
}
|
||||
|
||||
if( btn == this.schedulingMode )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.schedulingMode.getSetting(), backwards ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import appeng.api.config.OperationMode;
|
|||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.RelativeDirection;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
|
@ -158,6 +159,10 @@ public class GuiImgButton extends GuiButton implements ITooltip
|
|||
|
||||
this.registerApp( 16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementYes );
|
||||
this.registerApp( 16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementNo );
|
||||
|
||||
this.registerApp( 16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault );
|
||||
this.registerApp( 16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRoundRobin );
|
||||
this.registerApp( 16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRandom );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
|
@ -58,6 +59,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
|
||||
@GuiSync( 5 )
|
||||
public YesNo cMode = YesNo.NO;
|
||||
@GuiSync( 6 )
|
||||
public SchedulingMode schedulingMode = SchedulingMode.DEFAULT;
|
||||
int tbSlot;
|
||||
NetworkToolViewer tbInventory;
|
||||
|
||||
|
@ -217,6 +220,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
if( this.upgradeable instanceof PartExportBus )
|
||||
{
|
||||
this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY );
|
||||
this.schedulingMode = (SchedulingMode) cm.getSetting( Settings.SCHEDULING_MODE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ public enum ButtonToolTips
|
|||
BlockPlacement, BlockPlacementYes, BlockPlacementNo,
|
||||
|
||||
// Used in the tooltips of the items in the terminal, when moused over
|
||||
ItemsStored, ItemsRequestable;
|
||||
ItemsStored, ItemsRequestable,
|
||||
|
||||
SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom;
|
||||
|
||||
final String root;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import appeng.api.config.Actionable;
|
|||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
|
@ -65,10 +66,11 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
public class PartExportBus extends PartSharedItemBus implements ICraftingRequester
|
||||
{
|
||||
final MultiCraftingTracker cratingTracker = new MultiCraftingTracker( this, 9 );
|
||||
final BaseActionSource mySrc;
|
||||
long itemToSend = 1;
|
||||
boolean didSomething = false;
|
||||
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 );
|
||||
private final BaseActionSource mySrc;
|
||||
private long itemToSend = 1;
|
||||
private boolean didSomething = false;
|
||||
private int nextSlot = 0;
|
||||
|
||||
@Reflected
|
||||
public PartExportBus( ItemStack is )
|
||||
|
@ -78,6 +80,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
|
||||
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
|
||||
this.mySrc = new MachineSource( this );
|
||||
}
|
||||
|
||||
|
@ -85,76 +88,64 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.cratingTracker.readFromNBT( extra );
|
||||
this.craftingTracker.readFromNBT( extra );
|
||||
this.nextSlot = extra.getInteger( "nextSlot" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.cratingTracker.writeToNBT( extra );
|
||||
this.craftingTracker.writeToNBT( extra );
|
||||
extra.setInteger( "nextSlot", this.nextSlot );
|
||||
}
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
protected TickRateModulation doBusWork()
|
||||
{
|
||||
if( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() || !this.canDoBusWork() )
|
||||
{
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
this.itemToSend = 1;
|
||||
this.itemToSend = this.calculateItemsToSend();
|
||||
this.didSomething = false;
|
||||
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
this.itemToSend = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.itemToSend = 8;
|
||||
break;
|
||||
case 2:
|
||||
this.itemToSend = 32;
|
||||
break;
|
||||
case 3:
|
||||
this.itemToSend = 64;
|
||||
break;
|
||||
case 4:
|
||||
this.itemToSend = 96;
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
InventoryAdaptor d = this.getHandler();
|
||||
IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
ICraftingGrid cg = this.proxy.getCrafting();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
final InventoryAdaptor destination = this.getHandler();
|
||||
final IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
final IEnergyGrid energy = this.proxy.getEnergy();
|
||||
final ICraftingGrid cg = this.proxy.getCrafting();
|
||||
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
final SchedulingMode schedulingMode = (SchedulingMode) this.getConfigManager().getSetting( Settings.SCHEDULING_MODE );
|
||||
|
||||
if( d != null )
|
||||
if( destination != null )
|
||||
{
|
||||
for( int x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||
int x = 0;
|
||||
|
||||
for( x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||
{
|
||||
IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
int slotToExport = this.getStartingSlot( schedulingMode, x );
|
||||
|
||||
final IAEItemStack ais = this.config.getAEStackInSlot( slotToExport );
|
||||
|
||||
if( ais == null || this.itemToSend <= 0 || this.craftOnly() )
|
||||
{
|
||||
if( this.isCraftingEnabled() )
|
||||
{
|
||||
this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorld(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
long before = this.itemToSend;
|
||||
final long before = this.itemToSend;
|
||||
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
for( IAEItemStack o : ImmutableList.copyOf( inv.getStorageList().findFuzzy( ais, fzMode ) ) )
|
||||
{
|
||||
this.pushItemIntoTarget( d, energy, inv, o );
|
||||
this.pushItemIntoTarget( destination, energy, inv, o );
|
||||
if( this.itemToSend <= 0 )
|
||||
{
|
||||
break;
|
||||
|
@ -163,14 +154,20 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
}
|
||||
else
|
||||
{
|
||||
this.pushItemIntoTarget( d, energy, inv, ais );
|
||||
this.pushItemIntoTarget( destination, energy, inv, ais );
|
||||
}
|
||||
|
||||
if( this.itemToSend == before && this.isCraftingEnabled() )
|
||||
{
|
||||
this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorld(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
}
|
||||
}
|
||||
|
||||
this.updateSchedulingMode( schedulingMode, x );
|
||||
}
|
||||
else
|
||||
{
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
|
@ -194,7 +191,6 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory( IPartRenderHelper rh, ModelGenerator renderer )
|
||||
{
|
||||
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
|
@ -259,12 +255,6 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
return new TickingRequest( TickRates.ExportBus.min, TickRates.ExportBus.max, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
|
@ -277,66 +267,24 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
return this.doBusWork();
|
||||
}
|
||||
|
||||
private boolean craftOnly()
|
||||
{
|
||||
return this.getConfigManager().getSetting( Settings.CRAFT_ONLY ) == YesNo.YES;
|
||||
}
|
||||
|
||||
private boolean isCraftingEnabled()
|
||||
{
|
||||
return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0;
|
||||
}
|
||||
|
||||
private void pushItemIntoTarget( InventoryAdaptor d, IEnergyGrid energy, IMEInventory<IAEItemStack> inv, IAEItemStack ais )
|
||||
{
|
||||
ItemStack is = ais.getItemStack();
|
||||
is.stackSize = (int) this.itemToSend;
|
||||
|
||||
ItemStack o = d.simulateAdd( is );
|
||||
long canFit = o == null ? this.itemToSend : this.itemToSend - o.stackSize;
|
||||
|
||||
if( canFit > 0 )
|
||||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( canFit );
|
||||
IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais, this.mySrc );
|
||||
|
||||
if( itemsToAdd != null )
|
||||
{
|
||||
this.itemToSend -= itemsToAdd.getStackSize();
|
||||
|
||||
ItemStack failed = d.addItems( itemsToAdd.getItemStack() );
|
||||
if( failed != null )
|
||||
{
|
||||
ais.setStackSize( failed.stackSize );
|
||||
inv.injectItems( ais, Actionable.MODULATE, this.mySrc );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.didSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
||||
{
|
||||
return this.cratingTracker.getRequestedJobs();
|
||||
return this.craftingTracker.getRequestedJobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems( ICraftingLink link, IAEItemStack items, Actionable mode )
|
||||
{
|
||||
InventoryAdaptor d = this.getHandler();
|
||||
final InventoryAdaptor d = this.getHandler();
|
||||
|
||||
try
|
||||
{
|
||||
if( d != null && this.proxy.isActive() )
|
||||
{
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
final IEnergyGrid energy = this.proxy.getEnergy();
|
||||
final double power = items.getStackSize();
|
||||
|
||||
double power = items.getStackSize();
|
||||
if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
|
||||
{
|
||||
if( mode == Actionable.MODULATE )
|
||||
|
@ -358,6 +306,77 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||
@Override
|
||||
public void jobStateChange( ICraftingLink link )
|
||||
{
|
||||
this.cratingTracker.jobStateChange( link );
|
||||
this.craftingTracker.jobStateChange( link );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSleeping()
|
||||
{
|
||||
return this.getHandler() == null || super.isSleeping();
|
||||
}
|
||||
|
||||
private boolean craftOnly()
|
||||
{
|
||||
return this.getConfigManager().getSetting( Settings.CRAFT_ONLY ) == YesNo.YES;
|
||||
}
|
||||
|
||||
private boolean isCraftingEnabled()
|
||||
{
|
||||
return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0;
|
||||
}
|
||||
|
||||
private void pushItemIntoTarget( InventoryAdaptor d, IEnergyGrid energy, IMEInventory<IAEItemStack> inv, IAEItemStack ais )
|
||||
{
|
||||
final ItemStack is = ais.getItemStack();
|
||||
is.stackSize = (int) this.itemToSend;
|
||||
|
||||
final ItemStack o = d.simulateAdd( is );
|
||||
long canFit = o == null ? this.itemToSend : this.itemToSend - o.stackSize;
|
||||
|
||||
if( canFit > 0 )
|
||||
{
|
||||
ais = ais.copy();
|
||||
ais.setStackSize( canFit );
|
||||
IAEItemStack itemsToAdd = Platform.poweredExtraction( energy, inv, ais, this.mySrc );
|
||||
|
||||
if( itemsToAdd != null )
|
||||
{
|
||||
this.itemToSend -= itemsToAdd.getStackSize();
|
||||
|
||||
final ItemStack failed = d.addItems( itemsToAdd.getItemStack() );
|
||||
if( failed != null )
|
||||
{
|
||||
ais.setStackSize( failed.stackSize );
|
||||
inv.injectItems( ais, Actionable.MODULATE, this.mySrc );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.didSomething = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getStartingSlot( SchedulingMode schedulingMode, int x )
|
||||
{
|
||||
if( schedulingMode == SchedulingMode.RANDOM )
|
||||
{
|
||||
return Platform.getRandom().nextInt( this.availableSlots() );
|
||||
}
|
||||
|
||||
if( schedulingMode == SchedulingMode.ROUNDROBIN )
|
||||
{
|
||||
return ( this.nextSlot + x ) % this.availableSlots();
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
private void updateSchedulingMode( SchedulingMode schedulingMode, int x )
|
||||
{
|
||||
if( schedulingMode == SchedulingMode.ROUNDROBIN )
|
||||
{
|
||||
this.nextSlot = ( this.nextSlot + x ) % this.availableSlots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ import appeng.util.inv.IInventoryDestination;
|
|||
public class PartImportBus extends PartSharedItemBus implements IInventoryDestination
|
||||
{
|
||||
private final BaseActionSource source;
|
||||
IMEInventory<IAEItemStack> destination = null;
|
||||
IAEItemStack lastItemChecked = null;
|
||||
private IMEInventory<IAEItemStack> destination = null;
|
||||
private IAEItemStack lastItemChecked = null;
|
||||
private int itemToSend; // used in tickingRequest
|
||||
private boolean worked; // used in tickingRequest
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
|||
return false;
|
||||
}
|
||||
|
||||
IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source );
|
||||
final IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source );
|
||||
if( out == null )
|
||||
{
|
||||
return true;
|
||||
|
@ -171,50 +171,32 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
|||
}
|
||||
|
||||
@Override
|
||||
TickRateModulation doBusWork()
|
||||
protected TickRateModulation doBusWork()
|
||||
{
|
||||
if( !this.proxy.isActive() )
|
||||
if( !this.proxy.isActive() || !this.canDoBusWork() )
|
||||
{
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
this.worked = false;
|
||||
|
||||
InventoryAdaptor myAdaptor = this.getHandler();
|
||||
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
final InventoryAdaptor myAdaptor = this.getHandler();
|
||||
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
|
||||
if( myAdaptor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
this.itemToSend = 1;
|
||||
break;
|
||||
case 1:
|
||||
this.itemToSend = 8;
|
||||
break;
|
||||
case 2:
|
||||
this.itemToSend = 32;
|
||||
break;
|
||||
case 3:
|
||||
this.itemToSend = 64;
|
||||
break;
|
||||
case 4:
|
||||
this.itemToSend = 96;
|
||||
break;
|
||||
}
|
||||
|
||||
this.itemToSend = this.calculateItemsToSend();
|
||||
this.itemToSend = Math.min( this.itemToSend, (int) ( 0.01 + this.proxy.getEnergy().extractAEPower( this.itemToSend, Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) );
|
||||
IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
final IMEMonitor<IAEItemStack> inv = this.proxy.getStorage().getItemInventory();
|
||||
final IEnergyGrid energy = this.proxy.getEnergy();
|
||||
|
||||
boolean Configured = false;
|
||||
for( int x = 0; x < this.availableSlots(); x++ )
|
||||
{
|
||||
IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
final IAEItemStack ais = this.config.getAEStackInSlot( x );
|
||||
if( ais != null && this.itemToSend > 0 )
|
||||
{
|
||||
Configured = true;
|
||||
|
@ -254,14 +236,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
|||
|
||||
private boolean importStuff( InventoryAdaptor myAdaptor, IAEItemStack whatToImport, IMEMonitor<IAEItemStack> inv, IEnergySource energy, FuzzyMode fzMode )
|
||||
{
|
||||
int toSend = this.itemToSend;
|
||||
|
||||
if( toSend > 64 )
|
||||
{
|
||||
toSend = 64;
|
||||
}
|
||||
|
||||
final int toSend = Math.min( this.itemToSend, 64 );
|
||||
ItemStack newItems;
|
||||
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) );
|
||||
|
|
|
@ -37,21 +37,16 @@ import appeng.util.Platform;
|
|||
public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable
|
||||
{
|
||||
|
||||
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
int adaptorHash = 0;
|
||||
InventoryAdaptor adaptor;
|
||||
boolean lastRedstone = false;
|
||||
protected final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
private int adaptorHash = 0;
|
||||
private InventoryAdaptor adaptor;
|
||||
private boolean lastRedstone = false;
|
||||
|
||||
public PartSharedItemBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
protected int availableSlots()
|
||||
{
|
||||
return Math.min( 1 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 4, this.config.getSizeInventory() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
|
@ -83,31 +78,26 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
|||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
try
|
||||
this.updateState();
|
||||
if( this.lastRedstone != this.host.hasRedstone( this.side ) )
|
||||
{
|
||||
if( !this.isSleeping() )
|
||||
this.lastRedstone = !this.lastRedstone;
|
||||
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
{
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
this.doBusWork();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.proxy.getTick().sleepDevice( this.proxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
InventoryAdaptor getHandler()
|
||||
protected InventoryAdaptor getHandler()
|
||||
{
|
||||
TileEntity self = this.getHost().getTile();
|
||||
TileEntity target = this.getTileEntity( self, self.getPos().offset( side.getFacing() ) );
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = this.getTileEntity( self, self.getPos().offset( side.getFacing() ) );
|
||||
|
||||
int newAdaptorHash = Platform.generateTileHash( target );
|
||||
final int newAdaptorHash = Platform.generateTileHash( target );
|
||||
|
||||
if( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 )
|
||||
{
|
||||
|
@ -128,23 +118,82 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
|||
{
|
||||
return w.getTileEntity( pos );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int availableSlots()
|
||||
{
|
||||
return Math.min( 1 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 4, this.config.getSizeInventory() );
|
||||
}
|
||||
|
||||
protected int calculateItemsToSend()
|
||||
{
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
return 8;
|
||||
case 2:
|
||||
return 32;
|
||||
case 3:
|
||||
return 64;
|
||||
case 4:
|
||||
return 96;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bus can actually do something.
|
||||
*
|
||||
* Currently this tests if the chunk for the target is actually loaded.
|
||||
*
|
||||
* @return true, if the the bus should do its work.
|
||||
*/
|
||||
protected boolean canDoBusWork()
|
||||
{
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = this.getTileEntity( self, self.getPos().offset( this.side.getFacing() ) );
|
||||
|
||||
final World world = target.getWorld();
|
||||
final int xCoordinate = target.getPos().getX();
|
||||
final int zCoordinate = target.getPos().getZ();
|
||||
|
||||
return world != null && world.getChunkProvider().chunkExists( xCoordinate >> 4, zCoordinate >> 4 );
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !this.isSleeping() )
|
||||
{
|
||||
this.proxy.getTick().wakeDevice( this.proxy.getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.proxy.getTick().sleepDevice( this.proxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
private TileEntity getTileEntity( TileEntity self, int x, int y, int z )
|
||||
{
|
||||
final World w = self.getWorldObj();
|
||||
|
||||
if( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
|
||||
{
|
||||
return w.getTileEntity( x, y, z );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.updateState();
|
||||
if( this.lastRedstone != this.host.hasRedstone( this.side ) )
|
||||
{
|
||||
this.lastRedstone = !this.lastRedstone;
|
||||
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
{
|
||||
this.doBusWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract TickRateModulation doBusWork();
|
||||
protected abstract TickRateModulation doBusWork();
|
||||
}
|
||||
|
|
|
@ -313,6 +313,10 @@ gui.tooltips.appliedenergistics2.ReportInaccessibleItemsNo=No: Only extractable
|
|||
gui.tooltips.appliedenergistics2.BlockPlacement=Block Placement
|
||||
gui.tooltips.appliedenergistics2.BlockPlacementYes=Blocks will be placed as block.
|
||||
gui.tooltips.appliedenergistics2.BlockPlacementNo=Blocks will be dropped as item.
|
||||
gui.tooltips.appliedenergistics2.SchedulingMode=Scheduling Mode
|
||||
gui.tooltips.appliedenergistics2.SchedulingModeDefault=Export the first item until the network is empty, then try the next ones.
|
||||
gui.tooltips.appliedenergistics2.SchedulingModeRoundRobin=Export using round robin mode.
|
||||
gui.tooltips.appliedenergistics2.SchedulingModeRandom=Export items in random mode.
|
||||
gui.tooltips.appliedenergistics2.ItemsStored=Items Stored: %s
|
||||
gui.tooltips.appliedenergistics2.ItemsRequestable=Items Requestable: %s
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue