use of com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule in project minecolonies by ldtteam.
the class BuildingLumberjack method bonemealFungi.
/**
* Returns early if no worker is assigned Iterates over the nether tree position list If position is a fungus, grows it depending on worker's level If the block has changed,
* removes the position from the list and returns early If the position is not a fungus, removes the position from the list
*/
private void bonemealFungi() {
final WorkerBuildingModule module = getFirstModuleOccurance(WorkerBuildingModule.class);
final ICitizenData data = getFirstModuleOccurance(WorkerBuildingModule.class).getFirstCitizen();
if (data == null) {
return;
}
final int modifier = Math.max(0, Math.min(FUNGI_MODIFIER, 100));
for (Iterator<BlockPos> iterator = netherTrees.iterator(); iterator.hasNext(); ) {
final BlockPos pos = iterator.next();
final World world = colony.getWorld();
if (WorldUtil.isBlockLoaded(world, pos)) {
final BlockState blockState = world.getBlockState(pos);
final Block block = blockState.getBlock();
if (block == Blocks.CRIMSON_FUNGUS || block == Blocks.WARPED_FUNGUS) {
int threshold = modifier + (int) Math.ceil(data.getCitizenSkillHandler().getLevel(module.getPrimarySkill()) * (1 - ((float) modifier / 100)));
final int rand = world.getRandom().nextInt(100);
if (rand < threshold) {
final IGrowable growable = (IGrowable) block;
if (growable.isValidBonemealTarget(world, pos, blockState, world.isClientSide)) {
if (!world.isClientSide) {
if (growable.isBonemealSuccess(world, world.random, pos, blockState)) {
growable.performBonemeal((ServerWorld) world, world.random, pos, blockState);
return;
}
}
}
}
} else {
iterator.remove();
}
}
}
}
Aggregations