diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index 413051cb..fee73308 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -18,7 +18,6 @@ import com.minelittlepony.unicopia.structure.CustomSaplingGenerator; import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.tools.FabricToolTags; import net.minecraft.block.Block; -import net.minecraft.block.Blocks; import net.minecraft.block.FallingBlock; import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; @@ -164,6 +163,7 @@ public interface UBlocks { .breakByTool(FabricToolTags.SHOVELS) .build())); Block APPLE_LEAVES = register("apple_leaves", new FruitLeavesBlock(FabricBlockSettings.of(Material.LEAVES) + .nonOpaque() .strength(0.2F, 0.2F) .ticksRandomly() .sounds(BlockSoundGroup.GRASS) @@ -173,14 +173,12 @@ public interface UBlocks { .fruit(W -> TreeType.OAK.pickRandomStack()) .compost(w -> new ItemStack(UItems.ROTTEN_APPLE))); - SaplingBlock APPLE_SAPLING = register("apple_sapling", new SaplingBlock( - new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), APPLE_LEAVES.getDefaultState()), - FabricBlockSettings.of(Material.WOOD) - .noCollision() - .ticksRandomly() - .breakInstantly() - .sounds(BlockSoundGroup.GRASS) - .build()) {}); + SaplingBlock APPLE_SAPLING = register("apple_sapling", new SaplingBlock(CustomSaplingGenerator.APPLE_TREE, FabricBlockSettings.of(Material.WOOD) + .noCollision() + .ticksRandomly() + .breakInstantly() + .sounds(BlockSoundGroup.GRASS) + .build()) {}); static T register(String name, T block) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index b9b247cc..cd0698ca 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -46,7 +46,7 @@ public interface URenderers { BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH, UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR, - UBlocks.APPLE_SAPLING, + UBlocks.APPLE_SAPLING, UBlocks.ALFALFA_CROPS, UBlocks.TOMATO_PLANT, UBlocks.CLOUDSDALE_TOMATO_PLANT ); BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(), diff --git a/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java b/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java index ea74da74..d0881386 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java @@ -4,8 +4,10 @@ import java.util.Random; import javax.annotation.Nullable; import com.google.common.collect.ImmutableList; +import com.minelittlepony.unicopia.block.UBlocks; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.sapling.SaplingGenerator; import net.minecraft.world.gen.decorator.BeehiveTreeDecorator; import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig; @@ -15,11 +17,12 @@ import net.minecraft.world.gen.foliage.BlobFoliagePlacer; import net.minecraft.world.gen.stateprovider.SimpleStateProvider; public class CustomSaplingGenerator extends SaplingGenerator { + public static final CustomSaplingGenerator APPLE_TREE = new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), UBlocks.APPLE_LEAVES.getDefaultState()); - private final BranchedTreeFeatureConfig fancyConfig; - private final BranchedTreeFeatureConfig fancyHiveConfig; - private final BranchedTreeFeatureConfig hiveConfig; - private final BranchedTreeFeatureConfig config; + public final BranchedTreeFeatureConfig fancyConfig; + public final BranchedTreeFeatureConfig fancyHiveConfig; + public final BranchedTreeFeatureConfig hiveConfig; + public final BranchedTreeFeatureConfig config; public CustomSaplingGenerator(int height, BlockState log, BlockState leaves) { fancyConfig = new BranchedTreeFeatureConfig.Builder( diff --git a/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java b/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java index 325d12f9..d09dc436 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java @@ -1,11 +1,18 @@ package com.minelittlepony.unicopia.structure; +import com.google.common.collect.ImmutableList; + import net.minecraft.structure.StructurePieceType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig; +import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.FeatureConfig; +import net.minecraft.world.gen.feature.RandomFeatureConfig; import net.minecraft.world.gen.feature.StructureFeature; public interface UStructures { @@ -23,5 +30,19 @@ public interface UStructures { return Registry.register(Registry.FEATURE, new Identifier("unicopia", id), feature); } - static void bootstrap() { } + static void bootstrap() { + Registry.BIOME.forEach(biome -> { + Biome.Category category = biome.getCategory(); + + if (category == Biome.Category.FOREST) { + biome.addFeature(GenerationStep.Feature.VEGETAL_DECORATION, + Feature.RANDOM_SELECTOR.configure(new RandomFeatureConfig(ImmutableList.of( + Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.hiveConfig).withChance(0.02F), + Feature.FANCY_TREE.configure(CustomSaplingGenerator.APPLE_TREE.fancyConfig).withChance(0.01F)), + Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.config) + )) + .createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(10, 0.1F, 1)))); + } + }); + } }