Updated textures, implemented tree gen
This commit is contained in:
parent
c7094dfc61
commit
bb39d14bb8
|
@ -22,11 +22,19 @@ public class CherryTree extends Feature<DefaultFeatureConfig> {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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<TreeFeatureConfig> CHERRY_TREE_1 = new TreeFeature(TreeFeatureConfig.CODEC);
|
||||
private static final Feature<DefaultFeatureConfig> CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC);
|
||||
|
||||
// Configure the features
|
||||
public static final ConfiguredFeature<TreeFeatureConfig, ?> 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<ConfiguredFeature<?, ?>> 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);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 468 B |
Binary file not shown.
Before Width: | Height: | Size: 267 B After Width: | Height: | Size: 14 KiB |
Binary file not shown.
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 14 KiB |
Loading…
Reference in New Issue