beginings of trees
This commit is contained in:
parent
54855a1981
commit
c7094dfc61
|
@ -2,7 +2,6 @@ package net.parsell.cherry;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.parsell.cherry.core.*;
|
import net.parsell.cherry.core.*;
|
||||||
|
|
||||||
public class Cherry implements ModInitializer {
|
public class Cherry implements ModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,5 +13,7 @@ public class Cherry implements ModInitializer {
|
||||||
System.out.println("Cherry Initilizating...");
|
System.out.println("Cherry Initilizating...");
|
||||||
CherryBlocks.init();
|
CherryBlocks.init();
|
||||||
CherryItems.init();
|
CherryItems.init();
|
||||||
|
CherryFeatures.init();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package net.parsell.cherry.core;
|
||||||
|
|
||||||
|
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.feature.ConfiguredFeature;
|
||||||
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
|
import net.minecraft.world.gen.feature.TreeFeature;
|
||||||
|
import net.minecraft.world.gen.feature.TreeFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.feature.size.TwoLayersFeatureSize;
|
||||||
|
import net.minecraft.world.gen.foliage.BlobFoliagePlacer;
|
||||||
|
import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider;
|
||||||
|
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// 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());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Modify the biomes
|
||||||
|
BiomeModifications.addFeature(BiomeSelectors.all(), GenerationStep.Feature.VEGETAL_DECORATION, cherryTree1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(){
|
||||||
|
addFeatures();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue