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.translucent = false;
|
||||
this.fullBlock = false;
|
||||
this.lightValue = active ? 13 : 0;
|
||||
URegistry.setIdentifiers( this , "tech" , "base" , "alloy_furnace" , active ? "active" : "inactive" );
|
||||
}
|
||||
|
||||
|
@ -146,49 +147,66 @@ public class TBAlloyFurnaceBlock
|
|||
public void randomDisplayTick( final IBlockState stateIn , final World worldIn , final BlockPos pos ,
|
||||
final Random rand )
|
||||
{
|
||||
// XXX stolen from Blocks.FURNACE, will need adjustments (e.g. positions)
|
||||
if ( this.active ) {
|
||||
final EnumFacing enumfacing = stateIn.getValue( TBAlloyFurnaceBlock.FACING );
|
||||
final double d0 = pos.getX( ) + 0.5D;
|
||||
final double d1 = pos.getY( ) + rand.nextDouble( ) * 6.0D / 16.0D;
|
||||
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 );
|
||||
if ( rand.nextDouble( ) < .1 ) {
|
||||
worldIn.playSound( pos.getX( ) + .5 , pos.getY( ) , pos.getZ( ) + .5 ,
|
||||
SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE , SoundCategory.BLOCKS , 1.f , 1.f , false );
|
||||
}
|
||||
|
||||
switch ( enumfacing ) {
|
||||
if ( rand.nextDouble( ) < .5 ) {
|
||||
spawnFrontParticles( stateIn , worldIn , pos , rand );
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < 4 ; i++ ) {
|
||||
this.spawnTopParticles( stateIn , worldIn , pos , rand );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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:
|
||||
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 ] );
|
||||
spawnX = cx - frontOffset;
|
||||
spawnZ = cz + pSide;
|
||||
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 ] );
|
||||
spawnX = cx + frontOffset;
|
||||
spawnZ = cz + pSide;
|
||||
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 ] );
|
||||
spawnX = cx + pSide;
|
||||
spawnZ = cz - frontOffset;
|
||||
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 ] );
|
||||
spawnX = cx + pSide;
|
||||
spawnZ = cz + frontOffset;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , spawnX , spawnY , spawnZ , 0. , 0. , 0. );
|
||||
worldIn.spawnParticle( EnumParticleTypes.FLAME , spawnX , spawnY , spawnZ , 0. , 0. , 0. );
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue