Alloy furnace - light and particles
This commit is contained in:
parent
bc183d661e
commit
05da2a2147
1 changed files with 56 additions and 38 deletions
|
@ -67,6 +67,7 @@ public class TBAlloyFurnaceBlock
|
||||||
this.lightOpacity = 0;
|
this.lightOpacity = 0;
|
||||||
this.translucent = false;
|
this.translucent = false;
|
||||||
this.fullBlock = false;
|
this.fullBlock = false;
|
||||||
|
this.lightValue = active ? 13 : 0;
|
||||||
URegistry.setIdentifiers( this , "tech" , "base" , "alloy_furnace" , active ? "active" : "inactive" );
|
URegistry.setIdentifiers( this , "tech" , "base" , "alloy_furnace" , active ? "active" : "inactive" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,52 +147,69 @@ public class TBAlloyFurnaceBlock
|
||||||
public void randomDisplayTick( final IBlockState stateIn , final World worldIn , final BlockPos pos ,
|
public void randomDisplayTick( final IBlockState stateIn , final World worldIn , final BlockPos pos ,
|
||||||
final Random rand )
|
final Random rand )
|
||||||
{
|
{
|
||||||
// XXX stolen from Blocks.FURNACE, will need adjustments (e.g. positions)
|
|
||||||
if ( this.active ) {
|
if ( this.active ) {
|
||||||
final EnumFacing enumfacing = stateIn.getValue( TBAlloyFurnaceBlock.FACING );
|
if ( rand.nextDouble( ) < .1 ) {
|
||||||
final double d0 = pos.getX( ) + 0.5D;
|
worldIn.playSound( pos.getX( ) + .5 , pos.getY( ) , pos.getZ( ) + .5 ,
|
||||||
final double d1 = pos.getY( ) + rand.nextDouble( ) * 6.0D / 16.0D;
|
SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE , SoundCategory.BLOCKS , 1.f , 1.f , false );
|
||||||
final double d2 = pos.getZ( ) + 0.5D;
|
|
||||||
final double d3 = 0.52D;
|
|
||||||
final double d4 = rand.nextDouble( ) * 0.6D - 0.3D;
|
|
||||||
|
|
||||||
if ( rand.nextDouble( ) < 0.1D ) {
|
|
||||||
worldIn.playSound( pos.getX( ) + 0.5D , pos.getY( ) , pos.getZ( ) + 0.5D ,
|
|
||||||
SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE , SoundCategory.BLOCKS , 1.0F , 1.0F , false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( enumfacing ) {
|
if ( rand.nextDouble( ) < .5 ) {
|
||||||
case WEST:
|
spawnFrontParticles( stateIn , worldIn , pos , rand );
|
||||||
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 - d3 , d1 , d2 + d4 , 0.0D , 0.0D ,
|
}
|
||||||
0.0D , new int[ 0 ] );
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 - d3 , d1 , d2 + d4 , 0.0D , 0.0D , 0.0D ,
|
for ( int i = 0 ; i < 4 ; i++ ) {
|
||||||
new int[ 0 ] );
|
this.spawnTopParticles( stateIn , worldIn , pos , rand );
|
||||||
break;
|
|
||||||
case EAST:
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 + d3 , d1 , d2 + d4 , 0.0D , 0.0D ,
|
|
||||||
0.0D , new int[ 0 ] );
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 + d3 , d1 , d2 + d4 , 0.0D , 0.0D , 0.0D ,
|
|
||||||
new int[ 0 ] );
|
|
||||||
break;
|
|
||||||
case NORTH:
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 + d4 , d1 , d2 - d3 , 0.0D , 0.0D ,
|
|
||||||
0.0D , new int[ 0 ] );
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 + d4 , d1 , d2 - d3 , 0.0D , 0.0D , 0.0D ,
|
|
||||||
new int[ 0 ] );
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 + d4 , d1 , d2 + d3 , 0.0D , 0.0D ,
|
|
||||||
0.0D , new int[ 0 ] );
|
|
||||||
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 + d4 , d1 , d2 + d3 , 0.0D , 0.0D , 0.0D ,
|
|
||||||
new int[ 0 ] );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void spawnTopParticles( IBlockState stateIn , World worldIn , BlockPos pos , Random rand )
|
||||||
|
{
|
||||||
|
final double spawnX = pos.getX( ) + .5 + ( rand.nextDouble( ) - .5 ) * 4.5 / 16.;
|
||||||
|
final double spawnY = pos.getY( ) + ( 15. + 3. * rand.nextDouble( ) ) / 16.;
|
||||||
|
final double spawnZ = pos.getZ( ) + .5 + ( rand.nextDouble( ) - .5 ) * 4.5 / 16.;
|
||||||
|
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , spawnX , spawnY , spawnZ , 0. , 0. , 0. );
|
||||||
|
worldIn.spawnParticle( EnumParticleTypes.FLAME , spawnX , spawnY , spawnZ , 0. , 0. , 0. );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void spawnFrontParticles( final IBlockState stateIn , final World worldIn , final BlockPos pos ,
|
||||||
|
final Random rand )
|
||||||
|
{
|
||||||
|
final double cx = pos.getX( ) + .5;
|
||||||
|
final double cz = pos.getZ( ) + .5;
|
||||||
|
final double frontOffset = .52;
|
||||||
|
final double spawnY = pos.getY( ) + ( 4. + rand.nextDouble( ) * 4. ) / 16.;
|
||||||
|
final double pSide = ( rand.nextDouble( ) - .5 ) * 10. / 16.;
|
||||||
|
|
||||||
|
double spawnX , spawnZ;
|
||||||
|
switch ( stateIn.getValue( TBAlloyFurnaceBlock.FACING ) ) {
|
||||||
|
case WEST:
|
||||||
|
spawnX = cx - frontOffset;
|
||||||
|
spawnZ = cz + pSide;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
spawnX = cx + frontOffset;
|
||||||
|
spawnZ = cz + pSide;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
spawnX = cx + pSide;
|
||||||
|
spawnZ = cz - frontOffset;
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
spawnX = cx + pSide;
|
||||||
|
spawnZ = cz + frontOffset;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , spawnX , spawnY , spawnZ , 0. , 0. , 0. );
|
||||||
|
worldIn.spawnParticle( EnumParticleTypes.FLAME , spawnX , spawnY , spawnZ , 0. , 0. , 0. );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
|
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
|
||||||
{
|
{
|
||||||
|
|
Reference in a new issue