Added Light Detector

This commit is contained in:
AlgorithmX2
2014-07-15 20:26:04 -05:00
parent 9c9598c6fb
commit 862c89e1f0
7 changed files with 134 additions and 11 deletions
+11 -2
View File
@@ -12,6 +12,7 @@ import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.misc.BlockLightDetector;
import appeng.block.misc.BlockSkyCompass;
import appeng.block.networking.BlockWireless;
import appeng.client.render.ItemRenderer;
@@ -63,7 +64,15 @@ public class AEBaseItemBlock extends ItemBlock
if ( blockType.hasBlockTileEntity() )
{
if ( blockType instanceof BlockWireless || blockType instanceof BlockSkyCompass )
if ( blockType instanceof BlockLightDetector )
{
up = ForgeDirection.getOrientation( side );
if ( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
forward = ForgeDirection.SOUTH;
else
forward = ForgeDirection.UP;
}
else if ( blockType instanceof BlockWireless || blockType instanceof BlockSkyCompass )
{
forward = ForgeDirection.getOrientation( side );
if ( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
@@ -123,7 +132,7 @@ public class AEBaseItemBlock extends ItemBlock
if ( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) )
{
if ( blockType.hasBlockTileEntity() )
if ( blockType.hasBlockTileEntity() && !(blockType instanceof BlockLightDetector) )
{
AEBaseTile tile = blockType.getTileEntity( w, x, y, z );
ori = tile;
+48
View File
@@ -0,0 +1,48 @@
package appeng.block.misc;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TileLightDetector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockLightDetector extends BlockQuartzTorch
{
public BlockLightDetector() {
super( BlockLightDetector.class );
setfeature( EnumSet.of( AEFeature.LightDetector ) );
setTileEntiy( TileLightDetector.class );
}
@Override
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ)
{
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
TileLightDetector tld = getTileEntity( world, x, y, z );
if ( tld != null )
tld.updateLight();
}
@Override
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
{
if ( w instanceof World && ((TileLightDetector) getTileEntity( w, x, y, z )).isReady() )
return (int) ((World) w).getBlockLightValue( x, y, z ) - 6;
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
// cancel out lightning
}
}
+10 -7
View File
@@ -31,14 +31,18 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
{
public BlockQuartzTorch() {
super( BlockQuartzTorch.class, Material.circuits );
setfeature( EnumSet.of( AEFeature.DecorativeLights ) );
protected BlockQuartzTorch(Class which) {
super( which, Material.circuits );
setLightOpacity( 0 );
setLightLevel( 0.9375F );
isFullSize = isOpaque = false;
}
public BlockQuartzTorch() {
this( BlockQuartzTorch.class );
setfeature( EnumSet.of( AEFeature.DecorativeLights ) );
setLightLevel( 0.9375F );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@@ -100,9 +104,8 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
{/*
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y +
* 0.15, zOff + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z +
* 0.85 ) );
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
*/
}