Crafting CPUs now appear offline unless hey have their channel requirement met.
Also their status shows in waila.
This commit is contained in:
@@ -3,11 +3,12 @@ package appeng.tile.crafting;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import appeng.api.implementations.IPowerChannelState;
|
||||||
import appeng.api.networking.GridFlags;
|
import appeng.api.networking.GridFlags;
|
||||||
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||||
import appeng.api.parts.ISimplifiedBundle;
|
import appeng.api.parts.ISimplifiedBundle;
|
||||||
import appeng.me.GridAccessException;
|
|
||||||
import appeng.me.cluster.IAECluster;
|
import appeng.me.cluster.IAECluster;
|
||||||
import appeng.me.cluster.IAEMultiBlock;
|
import appeng.me.cluster.IAEMultiBlock;
|
||||||
import appeng.me.cluster.implementations.CraftingCPUCalculator;
|
import appeng.me.cluster.implementations.CraftingCPUCalculator;
|
||||||
@@ -15,8 +16,9 @@ import appeng.me.cluster.implementations.CraftingCPUCluster;
|
|||||||
import appeng.me.helpers.AENetworkProxy;
|
import appeng.me.helpers.AENetworkProxy;
|
||||||
import appeng.me.helpers.AENetworkProxyMultiblock;
|
import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||||
import appeng.tile.grid.AENetworkTile;
|
import appeng.tile.grid.AENetworkTile;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock
|
public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IPowerChannelState
|
||||||
{
|
{
|
||||||
|
|
||||||
CraftingCPUCluster clust;
|
CraftingCPUCluster clust;
|
||||||
@@ -75,25 +77,27 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock
|
|||||||
updateMeta();
|
updateMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MENetworkEventSubscribe
|
||||||
|
public void ChannelChangesd(MENetworkChannelsChanged ev)
|
||||||
|
{
|
||||||
|
updateMeta();
|
||||||
|
}
|
||||||
|
|
||||||
public void updateMeta()
|
public void updateMeta()
|
||||||
{
|
{
|
||||||
|
if ( !gridProxy.isReady() )
|
||||||
|
return;
|
||||||
|
|
||||||
boolean formed = clust != null;
|
boolean formed = clust != null;
|
||||||
boolean power = false;
|
boolean power = false;
|
||||||
try
|
power = gridProxy.isActive();
|
||||||
{
|
|
||||||
power = gridProxy.getEnergy().isNetworkPowered();
|
|
||||||
}
|
|
||||||
catch (GridAccessException e)
|
|
||||||
{
|
|
||||||
// ;P
|
|
||||||
}
|
|
||||||
|
|
||||||
int current = worldObj.getBlockMetadata( xCoord, yCoord, zCoord );
|
int current = worldObj.getBlockMetadata( xCoord, yCoord, zCoord );
|
||||||
int newmeta = (current & 3) | (formed ? 8 : 0) | (power ? 4 : 0);
|
int newmeta = (current & 3) | (formed ? 8 : 0) | (power ? 4 : 0);
|
||||||
|
|
||||||
if ( current != newmeta )
|
if ( current != newmeta )
|
||||||
{
|
{
|
||||||
worldObj.setBlockMetadataWithNotify( xCoord, yCoord, zCoord, newmeta, 3 );
|
worldObj.setBlockMetadataWithNotify( xCoord, yCoord, zCoord, newmeta, 2 );
|
||||||
|
|
||||||
if ( isFormed() )
|
if ( isFormed() )
|
||||||
gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) );
|
||||||
@@ -120,6 +124,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPowered()
|
public boolean isPowered()
|
||||||
{
|
{
|
||||||
return (worldObj.getBlockMetadata( xCoord, yCoord, zCoord ) & 4) == 4;
|
return (worldObj.getBlockMetadata( xCoord, yCoord, zCoord ) & 4) == 4;
|
||||||
@@ -150,4 +155,12 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive()
|
||||||
|
{
|
||||||
|
if ( Platform.isServer() )
|
||||||
|
return gridProxy.isActive();
|
||||||
|
return isPowered() && isFormed();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user