diff --git a/tile/crafting/TileCraftingTile.java b/tile/crafting/TileCraftingTile.java index 213ba42b7..c2d13af09 100644 --- a/tile/crafting/TileCraftingTile.java +++ b/tile/crafting/TileCraftingTile.java @@ -3,11 +3,12 @@ package appeng.tile.crafting; import java.util.EnumSet; import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.implementations.IPowerChannelState; import appeng.api.networking.GridFlags; +import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.events.MENetworkEventSubscribe; import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.parts.ISimplifiedBundle; -import appeng.me.GridAccessException; import appeng.me.cluster.IAECluster; import appeng.me.cluster.IAEMultiBlock; 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.AENetworkProxyMultiblock; 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; @@ -75,25 +77,27 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock updateMeta(); } + @MENetworkEventSubscribe + public void ChannelChangesd(MENetworkChannelsChanged ev) + { + updateMeta(); + } + public void updateMeta() { + if ( !gridProxy.isReady() ) + return; + boolean formed = clust != null; boolean power = false; - try - { - power = gridProxy.getEnergy().isNetworkPowered(); - } - catch (GridAccessException e) - { - // ;P - } + power = gridProxy.isActive(); int current = worldObj.getBlockMetadata( xCoord, yCoord, zCoord ); int newmeta = (current & 3) | (formed ? 8 : 0) | (power ? 4 : 0); if ( current != newmeta ) { - worldObj.setBlockMetadataWithNotify( xCoord, yCoord, zCoord, newmeta, 3 ); + worldObj.setBlockMetadataWithNotify( xCoord, yCoord, zCoord, newmeta, 2 ); if ( isFormed() ) gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) ); @@ -120,6 +124,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock return true; } + @Override public boolean isPowered() { return (worldObj.getBlockMetadata( xCoord, yCoord, zCoord ) & 4) == 4; @@ -150,4 +155,12 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock return 0; } + @Override + public boolean isActive() + { + if ( Platform.isServer() ) + return gridProxy.isActive(); + return isPowered() && isFormed(); + } + }