41 lines
1.4 KiB
Java
41 lines
1.4 KiB
Java
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;
|
|
}
|
|
} |