Skip to content

Commit

Permalink
Fixes #2647: Prevent crafting status from crashing due to missing net…
Browse files Browse the repository at this point in the history
…work.
  • Loading branch information
yueh committed Dec 8, 2016
1 parent 6bf52b0 commit 86908b1
Showing 1 changed file with 33 additions and 29 deletions.
Expand Up @@ -31,6 +31,7 @@
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.util.Platform;


public class ContainerCraftingStatus extends ContainerCraftingCPU
Expand All @@ -52,51 +53,54 @@ public ContainerCraftingStatus( final InventoryPlayer ip, final ITerminalHost te
@Override
public void detectAndSendChanges()
{
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();

int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
if( Platform.isServer() && this.getNetwork() != null )
{
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();

int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
{
if( ccr.getCpu() == c )
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
{
found = true;
if( ccr.getCpu() == c )
{
found = true;
}
}
}

final boolean matched = this.cpuMatches( c );
final boolean matched = this.cpuMatches( c );

if( matched )
{
matches++;
}
if( matched )
{
matches++;
}

if( found == !matched )
{
changed = true;
if( found == !matched )
{
changed = true;
}
}
}

if( changed || this.cpus.size() != matches )
{
this.cpus.clear();
for( final ICraftingCPU c : cpuSet )
if( changed || this.cpus.size() != matches )
{
if( this.cpuMatches( c ) )
this.cpus.clear();
for( final ICraftingCPU c : cpuSet )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
if( this.cpuMatches( c ) )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
}

this.sendCPUs();
}

this.sendCPUs();
this.noCPU = this.cpus.isEmpty();
}

this.noCPU = this.cpus.isEmpty();

super.detectAndSendChanges();
}

Expand Down

0 comments on commit 86908b1

Please sign in to comment.