Compare commits
2 Commits
54855a1981
...
bb39d14bb8
Author | SHA1 | Date |
---|---|---|
|
bb39d14bb8 | |
|
c7094dfc61 |
|
@ -2,7 +2,6 @@ package net.parsell.cherry;
|
|||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.parsell.cherry.core.*;
|
||||
|
||||
public class Cherry implements ModInitializer {
|
||||
|
||||
@Override
|
||||
|
@ -14,5 +13,7 @@ public class Cherry implements ModInitializer {
|
|||
System.out.println("Cherry Initilizating...");
|
||||
CherryBlocks.init();
|
||||
CherryItems.init();
|
||||
CherryFeatures.init();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package net.parsell.cherry.common.features;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.parsell.cherry.core.CherryBlocks;
|
||||
|
||||
public class CherryTree extends Feature<DefaultFeatureConfig> {
|
||||
public CherryTree(Codec<DefaultFeatureConfig> config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
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;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
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<DefaultFeatureConfig> CHERRY_TREE_1 = new CherryTree(DefaultFeatureConfig.CODEC);
|
||||
|
||||
// Configure the features
|
||||
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
|
||||
Registry.register(Registry.FEATURE, new Identifier("cherry", "cherry_tree"), CHERRY_TREE_1);
|
||||
|
||||
// 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_R);
|
||||
|
||||
// Modify the biomes
|
||||
BiomeModifications.addFeature(BiomeSelectors.all(), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1);
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
addFeatures();
|
||||
}
|
||||
}
|
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