diff --git a/src/main/java/net/parsell/cherry/common/features/CherryTree.java b/src/main/java/net/parsell/cherry/common/features/CherryTree.java index fc2ae71..f5cc24e 100644 --- a/src/main/java/net/parsell/cherry/common/features/CherryTree.java +++ b/src/main/java/net/parsell/cherry/common/features/CherryTree.java @@ -22,11 +22,19 @@ public class CherryTree extends Feature { public boolean generate(StructureWorldAccess world, ChunkGenerator generator, Random random, BlockPos pos, DefaultFeatureConfig config) { BlockPos topPos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, pos); Direction offset = Direction.NORTH; - + /* for (int y = 1; y <= 15; y++) { offset = offset.rotateYClockwise(); world.setBlockState(topPos.up(y).offset(offset), CherryBlocks.CHERRYLOG.getDefaultState(), 3); } + */ + if (isSoil(world, topPos.down())){ + System.out.println(pos.toString() + " is soil! (TOP)"); + for (int y = 0; y <=7; y++) + world.setBlockState(topPos.up(y), CherryBlocks.CHERRYLOG.getDefaultState(), 3); + } else { + System.out.println(pos.toString() + " is not soil! (TOP)"); + } return true; } diff --git a/src/main/java/net/parsell/cherry/core/CherryFeatures.java b/src/main/java/net/parsell/cherry/core/CherryFeatures.java index 4dd2476..7957ca8 100644 --- a/src/main/java/net/parsell/cherry/core/CherryFeatures.java +++ b/src/main/java/net/parsell/cherry/core/CherryFeatures.java @@ -1,5 +1,7 @@ package net.parsell.cherry.core; +import com.google.common.collect.ImmutableList; + import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.minecraft.block.BlockState; @@ -9,25 +11,37 @@ import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.UniformIntDistribution; +import net.minecraft.world.gen.decorator.ChanceDecoratorConfig; +import net.minecraft.world.gen.decorator.CountExtraDecoratorConfig; +import net.minecraft.world.gen.decorator.Decorator; import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.ConfiguredFeatures; +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.TreeFeature; import net.minecraft.world.gen.feature.TreeFeatureConfig; +import net.minecraft.world.gen.feature.TreeFeatureConfig.Builder; +import net.minecraft.world.gen.feature.size.FeatureSize; import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize; import net.minecraft.world.gen.foliage.BlobFoliagePlacer; +import net.minecraft.world.gen.foliage.FoliagePlacer; import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; import net.minecraft.world.gen.trunk.StraightTrunkPlacer; - +import net.parsell.cherry.common.features.CherryTree; public class CherryFeatures { private static final BlockState CHERRYLOG_STATE = CherryBlocks.CHERRYLOG.getDefaultState(); private static final BlockState CHERRYLEAVES_STATE = CherryBlocks.CHERRYLEAVES.getDefaultState(); // Create the features - private static final Feature CHERRY_TREE_1 = new TreeFeature(TreeFeatureConfig.CODEC); + private static final Feature CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC); // Configure the features - public static final ConfiguredFeature CHERRY_TREE_1_C = CHERRY_TREE_1.configure((new TreeFeatureConfig.Builder(new SimpleBlockStateProvider(CherryFeatures.CHERRYLOG_STATE), new SimpleBlockStateProvider(CherryFeatures.CHERRYLEAVES_STATE), new BlobFoliagePlacer(UniformIntDistribution.of(2), UniformIntDistribution.of(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayersFeatureSize(1, 0, 1))).ignoreVines().build()); + static TreeFeatureConfig CHERRY_TREE_1_CONFIG = new TreeFeatureConfig.Builder(new SimpleBlockStateProvider(CHERRYLOG_STATE), new SimpleBlockStateProvider(CHERRYLEAVES_STATE), new BlobFoliagePlacer(UniformIntDistribution.of(2), UniformIntDistribution.of(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayersFeatureSize(1, 0, 1)).ignoreVines().build(); + public static final ConfiguredFeature CHERRY_TREE_1_C = Feature.TREE.configure(CHERRY_TREE_1_CONFIG); + public static final ConfiguredFeature CHERRY_TREE_1_C_R = Feature.RANDOM_SELECTOR.configure(new RandomFeatureConfig(ImmutableList.of(CHERRY_TREE_1_C.withChance(0.8F)), CHERRY_TREE_1_C)).decorate(ConfiguredFeatures.Decorators.SQUARE_HEIGHTMAP).decorate(Decorator.COUNT_EXTRA.configure(new CountExtraDecoratorConfig(1, 0.1F, 1))); private static void addFeatures(){ // Register the features @@ -35,7 +49,7 @@ public class CherryFeatures { // Register the configured features RegistryKey> cherryTree1 = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, new Identifier("cherry", "cherry_tree_1")); - Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, cherryTree1.getValue(), CHERRY_TREE_1_C); + Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, cherryTree1.getValue(), CHERRY_TREE_1_C_R); // Modify the biomes BiomeModifications.addFeature(BiomeSelectors.all(), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1); diff --git a/src/main/resources/assets/cherry/textures/block/cherry_leaves.png b/src/main/resources/assets/cherry/textures/block/cherry_leaves.png index 637a8dc..bd34dea 100644 Binary files a/src/main/resources/assets/cherry/textures/block/cherry_leaves.png and b/src/main/resources/assets/cherry/textures/block/cherry_leaves.png differ diff --git a/src/main/resources/assets/cherry/textures/block/cherry_log.png b/src/main/resources/assets/cherry/textures/block/cherry_log.png index ab963f9..830972f 100644 Binary files a/src/main/resources/assets/cherry/textures/block/cherry_log.png and b/src/main/resources/assets/cherry/textures/block/cherry_log.png differ diff --git a/src/main/resources/assets/cherry/textures/block/cherry_log_top.png b/src/main/resources/assets/cherry/textures/block/cherry_log_top.png index 4621936..36534d7 100644 Binary files a/src/main/resources/assets/cherry/textures/block/cherry_log_top.png and b/src/main/resources/assets/cherry/textures/block/cherry_log_top.png differ