Added Light Detector
This commit is contained in:
@@ -12,6 +12,7 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
|||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.util.IOrientable;
|
import appeng.api.util.IOrientable;
|
||||||
import appeng.api.util.IOrientableBlock;
|
import appeng.api.util.IOrientableBlock;
|
||||||
|
import appeng.block.misc.BlockLightDetector;
|
||||||
import appeng.block.misc.BlockSkyCompass;
|
import appeng.block.misc.BlockSkyCompass;
|
||||||
import appeng.block.networking.BlockWireless;
|
import appeng.block.networking.BlockWireless;
|
||||||
import appeng.client.render.ItemRenderer;
|
import appeng.client.render.ItemRenderer;
|
||||||
@@ -63,7 +64,15 @@ public class AEBaseItemBlock extends ItemBlock
|
|||||||
|
|
||||||
if ( blockType.hasBlockTileEntity() )
|
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 );
|
forward = ForgeDirection.getOrientation( side );
|
||||||
if ( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
|
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 ( 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 );
|
AEBaseTile tile = blockType.getTileEntity( w, x, y, z );
|
||||||
ori = tile;
|
ori = tile;
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -31,14 +31,18 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||||||
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
|
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
|
||||||
{
|
{
|
||||||
|
|
||||||
public BlockQuartzTorch() {
|
protected BlockQuartzTorch(Class which) {
|
||||||
super( BlockQuartzTorch.class, Material.circuits );
|
super( which, Material.circuits );
|
||||||
setfeature( EnumSet.of( AEFeature.DecorativeLights ) );
|
|
||||||
setLightOpacity( 0 );
|
setLightOpacity( 0 );
|
||||||
setLightLevel( 0.9375F );
|
|
||||||
isFullSize = isOpaque = false;
|
isFullSize = isOpaque = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockQuartzTorch() {
|
||||||
|
this( BlockQuartzTorch.class );
|
||||||
|
setfeature( EnumSet.of( AEFeature.DecorativeLights ) );
|
||||||
|
setLightLevel( 0.9375F );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends BaseBlockRender> getRenderer()
|
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)
|
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 *
|
* 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 +
|
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
|
||||||
* 0.15, zOff + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z +
|
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
|
||||||
* 0.85 ) );
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraft.world.IBlockAccess;
|
|||||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.util.IOrientable;
|
import appeng.api.util.IOrientable;
|
||||||
|
import appeng.api.util.IOrientableBlock;
|
||||||
import appeng.block.AEBaseBlock;
|
import appeng.block.AEBaseBlock;
|
||||||
import appeng.block.misc.BlockQuartzTorch;
|
import appeng.block.misc.BlockQuartzTorch;
|
||||||
import appeng.client.render.BaseBlockRender;
|
import appeng.client.render.BaseBlockRender;
|
||||||
@@ -78,7 +79,7 @@ public class RenderQuartzTorch extends BaseBlockRender
|
|||||||
{
|
{
|
||||||
BlockQuartzTorch blk = (BlockQuartzTorch) block;
|
BlockQuartzTorch blk = (BlockQuartzTorch) block;
|
||||||
|
|
||||||
IOrientable te = getOrientable( block, world, x, y, z );
|
IOrientable te = ((IOrientableBlock) block).getOrientable( world, x, y, z );
|
||||||
|
|
||||||
float Point2 = 6.0f / 16.0f;
|
float Point2 = 6.0f / 16.0f;
|
||||||
float Point3 = 7.0f / 16.0f;
|
float Point3 = 7.0f / 16.0f;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import appeng.block.misc.BlockCharger;
|
|||||||
import appeng.block.misc.BlockCondenser;
|
import appeng.block.misc.BlockCondenser;
|
||||||
import appeng.block.misc.BlockInscriber;
|
import appeng.block.misc.BlockInscriber;
|
||||||
import appeng.block.misc.BlockInterface;
|
import appeng.block.misc.BlockInterface;
|
||||||
|
import appeng.block.misc.BlockLightDetector;
|
||||||
import appeng.block.misc.BlockQuartzGrowthAccelerator;
|
import appeng.block.misc.BlockQuartzGrowthAccelerator;
|
||||||
import appeng.block.misc.BlockQuartzTorch;
|
import appeng.block.misc.BlockQuartzTorch;
|
||||||
import appeng.block.misc.BlockSecurity;
|
import appeng.block.misc.BlockSecurity;
|
||||||
@@ -310,6 +311,7 @@ public class Registration
|
|||||||
blocks.blockQuartzPiller = addFeature( BlockQuartzPillar.class );
|
blocks.blockQuartzPiller = addFeature( BlockQuartzPillar.class );
|
||||||
blocks.blockQuartzChiseled = addFeature( BlockQuartzChiseled.class );
|
blocks.blockQuartzChiseled = addFeature( BlockQuartzChiseled.class );
|
||||||
blocks.blockQuartzTorch = addFeature( BlockQuartzTorch.class );
|
blocks.blockQuartzTorch = addFeature( BlockQuartzTorch.class );
|
||||||
|
blocks.blockLightDetector = addFeature( BlockLightDetector.class );
|
||||||
blocks.blockCharger = addFeature( BlockCharger.class );
|
blocks.blockCharger = addFeature( BlockCharger.class );
|
||||||
blocks.blockQuartzGrowthAccelerator = addFeature( BlockQuartzGrowthAccelerator.class );
|
blocks.blockQuartzGrowthAccelerator = addFeature( BlockQuartzGrowthAccelerator.class );
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public enum AEFeature
|
|||||||
|
|
||||||
enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false),
|
enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false),
|
||||||
|
|
||||||
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting");
|
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting"), LightDetector("Misc");
|
||||||
|
|
||||||
String Category;
|
String Category;
|
||||||
boolean visible = true;
|
boolean visible = true;
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package appeng.tile.misc;
|
||||||
|
|
||||||
|
import appeng.tile.AEBaseTile;
|
||||||
|
import appeng.tile.events.AETileEventHandler;
|
||||||
|
import appeng.tile.events.TileEventType;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
public class TileLightDetector extends AEBaseTile
|
||||||
|
{
|
||||||
|
|
||||||
|
int lastCheck = 30;
|
||||||
|
int lastLight = 0;
|
||||||
|
|
||||||
|
public boolean isReady()
|
||||||
|
{
|
||||||
|
return lastLight > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
class LightDetectorHandler extends AETileEventHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
public LightDetectorHandler() {
|
||||||
|
super( TileEventType.TICK );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Tick()
|
||||||
|
{
|
||||||
|
lastCheck++;
|
||||||
|
if ( lastCheck > 30 )
|
||||||
|
{
|
||||||
|
lastCheck = 0;
|
||||||
|
updateLight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
public TileLightDetector() {
|
||||||
|
addNewHandler( new LightDetectorHandler() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLight()
|
||||||
|
{
|
||||||
|
int val = worldObj.getBlockLightValue( xCoord, yCoord, zCoord );
|
||||||
|
|
||||||
|
if ( lastLight != val )
|
||||||
|
{
|
||||||
|
lastLight = val;
|
||||||
|
Platform.notifyBlocksOfNeighbors( worldObj, xCoord, yCoord, zCoord );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeRotated()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user