use of com.teamresourceful.resourcefulbees.config.Config in project ResourcefulBees by Resourceful-Bees.
the class BeeNestFeature method place.
@Override
public boolean place(@NotNull WorldGenLevel worldIn, @NotNull ChunkGenerator generator, @NotNull Random rand, @NotNull BlockPos pos, @NotNull NoneFeatureConfiguration config) {
if (!Config.GENERATE_BEE_NESTS.get()) {
return false;
}
Biome biome = worldIn.getBiome(pos);
Optional<ResourceKey<Biome>> biomeKey = worldIn.getBiomeName(pos);
Biome.BiomeCategory category = biome.getBiomeCategory();
boolean headsOrTails = rand.nextBoolean();
BlockPos newPos = getYPos(worldIn, rand, category, pos);
if (newPos.getY() == 0) {
return false;
}
Direction direction;
BlockPos finalNewPos = newPos.mutable();
List<Direction> possibleDirections = ALLOWED_DIRECTIONS.stream().filter(dir -> worldIn.isEmptyBlock(finalNewPos.relative(dir, 1))).collect(Collectors.toList());
if (!possibleDirections.isEmpty()) {
direction = possibleDirections.get(rand.nextInt(possibleDirections.size()));
} else {
return false;
}
Block nest;
BlockState platformBlockState = null;
switch(category) {
case THEEND:
nest = ModBlocks.PURPUR_BEE_NEST.get();
break;
case NETHER:
nest = getNetherNest(headsOrTails, biomeKey.orElse(null));
platformBlockState = Blocks.OBSIDIAN.defaultBlockState();
break;
case SAVANNA:
case DESERT:
case MESA:
nest = ModBlocks.ACACIA_BEE_NEST.get();
break;
case JUNGLE:
nest = ModBlocks.JUNGLE_BEE_NEST.get();
break;
case BEACH:
case OCEAN:
nest = ModBlocks.PRISMARINE_BEE_NEST.get();
platformBlockState = isFrozenBiome(biomeKey.orElse(null)) ? Blocks.PACKED_ICE.defaultBlockState() : Blocks.STRIPPED_OAK_WOOD.defaultBlockState();
break;
case ICY:
case TAIGA:
platformBlockState = Blocks.PACKED_ICE.defaultBlockState();
nest = ModBlocks.SPRUCE_BEE_NEST.get();
break;
case MUSHROOM:
nest = selectNest(headsOrTails, ModBlocks.RED_MUSHROOM_BEE_NEST.get(), ModBlocks.BROWN_MUSHROOM_BEE_NEST.get());
break;
case SWAMP:
nest = ModBlocks.OAK_BEE_NEST.get();
platformBlockState = Blocks.STRIPPED_SPRUCE_WOOD.defaultBlockState();
break;
case FOREST:
nest = selectNest(headsOrTails, ModBlocks.BIRCH_BEE_NEST.get(), ModBlocks.DARK_OAK_BEE_NEST.get());
break;
case RIVER:
platformBlockState = isFrozenBiome(biomeKey.orElse(null)) ? Blocks.PACKED_ICE.defaultBlockState() : Blocks.OAK_WOOD.defaultBlockState();
nest = overworldBlocks.next();
break;
default:
platformBlockState = Blocks.OAK_WOOD.defaultBlockState();
nest = overworldBlocks.next();
}
BlockState newState = nest.defaultBlockState().setValue(BeehiveBlock.FACING, direction);
BlockPos belowHive = newPos.offset(0, -1, 0);
if (worldIn.getBlockState(belowHive).getBlock().equals(Blocks.WATER)) {
generateHivePlatform(worldIn, belowHive, platformBlockState, direction, Blocks.WATER);
}
if (category.equals(Biome.BiomeCategory.NETHER) && worldIn.getBlockState(belowHive).getBlock().equals(Blocks.LAVA)) {
generateHivePlatform(worldIn, belowHive, platformBlockState, direction, Blocks.LAVA);
}
worldIn.setBlock(newPos, newState, 1);
setNestBees(newPos, biomeKey.orElse(null), worldIn, rand);
return true;
}
Aggregations