mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Added apple trees to world gen
This commit is contained in:
parent
e5e37be119
commit
ca70c87b04
4 changed files with 37 additions and 15 deletions
|
@ -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 extends Block> T register(String name, T block) {
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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))));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue