use of com.almuradev.content.type.block.type.leaf.processor.spread.Spread in project Almura by AlmuraDev.
the class LeafBlockImpl method updateSpreadTick.
private void updateSpreadTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if (worldIn.isRemote) {
return;
}
final IBlockState actualBlock = worldIn.getBlockState(pos);
final Spread spread = this.definition.spread;
if (spread == null) {
return;
}
if (actualBlock.getBlock() != this) {
return;
}
final Biome biome = worldIn.getBiome(pos);
final DoubleRange chanceRoll = spread.getOrLoadChanceRangeForBiome(biome);
if (chanceRoll == null) {
return;
}
if (!(rand.nextDouble() <= (chanceRoll.random(rand) / 100))) {
return;
}
for (final EnumFacing facing : EnumFacing.values()) {
final BlockPos offset = pos.offset(facing);
final IBlockState offsetBlock = worldIn.getBlockState(offset);
if (offsetBlock.getBlock() == Blocks.AIR) {
worldIn.setBlockState(offset, spread.getBlock().get());
worldIn.playEvent(2005, pos, 0);
break;
}
}
}
Aggregations