Search in sources :

Example 1 with SPTreeConfig

use of org.spoorn.spoornpink.world.gen.feature.config.SPTreeConfig in project SpoornPink by spoorn.

the class SpoornPink method onInitialize.

@Override
public void onInitialize() {
    log.info("Hello from SpoornPink!");
    // Config
    synchronized (this) {
        if (!configInitialized) {
            ModConfig.init();
            configInitialized = true;
        }
    }
    // Pink Blossom blocks and items
    String pink_blossom_name = "pink_blossom";
    ResourceBuilder rb = ResourceFactory.create(MODID, pink_blossom_name, ITEM_GROUP).addBlocks(BlockType.LOG, BlockType.WOOD, BlockType.PLANKS, BlockType.FENCE, BlockType.FENCE_GATE, BlockType.LEAVES, BlockType.BUTTON, BlockType.SLAB, BlockType.PRESSURE_PLATE, BlockType.STAIRS, BlockType.TRAPDOOR, BlockType.DOOR, BlockType.CRAFTING_TABLE, BlockType.STRIPPED_LOG, BlockType.STRIPPED_WOOD, BlockType.CHEST, BlockType.BARREL).addItems(ItemType.LOG, ItemType.WOOD, ItemType.PLANKS, ItemType.FENCE, ItemType.FENCE_GATE, ItemType.LEAVES, ItemType.BUTTON, ItemType.SLAB, ItemType.PRESSURE_PLATE, ItemType.STAIRS, ItemType.TRAPDOOR, ItemType.DOOR, ItemType.CRAFTING_TABLE, ItemType.BOAT, ItemType.STRIPPED_LOG, ItemType.STRIPPED_WOOD, ItemType.CHEST, ItemType.BARREL).addLeavesWithSaplingOverride("dark_pink_blossom", pink_blossom_name).addItem(ItemType.LEAVES, "dark_pink_blossom").addSmallFlower("pink_orchid", StatusEffects.SATURATION, 5).addSmallFlower("pink_orchid2", StatusEffects.SATURATION, 5).addSmallFlower("pink_orchid3", StatusEffects.SATURATION, 5).addSmallFlower("pink_orchid4", StatusEffects.SATURATION, 5).addSmallFlower("pink_orchid5", StatusEffects.SATURATION, 5).addBlock(BlockType.TALL_FLOWER, "pink_lilac").addItem(ItemType.TALL_FLOWER, "pink_lilac");
    Resource resource = RESOURCE_GENERATOR.generate(rb);
    Optional<Block> pinkBlossomLogBlock = resource.getBlock(BlockType.LOG, pink_blossom_name);
    Optional<Block> pinkBlossomLeavesBlock = resource.getBlock(BlockType.LEAVES, pink_blossom_name);
    Optional<Block> darkPinkBlossomLeavesBlock = resource.getBlock(BlockType.LEAVES, "dark_" + pink_blossom_name);
    if (pinkBlossomLeavesBlock.isEmpty() || pinkBlossomLogBlock.isEmpty() || darkPinkBlossomLeavesBlock.isEmpty()) {
        throw new RuntimeException("Could not generate pink_blossom_log or pink_blossom_leaves, or the dark variants");
    }
    // Trees
    SPTreeConfig pinkBlossomTreeConfig = SPTreeConfig.builder().trunkProvider(SimpleBlockStateProvider.of(pinkBlossomLogBlock.get())).leavesProvider(SimpleBlockStateProvider.of(pinkBlossomLeavesBlock.get())).build();
    RegistryEntry<ConfiguredFeature<SPTreeConfig, Feature<SPTreeConfig>>> pinkBlossomTree = SPConfiguredFeatures.registerSPTreeCF("pink_blossom_tree", SPFeatures.PINK_BLOSSOM_TREE, pinkBlossomTreeConfig);
    SPTreeConfig darkPinkBlossomTreeConfig = SPTreeConfig.builder().trunkProvider(SimpleBlockStateProvider.of(pinkBlossomLogBlock.get())).leavesProvider(SimpleBlockStateProvider.of(darkPinkBlossomLeavesBlock.get())).build();
    RegistryEntry<ConfiguredFeature<SPTreeConfig, Feature<SPTreeConfig>>> darkPinkBlossomTree = SPConfiguredFeatures.registerSPTreeCF("dark_pink_blossom_tree", SPFeatures.DARK_PINK_BLOSSOM_TREE, darkPinkBlossomTreeConfig);
    RegistryEntry<ConfiguredFeature<RandomFeatureConfig, Feature<RandomFeatureConfig>>> pinkBlossomTrees = SPConfiguredFeatures.registerMixOfTrees("pink_blossom_trees", pinkBlossomTree, pinkBlossomTree, darkPinkBlossomTree);
    // Saplings
    ResourceBuilder saplingsRB = ResourceFactory.create(MODID, pink_blossom_name, ITEM_GROUP).addSapling(pinkBlossomTrees).addItem(ItemType.SAPLING);
    Resource saplingResource = RESOURCE_GENERATOR.generate(saplingsRB);
    Optional<Block> saplingBlock = saplingResource.getBlock(BlockType.SAPLING, pink_blossom_name);
    if (saplingBlock.isEmpty()) {
        throw new RuntimeException("Could not generate " + pink_blossom_name + " sapling");
    }
    // Configured features
    SPConfiguredFeatures.bootstrap(resource);
    // Placed Features
    SPPlacedFeatures.registerTree(pink_blossom_name + "_trees", pinkBlossomTrees, saplingBlock.get());
    SPPlacedFeatures.bootstrap();
    // Register biome keys
    SpoornPinkBiomeRegistry.init();
}
Also used : ResourceBuilder(org.spoorn.spoornpacks.api.ResourceBuilder) ConfiguredFeature(net.minecraft.world.gen.feature.ConfiguredFeature) RandomFeatureConfig(net.minecraft.world.gen.feature.RandomFeatureConfig) Resource(org.spoorn.spoornpacks.api.Resource) Block(net.minecraft.block.Block) SPTreeConfig(org.spoorn.spoornpink.world.gen.feature.config.SPTreeConfig)

Aggregations

Block (net.minecraft.block.Block)1 ConfiguredFeature (net.minecraft.world.gen.feature.ConfiguredFeature)1 RandomFeatureConfig (net.minecraft.world.gen.feature.RandomFeatureConfig)1 Resource (org.spoorn.spoornpacks.api.Resource)1 ResourceBuilder (org.spoorn.spoornpacks.api.ResourceBuilder)1 SPTreeConfig (org.spoorn.spoornpink.world.gen.feature.config.SPTreeConfig)1