Added light detector item and block model.

This commit is contained in:
Sebastian Hartte 2016-08-27 18:45:25 +02:00
parent 81984b3ad7
commit 77cb3d8b92
4 changed files with 106 additions and 1 deletions

View file

@ -25,26 +25,41 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.ICustomCollision;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileLightDetector;
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision
{
// Cannot use the vanilla FACING property here because it excludes facing DOWN
public static final PropertyDirection FACING = PropertyDirection.create( "facing" );
// Used to alternate between two variants of the fixture on adjacent blocks
public static final PropertyBool ODD = PropertyBool.create( "odd" );
public BlockLightDetector()
{
super( Material.CIRCUITS );
this.setDefaultState( this.blockState.getBaseState().withProperty( FACING, EnumFacing.UP ).withProperty( ODD, false ) );
this.setLightOpacity( 0 );
this.setFullSize( false );
this.setOpaque( false );
@ -52,6 +67,25 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
this.setTileEntity( TileLightDetector.class );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return state.getValue( FACING ).ordinal();
}
@Override
public IBlockState getStateFromMeta( final int meta )
{
EnumFacing facing = EnumFacing.values()[meta];
return getDefaultState().withProperty(FACING, facing);
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { FACING, ODD };
}
@Override
public int getWeakPower( final IBlockState state, final IBlockAccess w, final BlockPos pos, final EnumFacing side )
{
@ -149,4 +183,22 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
return false;
}
@Override
public boolean isFullCube( IBlockState state )
{
return false;
}
@SideOnly( Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
return new MetaRotation( w, pos, FACING );
}
}

View file

@ -343,7 +343,9 @@ public final class ApiBlocks implements IBlocks
.build();
this.molecularAssembler = registry.block( "molecular_assembler", BlockMolecularAssembler::new ).features( AEFeature.MolecularAssembler ).build();
this.lightDetector = registry.block( "light_detector", BlockLightDetector::new ).features( AEFeature.LightDetector ).build();
this.lightDetector = registry.block( "light_detector", BlockLightDetector::new ).features( AEFeature.LightDetector )
.useCustomItemModel()
.build();
this.paint = registry.block( "paint", BlockPaint::new ).features( AEFeature.PaintBalls ).build();
this.skyStoneStairs = makeStairs( "sky_stone_stairs", registry, this.skyStoneBlock() );

View file

@ -0,0 +1,48 @@
{
"variants": {
"facing=down,odd=false": {
"model": "appliedenergistics2:quartz_fixture_standing",
"x": 180
},
"facing=down,odd=true": {
"model": "appliedenergistics2:quartz_fixture_standing_odd",
"x": 180
},
"facing=east,odd=false": {
"model": "appliedenergistics2:quartz_fixture_wall",
"y": 90
},
"facing=east,odd=true": {
"model": "appliedenergistics2:quartz_fixture_wall_odd",
"y": 90
},
"facing=north,odd=false": {
"model": "appliedenergistics2:quartz_fixture_wall"
},
"facing=north,odd=true": {
"model": "appliedenergistics2:quartz_fixture_wall_odd"
},
"facing=south,odd=false": {
"model": "appliedenergistics2:quartz_fixture_wall",
"y": 180
},
"facing=south,odd=true": {
"model": "appliedenergistics2:quartz_fixture_wall_odd",
"y": 180
},
"facing=up,odd=false": {
"model": "appliedenergistics2:quartz_fixture_standing"
},
"facing=up,odd=true": {
"model": "appliedenergistics2:quartz_fixture_standing_odd"
},
"facing=west,odd=false": {
"model": "appliedenergistics2:quartz_fixture_wall",
"y": 270
},
"facing=west,odd=true": {
"model": "appliedenergistics2:quartz_fixture_wall_odd",
"y": 270
}
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "appliedenergistics2:item/quartz_fixture"
}