Added Crystal Growth Accelerator.

Fixed Missing Textures.
This commit is contained in:
AlgorithmX2 2014-02-22 16:14:43 -06:00
parent 8c3973f809
commit 302a41ac76
19 changed files with 314 additions and 41 deletions

2
api

@ -1 +1 @@
Subproject commit 2fed92eaa8c7dd3434e6c0c20552c6fd2605959c
Subproject commit 6c9e85945d5c88eb590e35c907cf9af6e27e83af

View file

@ -0,0 +1,119 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
import appeng.client.render.effects.LightningEffect;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrientableBlock
{
public BlockQuartzGrowthAccelerator() {
super( BlockQuartzGrowthAccelerator.class, Material.rock );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileQuartzGrowthAccelerator.class );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockQuartzAccelerator.class;
}
@Override
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
return new MetaRotation( w, x, y, z );
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !AEConfig.instance.enableEffects )
return;
TileQuartzGrowthAccelerator tqga = getTileEntity( w, x, y, z );
if ( tqga.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = (double) (r.nextFloat() - 0.5F);
double d1 = (double) (r.nextFloat() - 0.5F);
ForgeDirection up = tqga.getUp();
ForgeDirection forward = tqga.getForward();
ForgeDirection west = Platform.crossProduct( forward, up );
double rx = 0.5 + x;
double ry = 0.5 + y;
double rz = 0.5 + z;
double dx = 0;
double dz = 0;
rx += up.offsetX * d0;
ry += up.offsetY * d0;
rz += up.offsetZ * d0;
switch (r.nextInt( 4 ))
{
case 0:
dx = 0.6;
dz = d1;
if ( !w.getBlock( x + west.offsetX, y + west.offsetY, z + west.offsetZ ).isAir( w, x + west.offsetX, y + west.offsetY, z + west.offsetZ ) )
return;
break;
case 1:
dx = d1;
dz += 0.6;
if ( !w.getBlock( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ).isAir( w, x + forward.offsetX, y + forward.offsetY,
z + forward.offsetZ ) )
return;
break;
case 2:
dx = d1;
dz = -0.6;
if ( !w.getBlock( x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ).isAir( w, x - forward.offsetX, y - forward.offsetY,
z - forward.offsetZ ) )
return;
break;
case 3:
dx = -0.6;
dz = d1;
if ( !w.getBlock( x - west.offsetX, y - west.offsetY, z - west.offsetZ ).isAir( w, x - west.offsetX, y - west.offsetY, z - west.offsetZ ) )
return;
break;
}
rx += dx * west.offsetX;
ry += dx * west.offsetY;
rz += dx * west.offsetZ;
rx += dz * forward.offsetX;
ry += dz * forward.offsetY;
rz += dz * forward.offsetZ;
LightningEffect fx = new LightningEffect( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
}

View file

@ -4,6 +4,7 @@ import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import appeng.block.AEBaseBlock;
@ -35,4 +36,10 @@ public class BlockMatrixFrame extends AEBaseBlock
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
}
}

View file

@ -0,0 +1,38 @@
package appeng.client.render.blocks;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.texture.ExtraTextures;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
public class RenderBlockQuartzAccelerator extends BaseBlockRender
{
public RenderBlockQuartzAccelerator() {
super( false, 20 );
}
@Override
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
{
TileEntity te = world.getTileEntity( x, y, z );
if ( te instanceof TileQuartzGrowthAccelerator )
{
if ( ((TileQuartzGrowthAccelerator) te).hasPower )
{
IIcon top_Bottom = ExtraTextures.BlockQuartzGrowthAcceleratorOn.getIcon();
IIcon side = ExtraTextures.BlockQuartzGrowthAcceleratorSideOn.getIcon();
blk.getRendererInstance().setTemporaryRenderIcons( top_Bottom, top_Bottom, side, side, side, side );
}
}
boolean out = super.renderInWorld( blk, world, x, y, z, renderer );
blk.getRendererInstance().setTemporaryRenderIcon( null );
return out;
}
}

View file

@ -15,8 +15,6 @@ public enum CableBusTextures
LevelEmitterTorchOn("ItemPart.LevelEmitterOn"), BlockWirelessOn("BlockWirelessOn"),
BlockTransPlane("BlockTransPlaneOn"),
BlockP2PTunnel2("ItemPart.P2PTunnel2"), BlockP2PTunnel3("ItemPart.P2PTunnel3"),
// MEWaiting("MEWaiting"),
@ -25,25 +23,19 @@ public enum CableBusTextures
Transparent("Transparent"), PartMonitorSidesStatus("PartMonitorSidesStatus"), PartMonitorSidesStatusLights("PartMonitorSidesStatusLights"),
PartMonitor_Solid("PartMonitor_Solid"), PartMonitor_Colored("PartMonitor_Colored"), PartMonitor_Bright("PartMonitor_Bright"),
PartMonitor_Colored("PartMonitor_Colored"), PartMonitor_Bright("PartMonitor_Bright"),
PartPatternTerm_Bright("PartPatternTerm_Bright"), PartPatternTerm_Colored("PartPatternTerm_Colored"), PartPatternTerm_Dark("PartPatternTerm_Dark"), PartPatternTerm_Solid(
"PartPatternTerm_Solid"),
PartPatternTerm_Bright("PartPatternTerm_Bright"), PartPatternTerm_Colored("PartPatternTerm_Colored"), PartPatternTerm_Dark("PartPatternTerm_Dark"),
PartConvMonitor_Bright("PartConvMonitor_Bright"), PartConvMonitor_Colored("PartConvMonitor_Colored"), PartConvMonitor_Dark("PartConvMonitor_Dark"), PartConvMonitor_Solid(
"PartConvMonitor_Solid"),
PartConvMonitor_Bright("PartConvMonitor_Bright"), PartConvMonitor_Colored("PartConvMonitor_Colored"), PartConvMonitor_Dark("PartConvMonitor_Dark"), PartCraftingMonitor_Bright(
"PartCraftingMonitor_Bright"), PartCraftingMonitor_Colored("PartCraftingMonitor_Colored"), PartCraftingMonitor_Dark("PartCraftingMonitor_Dark"),
PartCraftingMonitor_Bright("PartCraftingMonitor_Bright"), PartCraftingMonitor_Colored("PartCraftingMonitor_Colored"), PartCraftingMonitor_Dark(
"PartCraftingMonitor_Dark"), PartCraftingMonitor_Solid("PartCraftingMonitor_Solid"),
PartCraftingTerm_Bright("PartCraftingTerm_Bright"), PartCraftingTerm_Colored("PartCraftingTerm_Colored"), PartCraftingTerm_Dark("PartCraftingTerm_Dark"), PartCraftingTerm_Solid(
"PartCraftingTerm_Solid"),
PartCraftingTerm_Bright("PartCraftingTerm_Bright"), PartCraftingTerm_Colored("PartCraftingTerm_Colored"), PartCraftingTerm_Dark("PartCraftingTerm_Dark"), //
PartStorageMonitor_Bright("PartStorageMonitor_Bright"), PartStorageMonitor_Colored("PartStorageMonitor_Colored"), PartStorageMonitor_Dark(
"PartStorageMonitor_Dark"), PartStorageMonitor_Solid("PartStorageMonitor_Solid"),
"PartStorageMonitor_Dark"),
PartTerminal_Bright("PartTerminal_Bright"), PartTerminal_Colored("PartTerminal_Colored"), PartTerminal_Dark("PartTerminal_Dark"), PartTerminal_Solid(
"PartTerminal_Solid"),
PartTerminal_Bright("PartTerminal_Bright"), PartTerminal_Colored("PartTerminal_Colored"), PartTerminal_Dark("PartTerminal_Dark"),
MECable_Green("MECable_Green"), MECable_Grey("MECable_Grey"), MECable_LightBlue("MECable_LightBlue"), MECable_LightGrey("MECable_LightGrey"), MECable_Lime(
"MECable_Lime"), MECable_Magenta("MECable_Magenta"), MECable_Orange("MECable_Orange"), MECable_Pink("MECable_Pink"), MECable_Purple(

View file

@ -22,12 +22,8 @@ public enum ExtraTextures
BlockChargerInside("BlockChargerInside"),
BlockContainmentWallMerged("BlockContainmentWallMerged"), BlockHeatVentMerged("BlockHeatVentMerged"),
MEStorageCellTextures("MEStorageCellTextures"), White("White"),
// BlockInterfaceAlternate("BlockInterfaceAlternate"), BlockInterfaceAlternateArrow("BlockInterfaceAlternateArrow"),
BlockMatterCannonParticle("BlockMatterCannonParticle"), BlockEnergyParticle("BlockEnergyParticle"),
GlassFrame("BlockQuartzGlassFrame"),
@ -50,7 +46,9 @@ public enum ExtraTextures
BlockSpatialPylonE("BlockSpatialPylon_end"), BlockSpatialPylonE_dim("BlockSpatialPylon_end_dim"), BlockSpatialPylonE_red("BlockSpatialPylon_end_red"),
BlockMESecurityOn("BlockMESecurityOn");
BlockMESecurityOn("BlockMESecurityOn"),
BlockQuartzGrowthAcceleratorOn("BlockQuartzGrowthAcceleratorOn"), BlockQuartzGrowthAcceleratorSideOn("BlockQuartzGrowthAcceleratorSideOn");
final private String name;
public IIcon IIcon;

View file

@ -33,6 +33,7 @@ import appeng.block.misc.BlockCellWorkbench;
import appeng.block.misc.BlockCharger;
import appeng.block.misc.BlockCondenser;
import appeng.block.misc.BlockInterface;
import appeng.block.misc.BlockQuartzGrowthAccelerator;
import appeng.block.misc.BlockQuartzTorch;
import appeng.block.misc.BlockSecurity;
import appeng.block.misc.BlockTinyTNT;
@ -150,11 +151,11 @@ public class Registration
public void PreInit(FMLPreInitializationEvent event)
{
IRecipeHandlerRegistry recipeRegistery = AEApi.instance().registries().recipes();
recipeRegistery.addNewCraftHandler("grind", Grind.class);
recipeRegistery.addNewCraftHandler("shaped", Shaped.class);
recipeRegistery.addNewCraftHandler("shapeless", Shapeless.class);
recipeRegistery.addNewCraftHandler("smelt", Smelt.class);
recipeRegistery.addNewCraftHandler("pureify", Pureify.class);
recipeRegistery.addNewCraftHandler( "grind", Grind.class );
recipeRegistery.addNewCraftHandler( "shaped", Shaped.class );
recipeRegistery.addNewCraftHandler( "shapeless", Shapeless.class );
recipeRegistery.addNewCraftHandler( "smelt", Smelt.class );
recipeRegistery.addNewCraftHandler( "pureify", Pureify.class );
RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" );
RecipeSorter.register( "AE2-Shapeless", ShapelessRecipe.class, Category.SHAPELESS, "" );
@ -243,6 +244,7 @@ public class Registration
blocks.blockQuartzChiseled = addFeature( BlockQuartzChiseled.class );
blocks.blockQuartzTorch = addFeature( BlockQuartzTorch.class );
blocks.blockCharger = addFeature( BlockCharger.class );
blocks.blockQuartzGrowthAccelerator = addFeature( BlockQuartzGrowthAccelerator.class );
blocks.blockGrindStone = addFeature( BlockGrinder.class );
blocks.blockCrankHandle = addFeature( BlockCrank.class );

View file

@ -4,6 +4,7 @@ import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
@ -27,4 +28,11 @@ public class BlockChunkloader extends AEBaseBlock implements LoadingCallback
{
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
return;
}
}

View file

@ -3,6 +3,7 @@ package appeng.debug;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
@ -15,4 +16,10 @@ public class BlockItemGen extends AEBaseBlock
setTileEntiy( TileItemGen.class );
}
@Override
public void registerBlockIcons(IIconRegister iconRegistry)
{
return;
}
}

View file

@ -26,7 +26,7 @@ public class PartConversionMonitor extends PartStorageMonitor
frontBright = CableBusTextures.PartConvMonitor_Bright;
frontColored = CableBusTextures.PartConvMonitor_Colored;
frontDark = CableBusTextures.PartConvMonitor_Dark;
frontSolid = CableBusTextures.PartConvMonitor_Solid;
// frontSolid = CableBusTextures.PartConvMonitor_Solid;
}
@Override

View file

@ -11,7 +11,7 @@ public class PartCraftingMonitor extends PartMonitor
frontBright = CableBusTextures.PartCraftingMonitor_Bright;
frontColored = CableBusTextures.PartCraftingMonitor_Colored;
frontDark = CableBusTextures.PartCraftingMonitor_Dark;
frontSolid = CableBusTextures.PartCraftingMonitor_Solid;
// frontSolid = CableBusTextures.PartCraftingMonitor_Solid;
}
}

View file

@ -28,7 +28,7 @@ public class PartCraftingTerminal extends PartTerminal implements IAEAppEngInven
frontBright = CableBusTextures.PartCraftingTerm_Bright;
frontColored = CableBusTextures.PartCraftingTerm_Colored;
frontDark = CableBusTextures.PartCraftingTerm_Dark;
frontSolid = CableBusTextures.PartCraftingTerm_Solid;
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
}
public GuiBridge getGui()

View file

@ -25,7 +25,7 @@ public class PartDarkMonitor extends PartMonitor
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
rh.setInvColor( getColor().mediumVariant );
@ -40,7 +40,7 @@ public class PartDarkMonitor extends PartMonitor
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );

View file

@ -8,6 +8,7 @@ import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.implementations.parts.IPartMonitor;
import appeng.api.networking.GridFlags;
import appeng.api.networking.events.MENetworkBootingStatusChange;
@ -22,10 +23,10 @@ import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PartMonitor extends AEBasePart implements IPartMonitor
public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChannelState
{
CableBusTextures frontSolid = CableBusTextures.PartMonitor_Solid;
// CableBusTextures frontSolid = CableBusTextures.PartMonitor_Solid;
CableBusTextures frontDark = CableBusTextures.PartMonitor_Colored;
CableBusTextures frontBright = CableBusTextures.PartMonitor_Bright;
CableBusTextures frontColored = CableBusTextures.PartMonitor_Colored;
@ -129,7 +130,7 @@ public class PartMonitor extends AEBasePart implements IPartMonitor
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
rh.setInvColor( getColor().whiteVariant );
@ -150,7 +151,7 @@ public class PartMonitor extends AEBasePart implements IPartMonitor
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
@ -173,7 +174,7 @@ public class PartMonitor extends AEBasePart implements IPartMonitor
if ( notLightSource )
{
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(), frontSolid.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon() );
}
@ -218,4 +219,13 @@ public class PartMonitor extends AEBasePart implements IPartMonitor
bch.addBox( 4, 4, 13, 12, 12, 14 );
}
@Override
public boolean isActive()
{
if ( notLightSource )
return ((clientFlags & (CHANNEL_FLAG | POWERED_FLAG)) == (CHANNEL_FLAG | POWERED_FLAG));
else
return isPowered();
}
}

View file

@ -11,7 +11,7 @@ public class PartPatternTerminal extends PartMonitor
frontBright = CableBusTextures.PartPatternTerm_Bright;
frontColored = CableBusTextures.PartPatternTerm_Colored;
frontDark = CableBusTextures.PartPatternTerm_Dark;
frontSolid = CableBusTextures.PartPatternTerm_Solid;
// frontSolid = CableBusTextures.PartPatternTerm_Solid;
}
}

View file

@ -25,7 +25,7 @@ public class PartSemiDarkMonitor extends PartMonitor
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
int light = getColor().whiteVariant;
@ -43,7 +43,7 @@ public class PartSemiDarkMonitor extends PartMonitor
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
frontSolid.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );

View file

@ -158,7 +158,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
frontBright = CableBusTextures.PartStorageMonitor_Bright;
frontColored = CableBusTextures.PartStorageMonitor_Colored;
frontDark = CableBusTextures.PartStorageMonitor_Dark;
frontSolid = CableBusTextures.PartStorageMonitor_Solid;
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
}
@Override

View file

@ -51,7 +51,7 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM
frontBright = CableBusTextures.PartTerminal_Bright;
frontColored = CableBusTextures.PartTerminal_Colored;
frontDark = CableBusTextures.PartTerminal_Dark;
frontSolid = CableBusTextures.PartTerminal_Solid;
// frontSolid = CableBusTextures.PartTerminal_Solid;
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );

View file

@ -0,0 +1,92 @@
package appeng.tile.misc;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
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.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.util.AECableType;
import appeng.me.GridAccessException;
import appeng.tile.events.AETileEventHandler;
import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkTile;
public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPowerChannelState
{
public boolean hasPower = false;
@MENetworkEventSubscribe
public void onPower(MENetworkPowerStatusChange ch)
{
markForUpdate();
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
{
return AECableType.COVERED;
}
private class TileChargerHandler extends AETileEventHandler
{
public TileChargerHandler() {
super( TileEventType.NETWORK );
}
@Override
public boolean readFromStream(ByteBuf data) throws IOException
{
boolean hadPower = hasPower;
hasPower = data.readBoolean();
return hasPower != hadPower;
}
@Override
public void writeToStream(ByteBuf data) throws IOException
{
try
{
data.writeBoolean( gridProxy.getEnergy().isNetworkPowered() );
}
catch (GridAccessException e)
{
data.writeBoolean( false );
}
}
};
public TileQuartzGrowthAccelerator() {
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
gridProxy.setFlags( GridFlags.CANNOT_CARRY );
gridProxy.setIdlePowerUsage( 2 );
addNewHandler( new TileChargerHandler() );
}
@Override
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
{
super.setOrientation( inForward, inUp );
gridProxy.setValidSides( EnumSet.of( getUp(), getUp().getOpposite() ) );
}
@Override
public boolean isPowered()
{
return hasPower;
}
@Override
public boolean isActive()
{
return hasPower;
}
}