]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/interop/FlowerForestHelper.java
ed1d486dffbf6c5bdc8aa3130788f4f814c13137
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / interop / FlowerForestHelper.java
1 package com.irtimaled.bbor.client.interop;
2
3 import com.irtimaled.bbor.client.config.ConfigManager;
4 import com.irtimaled.bbor.client.config.HexColor;
5 import com.irtimaled.bbor.client.config.Setting;
6 import com.irtimaled.bbor.common.models.Coords;
7 import com.irtimaled.bbor.mixin.access.IPlacedFeature;
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.PlacedFeature;
17 import net.minecraft.world.gen.feature.SimpleBlockFeature;
18 import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig;
19 import net.minecraft.world.gen.feature.VegetationConfiguredFeatures;
20 import net.minecraft.world.gen.stateprovider.BlockStateProvider;
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import java.util.Random;
25
26 public class FlowerForestHelper {
27     private static final Random random = new Random();
28
29     private static final Map<BlockState, Setting<HexColor>> flowerColorMap = new HashMap<>();
30
31     public static final Biome BIOME = BuiltinRegistries.BIOME.get(BiomeKeys.FLOWER_FOREST);
32
33     private static BlockStateProvider blockStateProvider;
34
35     static {
36         flowerColorMap.put(Blocks.DANDELION.getDefaultState(), ConfigManager.colorFlowerForestDandelion);
37         flowerColorMap.put(Blocks.POPPY.getDefaultState(), ConfigManager.colorFlowerForestPoppy);
38         flowerColorMap.put(Blocks.ALLIUM.getDefaultState(), ConfigManager.colorFlowerForestAllium);
39         flowerColorMap.put(Blocks.AZURE_BLUET.getDefaultState(), ConfigManager.colorFlowerForestAzureBluet);
40         flowerColorMap.put(Blocks.RED_TULIP.getDefaultState(), ConfigManager.colorFlowerForestRedTulip);
41         flowerColorMap.put(Blocks.ORANGE_TULIP.getDefaultState(), ConfigManager.colorFlowerForestOrangeTulip);
42         flowerColorMap.put(Blocks.WHITE_TULIP.getDefaultState(), ConfigManager.colorFlowerForestWhiteTulip);
43         flowerColorMap.put(Blocks.PINK_TULIP.getDefaultState(), ConfigManager.colorFlowerForestPinkTulip);
44         flowerColorMap.put(Blocks.OXEYE_DAISY.getDefaultState(), ConfigManager.colorFlowerForestOxeyeDaisy);
45         flowerColorMap.put(Blocks.CORNFLOWER.getDefaultState(), ConfigManager.colorFlowerForestCornflower);
46         flowerColorMap.put(Blocks.LILY_OF_THE_VALLEY.getDefaultState(), ConfigManager.colorFlowerForestLilyOfTheValley);
47         final PlacedFeature placedFeature = VegetationConfiguredFeatures.FLOWER_FLOWER_FOREST.config.feature().get();
48         final ConfiguredFeature<SimpleBlockFeatureConfig, SimpleBlockFeature> configuredFeature = (ConfiguredFeature<SimpleBlockFeatureConfig, SimpleBlockFeature>) ((IPlacedFeature) placedFeature).getFeature().get();
49         blockStateProvider = configuredFeature.getConfig().toPlace();
50     }
51
52     public static Setting<HexColor> getFlowerColorAtPos(Coords coords) {
53         int x = coords.getX();
54         int z = coords.getZ();
55         BlockState blockState = blockStateProvider.getBlockState(random, new BlockPos(x, coords.getY(), z));
56         return flowerColorMap.get(blockState);
57     }
58
59     public static void setSeed(long seed) {
60         random.setSeed(seed);
61     }
62
63     public static boolean canGrowFlower(int x, int y, int z) {
64         return MinecraftClient.getInstance().world.getBlockState(new BlockPos(x, y, z)).getBlock() == Blocks.GRASS_BLOCK;
65     }
66 }