Fixes #2647: Prevent crafting status from crashing due to missing network.
This commit is contained in:
@@ -31,6 +31,7 @@ import appeng.api.networking.crafting.ICraftingCPU;
|
|||||||
import appeng.api.networking.crafting.ICraftingGrid;
|
import appeng.api.networking.crafting.ICraftingGrid;
|
||||||
import appeng.api.storage.ITerminalHost;
|
import appeng.api.storage.ITerminalHost;
|
||||||
import appeng.container.guisync.GuiSync;
|
import appeng.container.guisync.GuiSync;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||||
@@ -52,50 +53,53 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
|
|||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
|
if( Platform.isServer() && this.getNetwork() != null )
|
||||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
|
||||||
|
|
||||||
int matches = 0;
|
|
||||||
boolean changed = false;
|
|
||||||
for( final ICraftingCPU c : cpuSet )
|
|
||||||
{
|
{
|
||||||
boolean found = false;
|
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
|
||||||
for( final CraftingCPURecord ccr : this.cpus )
|
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||||
{
|
|
||||||
if( ccr.getCpu() == c )
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean matched = this.cpuMatches( c );
|
int matches = 0;
|
||||||
|
boolean changed = false;
|
||||||
if( matched )
|
|
||||||
{
|
|
||||||
matches++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( found == !matched )
|
|
||||||
{
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( changed || this.cpus.size() != matches )
|
|
||||||
{
|
|
||||||
this.cpus.clear();
|
|
||||||
for( final ICraftingCPU c : cpuSet )
|
for( final ICraftingCPU c : cpuSet )
|
||||||
{
|
{
|
||||||
if( this.cpuMatches( c ) )
|
boolean found = false;
|
||||||
|
for( final CraftingCPURecord ccr : this.cpus )
|
||||||
{
|
{
|
||||||
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
if( ccr.getCpu() == c )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean matched = this.cpuMatches( c );
|
||||||
|
|
||||||
|
if( matched )
|
||||||
|
{
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( found == !matched )
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendCPUs();
|
if( changed || this.cpus.size() != matches )
|
||||||
}
|
{
|
||||||
|
this.cpus.clear();
|
||||||
|
for( final ICraftingCPU c : cpuSet )
|
||||||
|
{
|
||||||
|
if( this.cpuMatches( c ) )
|
||||||
|
{
|
||||||
|
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.noCPU = this.cpus.isEmpty();
|
this.sendCPUs();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.noCPU = this.cpus.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
super.detectAndSendChanges();
|
super.detectAndSendChanges();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user