2 package com.irtimaled.bbor.client.interop;
4 import com.irtimaled.bbor.client.config.ConfigManager;
5 import com.irtimaled.bbor.client.config.HexColor;
6 import com.irtimaled.bbor.client.config.Setting;
7 import com.irtimaled.bbor.common.models.Coords;
8 import net.minecraft.block.BlockState;
9 import net.minecraft.block.Blocks;
10 import net.minecraft.client.MinecraftClient;
11 import net.minecraft.util.math.BlockPos;
12 import net.minecraft.util.registry.BuiltinRegistries;
13 import net.minecraft.world.biome.Biome;
14 import net.minecraft.world.biome.BiomeKeys;
15 import net.minecraft.world.gen.feature.ConfiguredFeature;
16 import net.minecraft.world.gen.feature.FeatureConfig;
17 import net.minecraft.world.gen.feature.FlowerFeature;
19 import java.util.HashMap;
21 import java.util.Random;
23 public class FlowerForestHelper {
24 private static final Random random = new Random();
26 private static final Map<BlockState, Setting<HexColor>> flowerColorMap = new HashMap<>();
27 private static final FlowerFeature flowersFeature;
28 private static final FeatureConfig flowersConfig;
30 public static final Biome BIOME = BuiltinRegistries.BIOME.get(BiomeKeys.FLOWER_FOREST);
33 flowerColorMap.put(Blocks.DANDELION.getDefaultState(), ConfigManager.colorFlowerForestDandelion);
34 flowerColorMap.put(Blocks.POPPY.getDefaultState(), ConfigManager.colorFlowerForestPoppy);
35 flowerColorMap.put(Blocks.ALLIUM.getDefaultState(), ConfigManager.colorFlowerForestAllium);
36 flowerColorMap.put(Blocks.AZURE_BLUET.getDefaultState(), ConfigManager.colorFlowerForestAzureBluet);
37 flowerColorMap.put(Blocks.RED_TULIP.getDefaultState(), ConfigManager.colorFlowerForestRedTulip);
38 flowerColorMap.put(Blocks.ORANGE_TULIP.getDefaultState(), ConfigManager.colorFlowerForestOrangeTulip);
39 flowerColorMap.put(Blocks.WHITE_TULIP.getDefaultState(), ConfigManager.colorFlowerForestWhiteTulip);
40 flowerColorMap.put(Blocks.PINK_TULIP.getDefaultState(), ConfigManager.colorFlowerForestPinkTulip);
41 flowerColorMap.put(Blocks.OXEYE_DAISY.getDefaultState(), ConfigManager.colorFlowerForestOxeyeDaisy);
42 flowerColorMap.put(Blocks.CORNFLOWER.getDefaultState(), ConfigManager.colorFlowerForestCornflower);
43 flowerColorMap.put(Blocks.LILY_OF_THE_VALLEY.getDefaultState(), ConfigManager.colorFlowerForestLilyOfTheValley);
44 ConfiguredFeature<?, ?> config = BIOME.getGenerationSettings().getFlowerFeatures().get(0);
45 flowersFeature = (FlowerFeature) config.feature;
46 flowersConfig = config.config;
49 public static Setting<HexColor> getFlowerColorAtPos(Coords coords) {
50 int x = coords.getX();
51 int z = coords.getZ();
52 BlockState blockState = flowersFeature.getFlowerState(random, new BlockPos(x, coords.getY(), z), flowersConfig);
53 return flowerColorMap.get(blockState);
56 public static void setSeed(long seed) {
60 public static boolean canGrowFlower(int x, int y, int z) {
61 return MinecraftClient.getInstance().world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.GRASS_BLOCK;