beginings of trees

This commit is contained in:
2021-02-25 02:09:01 -05:00
parent 54855a1981
commit c7094dfc61
3 changed files with 82 additions and 1 deletions
@@ -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;
}
}