Changed access to use this qualifier
This commit is contained in:
@@ -29,7 +29,7 @@ public class CraftBranchFailure extends Exception
|
||||
|
||||
public CraftBranchFailure(IAEItemStack what, long howMany) {
|
||||
super( "Failed: " + what.getItem().getUnlocalizedName() + " x " + howMany );
|
||||
missing = what.copy();
|
||||
missing.setStackSize( howMany );
|
||||
this.missing = what.copy();
|
||||
this.missing.setStackSize( howMany );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CraftingCalculationFailure extends RuntimeException
|
||||
|
||||
public CraftingCalculationFailure(IAEItemStack what, long howMany) {
|
||||
super( "this should have been caught!" );
|
||||
missing = what.copy();
|
||||
missing.setStackSize( howMany );
|
||||
this.missing = what.copy();
|
||||
this.missing.setStackSize( howMany );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,43 +63,43 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
@Override
|
||||
public IAEItemStack getOutput()
|
||||
{
|
||||
return output;
|
||||
return this.output;
|
||||
}
|
||||
|
||||
public CraftingJob(World w, NBTTagCompound data)
|
||||
{
|
||||
world = wrapWorld( w );
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
prophecies = new HashSet<IAEItemStack>();
|
||||
original = null;
|
||||
availableCheck = null;
|
||||
this.world = this.wrapWorld( w );
|
||||
this.storage = AEApi.instance().storage().createItemList();
|
||||
this.prophecies = new HashSet<IAEItemStack>();
|
||||
this.original = null;
|
||||
this.availableCheck = null;
|
||||
}
|
||||
|
||||
public void refund(IAEItemStack o)
|
||||
{
|
||||
availableCheck.injectItems( o, Actionable.MODULATE, this.actionSrc );
|
||||
this.availableCheck.injectItems( o, Actionable.MODULATE, this.actionSrc );
|
||||
}
|
||||
|
||||
public IAEItemStack checkUse(IAEItemStack available)
|
||||
{
|
||||
return availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
|
||||
return this.availableCheck.extractItems( available, Actionable.MODULATE, this.actionSrc );
|
||||
}
|
||||
|
||||
public CraftingJob(World w, IGrid grid, BaseActionSource actionSrc, IAEItemStack what, ICraftingCallback callback)
|
||||
{
|
||||
world = wrapWorld( w );
|
||||
output = what.copy();
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
prophecies = new HashSet<IAEItemStack>();
|
||||
this.world = this.wrapWorld( w );
|
||||
this.output = what.copy();
|
||||
this.storage = AEApi.instance().storage().createItemList();
|
||||
this.prophecies = new HashSet<IAEItemStack>();
|
||||
this.actionSrc = actionSrc;
|
||||
|
||||
this.callback = callback;
|
||||
ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
|
||||
IStorageGrid sg = grid.getCache( IStorageGrid.class );
|
||||
original = new MECraftingInventory( sg.getItemInventory(), actionSrc, false, false, false );
|
||||
this.original = new MECraftingInventory( sg.getItemInventory(), actionSrc, false, false, false );
|
||||
|
||||
tree = getCraftingTree( cc, what );
|
||||
availableCheck = null;
|
||||
this.tree = this.getCraftingTree( cc, what );
|
||||
this.availableCheck = null;
|
||||
}
|
||||
|
||||
private World wrapWorld(World w)
|
||||
@@ -115,7 +115,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
@Override
|
||||
public long getByteTotal()
|
||||
{
|
||||
return bytes;
|
||||
return this.bytes;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound out)
|
||||
@@ -132,14 +132,14 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
{
|
||||
what = what.copy();
|
||||
what.setStackSize( what.getStackSize() * crafts );
|
||||
crafting.add( what );
|
||||
this.crafting.add( what );
|
||||
}
|
||||
}
|
||||
|
||||
public void addMissing(IAEItemStack what)
|
||||
{
|
||||
what = what.copy();
|
||||
missing.add( what );
|
||||
this.missing.add( what );
|
||||
}
|
||||
|
||||
static class TwoIntegers
|
||||
@@ -158,51 +158,51 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
{
|
||||
try
|
||||
{
|
||||
TickHandler.instance.registerCraftingSimulation( world, this );
|
||||
handlePausing();
|
||||
TickHandler.instance.registerCraftingSimulation( this.world, this );
|
||||
this.handlePausing();
|
||||
|
||||
Stopwatch timer = Stopwatch.createStarted();
|
||||
|
||||
MECraftingInventory craftingInventory = new MECraftingInventory( original, true, false, true );
|
||||
craftingInventory.ignore( output );
|
||||
MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
|
||||
craftingInventory.ignore( this.output );
|
||||
|
||||
availableCheck = new MECraftingInventory( original, false, false, false );
|
||||
tree.request( craftingInventory, output.getStackSize(), actionSrc );
|
||||
tree.dive( this );
|
||||
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
|
||||
this.tree.request( craftingInventory, this.output.getStackSize(), this.actionSrc );
|
||||
this.tree.dive( this );
|
||||
|
||||
for (String s : opsAndMultiplier.keySet())
|
||||
for (String s : this.opsAndMultiplier.keySet())
|
||||
{
|
||||
TwoIntegers ti = opsAndMultiplier.get( s );
|
||||
TwoIntegers ti = this.opsAndMultiplier.get( s );
|
||||
AELog.crafting( s + " * " + ti.times + " = " + (ti.perOp * ti.times) );
|
||||
}
|
||||
|
||||
AELog.crafting( "------------- " + getByteTotal() + "b real" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
|
||||
AELog.crafting( "------------- " + this.getByteTotal() + "b real" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
|
||||
// if ( mode == Actionable.MODULATE )
|
||||
// craftingInventory.moveItemsToStorage( storage );
|
||||
}
|
||||
catch (CraftBranchFailure e)
|
||||
{
|
||||
simulate = true;
|
||||
this.simulate = true;
|
||||
|
||||
try
|
||||
{
|
||||
Stopwatch timer = Stopwatch.createStarted();
|
||||
MECraftingInventory craftingInventory = new MECraftingInventory( original, true, false, true );
|
||||
craftingInventory.ignore( output );
|
||||
MECraftingInventory craftingInventory = new MECraftingInventory( this.original, true, false, true );
|
||||
craftingInventory.ignore( this.output );
|
||||
|
||||
availableCheck = new MECraftingInventory( original, false, false, false );
|
||||
this.availableCheck = new MECraftingInventory( this.original, false, false, false );
|
||||
|
||||
tree.setSimulate();
|
||||
tree.request( craftingInventory, output.getStackSize(), actionSrc );
|
||||
tree.dive( this );
|
||||
this.tree.setSimulate();
|
||||
this.tree.request( craftingInventory, this.output.getStackSize(), this.actionSrc );
|
||||
this.tree.dive( this );
|
||||
|
||||
for (String s : opsAndMultiplier.keySet())
|
||||
for (String s : this.opsAndMultiplier.keySet())
|
||||
{
|
||||
TwoIntegers ti = opsAndMultiplier.get( s );
|
||||
TwoIntegers ti = this.opsAndMultiplier.get( s );
|
||||
AELog.crafting( s + " * " + ti.times + " = " + (ti.perOp * ti.times) );
|
||||
}
|
||||
|
||||
AELog.crafting( "------------- " + getByteTotal() + "b simulate" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
|
||||
AELog.crafting( "------------- " + this.getByteTotal() + "b simulate" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" );
|
||||
}
|
||||
catch (CraftBranchFailure e1)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
AELog.crafting( "Crafting calculation canceled." );
|
||||
finish();
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -226,51 +226,51 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
AELog.crafting( "Crafting calculation canceled." );
|
||||
finish();
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
log( "crafting job now done" );
|
||||
this.log( "crafting job now done" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
finish();
|
||||
this.finish();
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
|
||||
finish();
|
||||
this.finish();
|
||||
|
||||
}
|
||||
|
||||
public void finish()
|
||||
{
|
||||
if ( callback != null )
|
||||
callback.calculationComplete( this );
|
||||
if ( this.callback != null )
|
||||
this.callback.calculationComplete( this );
|
||||
|
||||
availableCheck = null;
|
||||
this.availableCheck = null;
|
||||
|
||||
synchronized (monitor)
|
||||
synchronized (this.monitor)
|
||||
{
|
||||
running = false;
|
||||
done = true;
|
||||
monitor.notify();
|
||||
this.running = false;
|
||||
this.done = true;
|
||||
this.monitor.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSimulation()
|
||||
{
|
||||
return simulate;
|
||||
return this.simulate;
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return done;
|
||||
return this.done;
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return world;
|
||||
return this.world;
|
||||
}
|
||||
|
||||
private boolean running = false;
|
||||
@@ -287,33 +287,33 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
*/
|
||||
public boolean simulateFor(int milli)
|
||||
{
|
||||
time = milli;
|
||||
this.time = milli;
|
||||
|
||||
synchronized (monitor)
|
||||
synchronized (this.monitor)
|
||||
{
|
||||
if ( isDone() )
|
||||
if ( this.isDone() )
|
||||
return false;
|
||||
|
||||
watch.reset();
|
||||
watch.start();
|
||||
running = true;
|
||||
this.watch.reset();
|
||||
this.watch.start();
|
||||
this.running = true;
|
||||
|
||||
log( "main thread is now going to sleep" );
|
||||
this.log( "main thread is now going to sleep" );
|
||||
|
||||
monitor.notify();
|
||||
this.monitor.notify();
|
||||
|
||||
while (running)
|
||||
while (this.running)
|
||||
{
|
||||
try
|
||||
{
|
||||
monitor.wait();
|
||||
this.monitor.wait();
|
||||
}
|
||||
catch (InterruptedException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
log( "main thread is now active" );
|
||||
this.log( "main thread is now active" );
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -323,29 +323,29 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
|
||||
public void handlePausing() throws InterruptedException
|
||||
{
|
||||
if ( incTime++ > 100 )
|
||||
if ( this.incTime++ > 100 )
|
||||
{
|
||||
incTime = 0;
|
||||
this.incTime = 0;
|
||||
|
||||
synchronized (monitor)
|
||||
synchronized (this.monitor)
|
||||
{
|
||||
if ( watch.elapsed( TimeUnit.MICROSECONDS ) > time )
|
||||
if ( this.watch.elapsed( TimeUnit.MICROSECONDS ) > this.time )
|
||||
{
|
||||
running = false;
|
||||
watch.stop();
|
||||
monitor.notify();
|
||||
this.running = false;
|
||||
this.watch.stop();
|
||||
this.monitor.notify();
|
||||
}
|
||||
|
||||
if ( !running )
|
||||
if ( !this.running )
|
||||
{
|
||||
log( "crafting job will now sleep" );
|
||||
this.log( "crafting job will now sleep" );
|
||||
|
||||
while (!running)
|
||||
while (!this.running)
|
||||
{
|
||||
monitor.wait();
|
||||
this.monitor.wait();
|
||||
}
|
||||
|
||||
log( "crafting job now active" );
|
||||
this.log( "crafting job now active" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,14 +361,14 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
|
||||
public void addBytes(long crafts)
|
||||
{
|
||||
bytes += crafts;
|
||||
this.bytes += crafts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populatePlan(IItemList<IAEItemStack> plan)
|
||||
{
|
||||
if ( tree != null )
|
||||
tree.getPlan( plan );
|
||||
if ( this.tree != null )
|
||||
this.tree.getPlan( plan );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,98 +40,98 @@ public class CraftingLink implements ICraftingLink
|
||||
final boolean standalone;
|
||||
|
||||
public CraftingLink(NBTTagCompound data, ICraftingRequester req) {
|
||||
CraftID = data.getString( "CraftID" );
|
||||
canceled = data.getBoolean( "canceled" );
|
||||
done = data.getBoolean( "done" );
|
||||
standalone = data.getBoolean( "standalone" );
|
||||
this.CraftID = data.getString( "CraftID" );
|
||||
this.canceled = data.getBoolean( "canceled" );
|
||||
this.done = data.getBoolean( "done" );
|
||||
this.standalone = data.getBoolean( "standalone" );
|
||||
|
||||
if ( !data.hasKey( "req" ) || !data.getBoolean( "req" ) )
|
||||
throw new RuntimeException( "Invalid Crafting Link for Object" );
|
||||
|
||||
this.req = req;
|
||||
cpu = null;
|
||||
this.cpu = null;
|
||||
}
|
||||
|
||||
public CraftingLink(NBTTagCompound data, ICraftingCPU cpu) {
|
||||
CraftID = data.getString( "CraftID" );
|
||||
canceled = data.getBoolean( "canceled" );
|
||||
done = data.getBoolean( "done" );
|
||||
standalone = data.getBoolean( "standalone" );
|
||||
this.CraftID = data.getString( "CraftID" );
|
||||
this.canceled = data.getBoolean( "canceled" );
|
||||
this.done = data.getBoolean( "done" );
|
||||
this.standalone = data.getBoolean( "standalone" );
|
||||
|
||||
if ( !data.hasKey( "req" ) || data.getBoolean( "req" ) )
|
||||
throw new RuntimeException( "Invalid Crafting Link for Object" );
|
||||
|
||||
this.cpu = cpu;
|
||||
req = null;
|
||||
this.req = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCanceled()
|
||||
{
|
||||
if ( canceled )
|
||||
if ( this.canceled )
|
||||
return true;
|
||||
|
||||
if ( done )
|
||||
if ( this.done )
|
||||
return false;
|
||||
|
||||
if ( tie == null )
|
||||
if ( this.tie == null )
|
||||
return false;
|
||||
|
||||
return tie.isCanceled();
|
||||
return this.tie.isCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone()
|
||||
{
|
||||
if ( done )
|
||||
if ( this.done )
|
||||
return true;
|
||||
|
||||
if ( canceled )
|
||||
if ( this.canceled )
|
||||
return false;
|
||||
|
||||
if ( tie == null )
|
||||
if ( this.tie == null )
|
||||
return false;
|
||||
|
||||
return tie.isDone();
|
||||
return this.tie.isDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel()
|
||||
{
|
||||
if ( done )
|
||||
if ( this.done )
|
||||
return;
|
||||
|
||||
canceled = true;
|
||||
this.canceled = true;
|
||||
|
||||
if ( tie != null )
|
||||
tie.cancel();
|
||||
if ( this.tie != null )
|
||||
this.tie.cancel();
|
||||
|
||||
tie = null;
|
||||
this.tie = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setString( "CraftID", CraftID );
|
||||
tag.setBoolean( "canceled", canceled );
|
||||
tag.setBoolean( "done", done );
|
||||
tag.setBoolean( "standalone", standalone );
|
||||
tag.setBoolean( "req", req != null );
|
||||
tag.setString( "CraftID", this.CraftID );
|
||||
tag.setBoolean( "canceled", this.canceled );
|
||||
tag.setBoolean( "done", this.done );
|
||||
tag.setBoolean( "standalone", this.standalone );
|
||||
tag.setBoolean( "req", this.req != null );
|
||||
}
|
||||
|
||||
public void setNexus(CraftingLinkNexus n)
|
||||
{
|
||||
if ( tie != null )
|
||||
tie.remove( this );
|
||||
if ( this.tie != null )
|
||||
this.tie.remove( this );
|
||||
|
||||
if ( canceled && n != null )
|
||||
if ( this.canceled && n != null )
|
||||
{
|
||||
n.cancel();
|
||||
tie = null;
|
||||
this.tie = null;
|
||||
return;
|
||||
}
|
||||
|
||||
tie = n;
|
||||
this.tie = n;
|
||||
|
||||
if ( n != null )
|
||||
n.add( this );
|
||||
@@ -140,26 +140,26 @@ public class CraftingLink implements ICraftingLink
|
||||
@Override
|
||||
public String getCraftingID()
|
||||
{
|
||||
return CraftID;
|
||||
return this.CraftID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStandalone()
|
||||
{
|
||||
return standalone;
|
||||
return this.standalone;
|
||||
}
|
||||
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
if ( tie == null || tie.req == null || tie.req.req == null )
|
||||
if ( this.tie == null || this.tie.req == null || this.tie.req.req == null )
|
||||
return input;
|
||||
|
||||
return tie.req.req.injectCraftedItems( tie.req, input, mode );
|
||||
return this.tie.req.req.injectCraftedItems( this.tie.req, input, mode );
|
||||
}
|
||||
|
||||
public void markDone()
|
||||
{
|
||||
if ( tie != null )
|
||||
tie.markDone();
|
||||
if ( this.tie != null )
|
||||
this.tie.markDone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,25 +41,25 @@ public class CraftingLinkNexus
|
||||
|
||||
public boolean isDead(IGrid g, CraftingGridCache craftingGridCache)
|
||||
{
|
||||
if ( isCanceled() || isDone() )
|
||||
if ( this.isCanceled() || this.isDone() )
|
||||
return true;
|
||||
|
||||
if ( req == null || cpu == null )
|
||||
tickOfDeath++;
|
||||
if ( this.req == null || this.cpu == null )
|
||||
this.tickOfDeath++;
|
||||
else
|
||||
{
|
||||
boolean hasCpu = craftingGridCache.hasCpu( cpu.cpu );
|
||||
boolean hasMachine = req.req.getActionableNode().getGrid() == g;
|
||||
boolean hasCpu = craftingGridCache.hasCpu( this.cpu.cpu );
|
||||
boolean hasMachine = this.req.req.getActionableNode().getGrid() == g;
|
||||
|
||||
if ( hasCpu && hasMachine )
|
||||
tickOfDeath = 0;
|
||||
this.tickOfDeath = 0;
|
||||
else
|
||||
tickOfDeath += 60;
|
||||
this.tickOfDeath += 60;
|
||||
}
|
||||
|
||||
if ( tickOfDeath > 60 )
|
||||
if ( this.tickOfDeath > 60 )
|
||||
{
|
||||
cancel();
|
||||
this.cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,72 +68,72 @@ public class CraftingLinkNexus
|
||||
|
||||
public void remove(CraftingLink craftingLink)
|
||||
{
|
||||
if ( req == craftingLink )
|
||||
req = null;
|
||||
else if ( cpu == craftingLink )
|
||||
cpu = null;
|
||||
if ( this.req == craftingLink )
|
||||
this.req = null;
|
||||
else if ( this.cpu == craftingLink )
|
||||
this.cpu = null;
|
||||
}
|
||||
|
||||
public void add(CraftingLink craftingLink)
|
||||
{
|
||||
if ( craftingLink.cpu != null )
|
||||
cpu = craftingLink;
|
||||
this.cpu = craftingLink;
|
||||
else if ( craftingLink.req != null )
|
||||
req = craftingLink;
|
||||
this.req = craftingLink;
|
||||
}
|
||||
|
||||
public boolean isCanceled()
|
||||
{
|
||||
return canceled;
|
||||
return this.canceled;
|
||||
}
|
||||
|
||||
public boolean isDone()
|
||||
{
|
||||
return done;
|
||||
return this.done;
|
||||
}
|
||||
|
||||
public void markDone()
|
||||
{
|
||||
done = true;
|
||||
this.done = true;
|
||||
|
||||
if ( req != null )
|
||||
if ( this.req != null )
|
||||
{
|
||||
req.done = true;
|
||||
if ( req.req != null )
|
||||
req.req.jobStateChange( req );
|
||||
this.req.done = true;
|
||||
if ( this.req.req != null )
|
||||
this.req.req.jobStateChange( this.req );
|
||||
}
|
||||
|
||||
if ( cpu != null )
|
||||
cpu.done = true;
|
||||
if ( this.cpu != null )
|
||||
this.cpu.done = true;
|
||||
}
|
||||
|
||||
public void cancel()
|
||||
{
|
||||
canceled = true;
|
||||
this.canceled = true;
|
||||
|
||||
if ( req != null )
|
||||
if ( this.req != null )
|
||||
{
|
||||
req.canceled = true;
|
||||
if ( req.req != null )
|
||||
req.req.jobStateChange( req );
|
||||
this.req.canceled = true;
|
||||
if ( this.req.req != null )
|
||||
this.req.req.jobStateChange( this.req );
|
||||
}
|
||||
|
||||
if ( cpu != null )
|
||||
cpu.canceled = true;
|
||||
if ( this.cpu != null )
|
||||
this.cpu.canceled = true;
|
||||
}
|
||||
|
||||
public boolean isMachine(IGridHost machine)
|
||||
{
|
||||
return req == machine;
|
||||
return this.req == machine;
|
||||
}
|
||||
|
||||
public void removeNode()
|
||||
{
|
||||
if ( req != null )
|
||||
req.setNexus( null );
|
||||
if ( this.req != null )
|
||||
this.req.setNexus( null );
|
||||
|
||||
req = null;
|
||||
tickOfDeath = 0;
|
||||
this.req = null;
|
||||
this.tickOfDeath = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,29 +66,29 @@ public class CraftingTreeNode
|
||||
|
||||
public CraftingTreeNode(ICraftingGrid cc, CraftingJob job, IAEItemStack wat, CraftingTreeProcess par, int slot, int depth)
|
||||
{
|
||||
what = wat;
|
||||
parent = par;
|
||||
this.what = wat;
|
||||
this.parent = par;
|
||||
this.slot = slot;
|
||||
this.world = job.getWorld();
|
||||
this.job = job;
|
||||
sim = false;
|
||||
this.sim = false;
|
||||
|
||||
canEmit = cc.canEmitFor( what );
|
||||
if ( canEmit )
|
||||
this.canEmit = cc.canEmitFor( this.what );
|
||||
if ( this.canEmit )
|
||||
return; // if you can emit for something, you can't make it with patterns.
|
||||
|
||||
for (ICraftingPatternDetails details : cc.getCraftingFor( what, parent == null ? null : parent.details, slot, world ))// in
|
||||
for (ICraftingPatternDetails details : cc.getCraftingFor( this.what, this.parent == null ? null : this.parent.details, slot, this.world ))// in
|
||||
// order.
|
||||
{
|
||||
if ( parent == null || parent.notRecursive( details ) )
|
||||
nodes.add( new CraftingTreeProcess( cc, job, details, this, depth + 1 ) );
|
||||
if ( this.parent == null || this.parent.notRecursive( details ) )
|
||||
this.nodes.add( new CraftingTreeProcess( cc, job, details, this, depth + 1 ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IAEItemStack getStack(long size)
|
||||
{
|
||||
IAEItemStack is = what.copy();
|
||||
IAEItemStack is = this.what.copy();
|
||||
is.setStackSize( size );
|
||||
return is;
|
||||
}
|
||||
@@ -97,32 +97,32 @@ public class CraftingTreeNode
|
||||
{
|
||||
IAEItemStack[] o = details.getCondensedOutputs();
|
||||
for (IAEItemStack i : o)
|
||||
if ( i.equals( what ) )
|
||||
if ( i.equals( this.what ) )
|
||||
return false;
|
||||
|
||||
o = details.getCondensedInputs();
|
||||
for (IAEItemStack i : o)
|
||||
if ( i.equals( what ) )
|
||||
if ( i.equals( this.what ) )
|
||||
return false;
|
||||
|
||||
if ( parent == null )
|
||||
if ( this.parent == null )
|
||||
return true;
|
||||
|
||||
return parent.notRecursive( details );
|
||||
return this.parent.notRecursive( details );
|
||||
}
|
||||
|
||||
public IAEItemStack request(MECraftingInventory inv, long l, BaseActionSource src) throws CraftBranchFailure, InterruptedException
|
||||
{
|
||||
job.handlePausing();
|
||||
this.job.handlePausing();
|
||||
|
||||
List<IAEItemStack> thingsUsed = new LinkedList<IAEItemStack>();
|
||||
|
||||
what.setStackSize( l );
|
||||
if ( slot >= 0 && parent != null && parent.details.isCraftable() )
|
||||
this.what.setStackSize( l );
|
||||
if ( this.slot >= 0 && this.parent != null && this.parent.details.isCraftable() )
|
||||
{
|
||||
for (IAEItemStack fuzz : inv.getItemList().findFuzzy( what, FuzzyMode.IGNORE_ALL ))
|
||||
for (IAEItemStack fuzz : inv.getItemList().findFuzzy( this.what, FuzzyMode.IGNORE_ALL ))
|
||||
{
|
||||
if ( parent.details.isValidItemForSlot( slot, fuzz.getItemStack(), world ) )
|
||||
if ( this.parent.details.isValidItemForSlot( this.slot, fuzz.getItemStack(), this.world ) )
|
||||
{
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( l );
|
||||
@@ -130,17 +130,17 @@ public class CraftingTreeNode
|
||||
|
||||
if ( available != null )
|
||||
{
|
||||
if ( !exhausted )
|
||||
if ( !this.exhausted )
|
||||
{
|
||||
IAEItemStack is = job.checkUse( available );
|
||||
IAEItemStack is = this.job.checkUse( available );
|
||||
if ( is != null )
|
||||
{
|
||||
thingsUsed.add( is.copy() );
|
||||
used.add( is );
|
||||
this.used.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
bytes += available.getStackSize();
|
||||
this.bytes += available.getStackSize();
|
||||
l -= available.getStackSize();
|
||||
|
||||
if ( l == 0 )
|
||||
@@ -151,21 +151,21 @@ public class CraftingTreeNode
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack available = inv.extractItems( what, Actionable.MODULATE, src );
|
||||
IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
|
||||
|
||||
if ( available != null )
|
||||
{
|
||||
if ( !exhausted )
|
||||
if ( !this.exhausted )
|
||||
{
|
||||
IAEItemStack is = job.checkUse( available );
|
||||
IAEItemStack is = this.job.checkUse( available );
|
||||
if ( is != null )
|
||||
{
|
||||
thingsUsed.add( is.copy() );
|
||||
used.add( is );
|
||||
this.used.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
bytes += available.getStackSize();
|
||||
this.bytes += available.getStackSize();
|
||||
l -= available.getStackSize();
|
||||
|
||||
if ( l == 0 )
|
||||
@@ -173,26 +173,26 @@ public class CraftingTreeNode
|
||||
}
|
||||
}
|
||||
|
||||
if ( canEmit )
|
||||
if ( this.canEmit )
|
||||
{
|
||||
IAEItemStack wat = what.copy();
|
||||
IAEItemStack wat = this.what.copy();
|
||||
wat.setStackSize( l );
|
||||
|
||||
howManyEmitted = wat.getStackSize();
|
||||
bytes += wat.getStackSize();
|
||||
this.howManyEmitted = wat.getStackSize();
|
||||
this.bytes += wat.getStackSize();
|
||||
|
||||
return wat;
|
||||
}
|
||||
|
||||
exhausted = true;
|
||||
this.exhausted = true;
|
||||
|
||||
if ( nodes.size() == 1 )
|
||||
if ( this.nodes.size() == 1 )
|
||||
{
|
||||
CraftingTreeProcess pro = nodes.get( 0 );
|
||||
CraftingTreeProcess pro = this.nodes.get( 0 );
|
||||
|
||||
while (pro.possible && l > 0)
|
||||
{
|
||||
IAEItemStack madeWhat = pro.getAmountCrafted( what );
|
||||
IAEItemStack madeWhat = pro.getAmountCrafted( this.what );
|
||||
|
||||
pro.request( inv, pro.getTimes( l, madeWhat.getStackSize() ), src );
|
||||
|
||||
@@ -201,7 +201,7 @@ public class CraftingTreeNode
|
||||
|
||||
if ( available != null )
|
||||
{
|
||||
bytes += available.getStackSize();
|
||||
this.bytes += available.getStackSize();
|
||||
l -= available.getStackSize();
|
||||
|
||||
if ( l <= 0 )
|
||||
@@ -211,9 +211,9 @@ public class CraftingTreeNode
|
||||
pro.possible = false; // ;P
|
||||
}
|
||||
}
|
||||
else if ( nodes.size() > 1 )
|
||||
else if ( this.nodes.size() > 1 )
|
||||
{
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
for (CraftingTreeProcess pro : this.nodes)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -222,15 +222,15 @@ public class CraftingTreeNode
|
||||
MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
|
||||
pro.request( subInv, 1, src );
|
||||
|
||||
what.setStackSize( l );
|
||||
IAEItemStack available = subInv.extractItems( what, Actionable.MODULATE, src );
|
||||
this.what.setStackSize( l );
|
||||
IAEItemStack available = subInv.extractItems( this.what, Actionable.MODULATE, src );
|
||||
|
||||
if ( available != null )
|
||||
{
|
||||
if ( !subInv.commit( src ) )
|
||||
throw new CraftBranchFailure( what, l );
|
||||
throw new CraftBranchFailure( this.what, l );
|
||||
|
||||
bytes += available.getStackSize();
|
||||
this.bytes += available.getStackSize();
|
||||
l -= available.getStackSize();
|
||||
|
||||
if ( l <= 0 )
|
||||
@@ -247,52 +247,52 @@ public class CraftingTreeNode
|
||||
}
|
||||
}
|
||||
|
||||
if ( sim )
|
||||
if ( this.sim )
|
||||
{
|
||||
missing += l;
|
||||
bytes += l;
|
||||
IAEItemStack rv = what.copy();
|
||||
this.missing += l;
|
||||
this.bytes += l;
|
||||
IAEItemStack rv = this.what.copy();
|
||||
rv.setStackSize( l );
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (IAEItemStack o : thingsUsed)
|
||||
{
|
||||
job.refund( o.copy() );
|
||||
this.job.refund( o.copy() );
|
||||
o.setStackSize( -o.getStackSize() );
|
||||
used.add( o );
|
||||
this.used.add( o );
|
||||
}
|
||||
|
||||
throw new CraftBranchFailure( what, l );
|
||||
throw new CraftBranchFailure( this.what, l );
|
||||
}
|
||||
|
||||
public void dive(CraftingJob job)
|
||||
{
|
||||
if ( missing > 0 )
|
||||
job.addMissing( getStack( missing ) );
|
||||
if ( this.missing > 0 )
|
||||
job.addMissing( this.getStack( this.missing ) );
|
||||
// missing = 0;
|
||||
|
||||
job.addBytes( 8 + bytes );
|
||||
job.addBytes( 8 + this.bytes );
|
||||
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
for (CraftingTreeProcess pro : this.nodes)
|
||||
pro.dive( job );
|
||||
}
|
||||
|
||||
public void setSimulate()
|
||||
{
|
||||
sim = true;
|
||||
missing = 0;
|
||||
bytes = 0;
|
||||
used.resetStatus();
|
||||
exhausted = false;
|
||||
this.sim = true;
|
||||
this.missing = 0;
|
||||
this.bytes = 0;
|
||||
this.used.resetStatus();
|
||||
this.exhausted = false;
|
||||
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
for (CraftingTreeProcess pro : this.nodes)
|
||||
pro.setSimulate();
|
||||
}
|
||||
|
||||
public void setJob(MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src) throws CraftBranchFailure
|
||||
{
|
||||
for (IAEItemStack i : used)
|
||||
for (IAEItemStack i : this.used)
|
||||
{
|
||||
IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src );
|
||||
|
||||
@@ -302,37 +302,37 @@ public class CraftingTreeNode
|
||||
craftingCPUCluster.addStorage( ex );
|
||||
}
|
||||
|
||||
if ( howManyEmitted > 0 )
|
||||
if ( this.howManyEmitted > 0 )
|
||||
{
|
||||
IAEItemStack i = what.copy();
|
||||
i.setStackSize( howManyEmitted );
|
||||
IAEItemStack i = this.what.copy();
|
||||
i.setStackSize( this.howManyEmitted );
|
||||
craftingCPUCluster.addEmitable( i );
|
||||
}
|
||||
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
for (CraftingTreeProcess pro : this.nodes)
|
||||
pro.setJob( storage, craftingCPUCluster, src );
|
||||
}
|
||||
|
||||
public void getPlan(IItemList<IAEItemStack> plan)
|
||||
{
|
||||
if ( missing > 0 )
|
||||
if ( this.missing > 0 )
|
||||
{
|
||||
IAEItemStack o = what.copy();
|
||||
o.setStackSize( missing );
|
||||
IAEItemStack o = this.what.copy();
|
||||
o.setStackSize( this.missing );
|
||||
plan.add( o );
|
||||
}
|
||||
|
||||
if ( howManyEmitted > 0 )
|
||||
if ( this.howManyEmitted > 0 )
|
||||
{
|
||||
IAEItemStack i = what.copy();
|
||||
i.setCountRequestable( howManyEmitted );
|
||||
IAEItemStack i = this.what.copy();
|
||||
i.setCountRequestable( this.howManyEmitted );
|
||||
plan.addRequestable( i );
|
||||
}
|
||||
|
||||
for (IAEItemStack i : used)
|
||||
for (IAEItemStack i : this.used)
|
||||
plan.add( i.copy() );
|
||||
|
||||
for (CraftingTreeProcess pro : nodes)
|
||||
for (CraftingTreeProcess pro : this.nodes)
|
||||
pro.getPlan( plan );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CraftingTreeProcess
|
||||
public boolean possible = true;
|
||||
|
||||
public CraftingTreeProcess( ICraftingGrid cc, CraftingJob job, ICraftingPatternDetails details, CraftingTreeNode craftingTreeNode, int depth ) {
|
||||
parent = craftingTreeNode;
|
||||
this.parent = craftingTreeNode;
|
||||
this.details = details;
|
||||
this.job = job;
|
||||
this.depth = depth;
|
||||
@@ -82,7 +82,7 @@ public class CraftingTreeProcess
|
||||
{
|
||||
ItemStack g = ic.getStackInSlot( x );
|
||||
if ( g != null && g.stackSize > 1 )
|
||||
fullSimulation = true;
|
||||
this.fullSimulation = true;
|
||||
}
|
||||
|
||||
for ( IAEItemStack part : details.getCondensedInputs() )
|
||||
@@ -97,21 +97,21 @@ public class CraftingTreeProcess
|
||||
}
|
||||
|
||||
if ( isAnInput )
|
||||
limitQty = true;
|
||||
this.limitQty = true;
|
||||
|
||||
if ( g.getItem().hasContainerItem( g ) )
|
||||
limitQty = containerItems = true;
|
||||
this.limitQty = this.containerItems = true;
|
||||
}
|
||||
|
||||
boolean complicated = false;
|
||||
|
||||
if ( containerItems || complicated )
|
||||
if ( this.containerItems || complicated )
|
||||
{
|
||||
for (int x = 0; x < list.length; x++)
|
||||
{
|
||||
IAEItemStack part = list[x];
|
||||
if ( part != null )
|
||||
nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() );
|
||||
this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -125,7 +125,7 @@ public class CraftingTreeProcess
|
||||
if ( part != null && part.equals( comparePart ) )
|
||||
{
|
||||
// use the first slot...
|
||||
nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() );
|
||||
this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -146,31 +146,31 @@ public class CraftingTreeProcess
|
||||
}
|
||||
|
||||
if ( isAnInput )
|
||||
limitQty = true;
|
||||
this.limitQty = true;
|
||||
}
|
||||
|
||||
for (IAEItemStack part : details.getCondensedInputs())
|
||||
{
|
||||
nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, -1, depth + 1 ), part.getStackSize() );
|
||||
this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, -1, depth + 1 ), part.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean notRecursive(ICraftingPatternDetails details)
|
||||
{
|
||||
return parent == null || parent.notRecursive( details );
|
||||
return this.parent == null || this.parent.notRecursive( details );
|
||||
}
|
||||
|
||||
long getTimes(long remaining, long stackSize)
|
||||
{
|
||||
if ( limitQty || fullSimulation )
|
||||
if ( this.limitQty || this.fullSimulation )
|
||||
return 1;
|
||||
return (remaining / stackSize) + (remaining % stackSize != 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
IAEItemStack getAmountCrafted(IAEItemStack what2)
|
||||
{
|
||||
for (IAEItemStack is : details.getCondensedOutputs())
|
||||
for (IAEItemStack is : this.details.getCondensedOutputs())
|
||||
{
|
||||
if ( is.equals( what2 ) )
|
||||
{
|
||||
@@ -181,7 +181,7 @@ public class CraftingTreeProcess
|
||||
}
|
||||
|
||||
// more fuzzy!
|
||||
for (IAEItemStack is : details.getCondensedOutputs())
|
||||
for (IAEItemStack is : this.details.getCondensedOutputs())
|
||||
{
|
||||
if ( is.getItem() == what2.getItem() && (is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage()) )
|
||||
{
|
||||
@@ -196,13 +196,13 @@ public class CraftingTreeProcess
|
||||
|
||||
public void request(MECraftingInventory inv, long i, BaseActionSource src) throws CraftBranchFailure, InterruptedException
|
||||
{
|
||||
job.handlePausing();
|
||||
this.job.handlePausing();
|
||||
|
||||
if ( fullSimulation )
|
||||
if ( this.fullSimulation )
|
||||
{
|
||||
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
|
||||
for (Entry<CraftingTreeNode, Long> entry : nodes.entrySet())
|
||||
for (Entry<CraftingTreeNode, Long> entry : this.nodes.entrySet())
|
||||
{
|
||||
IAEItemStack item = entry.getKey().getStack( entry.getValue() );
|
||||
IAEItemStack stack = entry.getKey().request( inv, item.getStackSize(), src );
|
||||
@@ -210,7 +210,7 @@ public class CraftingTreeProcess
|
||||
ic.setInventorySlotContents( entry.getKey().slot, stack.getItemStack() );
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) world ), details.getOutput( ic, world ), ic );
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.world ), this.details.getOutput( ic, this.world ), ic );
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++)
|
||||
{
|
||||
@@ -220,7 +220,7 @@ public class CraftingTreeProcess
|
||||
IAEItemStack o = AEApi.instance().storage().createItemStack( is );
|
||||
if ( o != null )
|
||||
{
|
||||
bytes++;
|
||||
this.bytes++;
|
||||
inv.injectItems( o, Actionable.MODULATE, src );
|
||||
}
|
||||
}
|
||||
@@ -228,18 +228,18 @@ public class CraftingTreeProcess
|
||||
else
|
||||
{
|
||||
// request and remove inputs...
|
||||
for (Entry<CraftingTreeNode, Long> entry : nodes.entrySet())
|
||||
for (Entry<CraftingTreeNode, Long> entry : this.nodes.entrySet())
|
||||
{
|
||||
IAEItemStack item = entry.getKey().getStack( entry.getValue() );
|
||||
IAEItemStack stack = entry.getKey().request( inv, item.getStackSize() * i, src );
|
||||
|
||||
if ( containerItems )
|
||||
if ( this.containerItems )
|
||||
{
|
||||
ItemStack is = Platform.getContainerItem( stack.getItemStack() );
|
||||
IAEItemStack o = AEApi.instance().storage().createItemStack( is );
|
||||
if ( o != null )
|
||||
{
|
||||
bytes++;
|
||||
this.bytes++;
|
||||
inv.injectItems( o, Actionable.MODULATE, src );
|
||||
}
|
||||
}
|
||||
@@ -249,52 +249,52 @@ public class CraftingTreeProcess
|
||||
// assume its possible.
|
||||
|
||||
// add crafting results..
|
||||
for (IAEItemStack out : details.getCondensedOutputs())
|
||||
for (IAEItemStack out : this.details.getCondensedOutputs())
|
||||
{
|
||||
IAEItemStack o = out.copy();
|
||||
o.setStackSize( o.getStackSize() * i );
|
||||
inv.injectItems( o, Actionable.MODULATE, src );
|
||||
}
|
||||
|
||||
crafts += i;
|
||||
this.crafts += i;
|
||||
}
|
||||
|
||||
public void dive(CraftingJob job)
|
||||
{
|
||||
job.addTask( getAmountCrafted( parent.getStack( 1 ) ), crafts, details, depth );
|
||||
for (CraftingTreeNode pro : nodes.keySet())
|
||||
job.addTask( this.getAmountCrafted( this.parent.getStack( 1 ) ), this.crafts, this.details, this.depth );
|
||||
for (CraftingTreeNode pro : this.nodes.keySet())
|
||||
pro.dive( job );
|
||||
|
||||
job.addBytes( 8 + crafts + bytes );
|
||||
job.addBytes( 8 + this.crafts + this.bytes );
|
||||
}
|
||||
|
||||
public void setSimulate()
|
||||
{
|
||||
crafts = 0;
|
||||
bytes = 0;
|
||||
this.crafts = 0;
|
||||
this.bytes = 0;
|
||||
|
||||
for (CraftingTreeNode pro : nodes.keySet())
|
||||
for (CraftingTreeNode pro : this.nodes.keySet())
|
||||
pro.setSimulate();
|
||||
}
|
||||
|
||||
public void setJob(MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src) throws CraftBranchFailure
|
||||
{
|
||||
craftingCPUCluster.addCrafting( details, crafts );
|
||||
craftingCPUCluster.addCrafting( this.details, this.crafts );
|
||||
|
||||
for (CraftingTreeNode pro : nodes.keySet())
|
||||
for (CraftingTreeNode pro : this.nodes.keySet())
|
||||
pro.setJob( storage, craftingCPUCluster, src );
|
||||
}
|
||||
|
||||
public void getPlan(IItemList<IAEItemStack> plan)
|
||||
{
|
||||
for (IAEItemStack i : details.getOutputs())
|
||||
for (IAEItemStack i : this.details.getOutputs())
|
||||
{
|
||||
i = i.copy();
|
||||
i.setCountRequestable( i.getStackSize() * crafts );
|
||||
i.setCountRequestable( i.getStackSize() * this.crafts );
|
||||
plan.addRequestable( i );
|
||||
}
|
||||
|
||||
for (CraftingTreeNode pro : nodes.keySet())
|
||||
for (CraftingTreeNode pro : this.nodes.keySet())
|
||||
pro.getPlan( plan );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,27 +41,27 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
IAEStack myLast;
|
||||
|
||||
public ItemWatcherIterator(CraftingWatcher parent, Iterator<IAEStack> i) {
|
||||
watcher = parent;
|
||||
interestIterator = i;
|
||||
this.watcher = parent;
|
||||
this.interestIterator = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return interestIterator.hasNext();
|
||||
return this.interestIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack next()
|
||||
{
|
||||
return myLast = interestIterator.next();
|
||||
return this.myLast = this.interestIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
gsc.interestManager.remove( myLast, watcher );
|
||||
interestIterator.remove();
|
||||
CraftingWatcher.this.gsc.interestManager.remove( this.myLast, this.watcher );
|
||||
this.interestIterator.remove();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,22 +71,22 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
final HashSet<IAEStack> myInterests = new HashSet<IAEStack>();
|
||||
|
||||
public CraftingWatcher(CraftingGridCache cache, ICraftingWatcherHost host) {
|
||||
gsc = cache;
|
||||
this.gsc = cache;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public ICraftingWatcherHost getHost()
|
||||
{
|
||||
return host;
|
||||
return this.host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(IAEStack e)
|
||||
{
|
||||
if ( myInterests.contains( e ) )
|
||||
if ( this.myInterests.contains( e ) )
|
||||
return false;
|
||||
|
||||
return myInterests.add( e.copy() ) && gsc.interestManager.put( e, this );
|
||||
return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +95,7 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
boolean didChange = false;
|
||||
|
||||
for (IAEStack o : c)
|
||||
didChange = add( o ) || didChange;
|
||||
didChange = this.add( o ) || didChange;
|
||||
|
||||
return didChange;
|
||||
}
|
||||
@@ -103,10 +103,10 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
Iterator<IAEStack> i = myInterests.iterator();
|
||||
Iterator<IAEStack> i = this.myInterests.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
gsc.interestManager.remove( i.next(), this );
|
||||
this.gsc.interestManager.remove( i.next(), this );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
@@ -114,31 +114,31 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return myInterests.contains( o );
|
||||
return this.myInterests.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return myInterests.containsAll( c );
|
||||
return this.myInterests.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return myInterests.isEmpty();
|
||||
return this.myInterests.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEStack> iterator()
|
||||
{
|
||||
return new ItemWatcherIterator( this, myInterests.iterator() );
|
||||
return new ItemWatcherIterator( this, this.myInterests.iterator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
return myInterests.remove( o ) && gsc.interestManager.remove( (IAEStack) o, this );
|
||||
return this.myInterests.remove( o ) && this.gsc.interestManager.remove( (IAEStack) o, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,7 +146,7 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
{
|
||||
boolean didSomething = false;
|
||||
for (Object o : c)
|
||||
didSomething = remove( o ) || didSomething;
|
||||
didSomething = this.remove( o ) || didSomething;
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
boolean changed = false;
|
||||
Iterator<IAEStack> i = iterator();
|
||||
Iterator<IAEStack> i = this.iterator();
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
@@ -171,19 +171,19 @@ public class CraftingWatcher implements ICraftingWatcher
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return myInterests.size();
|
||||
return this.myInterests.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return myInterests.toArray();
|
||||
return this.myInterests.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return myInterests.toArray( a );
|
||||
return this.myInterests.toArray( a );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,15 +46,15 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
|
||||
public MECraftingInventory()
|
||||
{
|
||||
localCache = AEApi.instance().storage().createItemList();
|
||||
extractedCache = null;
|
||||
injectedCache = null;
|
||||
missingCache = null;
|
||||
this.localCache = AEApi.instance().storage().createItemList();
|
||||
this.extractedCache = null;
|
||||
this.injectedCache = null;
|
||||
this.missingCache = null;
|
||||
this.logExtracted = false;
|
||||
this.logInjections = false;
|
||||
this.logMissing = false;
|
||||
target = null;
|
||||
par = null;
|
||||
this.target = null;
|
||||
this.par = null;
|
||||
}
|
||||
|
||||
public MECraftingInventory(MECraftingInventory parent)
|
||||
@@ -64,24 +64,24 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
this.logInjections = parent.logInjections;
|
||||
this.logMissing = parent.logMissing;
|
||||
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
if ( this.logMissing )
|
||||
this.missingCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
missingCache = null;
|
||||
this.missingCache = null;
|
||||
|
||||
if ( logExtracted )
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
if ( this.logExtracted )
|
||||
this.extractedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
extractedCache = null;
|
||||
this.extractedCache = null;
|
||||
|
||||
if ( logInjections )
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
if ( this.logInjections )
|
||||
this.injectedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
injectedCache = null;
|
||||
this.injectedCache = null;
|
||||
|
||||
localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
this.localCache = this.target.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
|
||||
par = parent;
|
||||
this.par = parent;
|
||||
}
|
||||
|
||||
public MECraftingInventory(IMEMonitor<IAEItemStack> target, BaseActionSource src, boolean logExtracted, boolean logInjections, boolean logMissing)
|
||||
@@ -92,25 +92,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
this.logMissing = logMissing;
|
||||
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
this.missingCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
missingCache = null;
|
||||
this.missingCache = null;
|
||||
|
||||
if ( logExtracted )
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
this.extractedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
extractedCache = null;
|
||||
this.extractedCache = null;
|
||||
|
||||
if ( logInjections )
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
this.injectedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
injectedCache = null;
|
||||
this.injectedCache = null;
|
||||
|
||||
localCache = AEApi.instance().storage().createItemList();
|
||||
this.localCache = AEApi.instance().storage().createItemList();
|
||||
for (IAEItemStack is : target.getStorageList())
|
||||
localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) );
|
||||
this.localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) );
|
||||
|
||||
par = null;
|
||||
this.par = null;
|
||||
}
|
||||
|
||||
public MECraftingInventory(IMEInventory<IAEItemStack> target, boolean logExtracted, boolean logInjections, boolean logMissing)
|
||||
@@ -121,22 +121,22 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
this.logMissing = logMissing;
|
||||
|
||||
if ( logMissing )
|
||||
missingCache = AEApi.instance().storage().createItemList();
|
||||
this.missingCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
missingCache = null;
|
||||
this.missingCache = null;
|
||||
|
||||
if ( logExtracted )
|
||||
extractedCache = AEApi.instance().storage().createItemList();
|
||||
this.extractedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
extractedCache = null;
|
||||
this.extractedCache = null;
|
||||
|
||||
if ( logInjections )
|
||||
injectedCache = AEApi.instance().storage().createItemList();
|
||||
this.injectedCache = AEApi.instance().storage().createItemList();
|
||||
else
|
||||
injectedCache = null;
|
||||
this.injectedCache = null;
|
||||
|
||||
localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
par = null;
|
||||
this.localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
this.par = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,9 +147,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
if ( logInjections )
|
||||
injectedCache.add( input );
|
||||
localCache.add( input );
|
||||
if ( this.logInjections )
|
||||
this.injectedCache.add( input );
|
||||
this.localCache.add( input );
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -161,7 +161,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
if ( request == null )
|
||||
return null;
|
||||
|
||||
IAEItemStack list = localCache.findPrecise( request );
|
||||
IAEItemStack list = this.localCache.findPrecise( request );
|
||||
if ( list == null || list.getStackSize() == 0 )
|
||||
return null;
|
||||
|
||||
@@ -170,8 +170,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
list.decStackSize( request.getStackSize() );
|
||||
if ( logExtracted )
|
||||
extractedCache.add( request );
|
||||
if ( this.logExtracted )
|
||||
this.extractedCache.add( request );
|
||||
}
|
||||
|
||||
return request;
|
||||
@@ -183,8 +183,8 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
if ( mode == Actionable.MODULATE )
|
||||
{
|
||||
list.reset();
|
||||
if ( logExtracted )
|
||||
extractedCache.add( ret );
|
||||
if ( this.logExtracted )
|
||||
this.extractedCache.add( ret );
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -193,7 +193,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
|
||||
{
|
||||
for (IAEItemStack is : localCache)
|
||||
for (IAEItemStack is : this.localCache)
|
||||
out.add( is );
|
||||
|
||||
return out;
|
||||
@@ -201,7 +201,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
|
||||
public IItemList<IAEItemStack> getItemList()
|
||||
{
|
||||
return localCache;
|
||||
return this.localCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,12 +216,12 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();
|
||||
boolean failed = false;
|
||||
|
||||
if ( logInjections )
|
||||
if ( this.logInjections )
|
||||
{
|
||||
for (IAEItemStack inject : injectedCache)
|
||||
for (IAEItemStack inject : this.injectedCache)
|
||||
{
|
||||
IAEItemStack result = null;
|
||||
added.add( result = target.injectItems( inject, Actionable.MODULATE, src ) );
|
||||
added.add( result = this.target.injectItems( inject, Actionable.MODULATE, src ) );
|
||||
|
||||
if ( result != null )
|
||||
{
|
||||
@@ -234,17 +234,17 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
if ( failed )
|
||||
{
|
||||
for (IAEItemStack is : added)
|
||||
target.extractItems( is, Actionable.MODULATE, src );
|
||||
this.target.extractItems( is, Actionable.MODULATE, src );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( logExtracted )
|
||||
if ( this.logExtracted )
|
||||
{
|
||||
for (IAEItemStack extra : extractedCache)
|
||||
for (IAEItemStack extra : this.extractedCache)
|
||||
{
|
||||
IAEItemStack result = null;
|
||||
pulled.add( result = target.extractItems( extra, Actionable.MODULATE, src ) );
|
||||
pulled.add( result = this.target.extractItems( extra, Actionable.MODULATE, src ) );
|
||||
|
||||
if ( result == null || result.getStackSize() != extra.getStackSize() )
|
||||
{
|
||||
@@ -257,18 +257,18 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
if ( failed )
|
||||
{
|
||||
for (IAEItemStack is : added)
|
||||
target.extractItems( is, Actionable.MODULATE, src );
|
||||
this.target.extractItems( is, Actionable.MODULATE, src );
|
||||
|
||||
for (IAEItemStack is : pulled)
|
||||
target.injectItems( is, Actionable.MODULATE, src );
|
||||
this.target.injectItems( is, Actionable.MODULATE, src );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( logMissing && par != null )
|
||||
if ( this.logMissing && this.par != null )
|
||||
{
|
||||
for (IAEItemStack extra : missingCache)
|
||||
par.addMissing( extra );
|
||||
for (IAEItemStack extra : this.missingCache)
|
||||
this.par.addMissing( extra );
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -276,12 +276,12 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
|
||||
public void addMissing(IAEItemStack extra)
|
||||
{
|
||||
missingCache.add( extra );
|
||||
this.missingCache.add( extra );
|
||||
}
|
||||
|
||||
public void ignore(IAEItemStack what)
|
||||
{
|
||||
IAEItemStack list = localCache.findPrecise( what );
|
||||
IAEItemStack list = this.localCache.findPrecise( what );
|
||||
if ( list != null )
|
||||
list.setStackSize( 0 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user