use of net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration in project Tropicraft by Tropicraft.
the class LargePalmTreeFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
WorldGenLevel world = context.level();
Random random = context.random();
BlockPos pos = context.origin();
NoneFeatureConfiguration config = context.config();
pos = pos.immutable();
int height = random.nextInt(7) + 7;
if (goesBeyondWorldSize(world, pos.getY(), height)) {
return false;
}
if (!isBBAvailable(world, pos, height)) {
return false;
}
if (!getSapling().canSurvive(getSapling().defaultBlockState(), world, pos)) {
return false;
}
if (world.getBlockState(pos.below()).getBlock() == Blocks.GRASS_BLOCK) {
world.setBlock(pos.below(), Blocks.DIRT.defaultBlockState(), 3);
}
// Place trunk
for (int y = 0; y <= height; y++) {
placeLog(world, pos.getX(), pos.getY() + y, pos.getZ());
}
final int i = pos.getX(), j = pos.getY(), k = pos.getZ();
// Wheeee, auto-generated code!
placeLeaf(world, i + 0, j + height + 1, k + -7);
placeLeaf(world, i + -1, j + height + 1, k + -6);
placeLeaf(world, i + 1, j + height + 1, k + -6);
placeLeaf(world, i + -5, j + height + 1, k + -5);
placeLeaf(world, i + 5, j + height + 1, k + -5);
placeLeaf(world, i + -6, j + height + 1, k + -1);
placeLog(world, i + 0, j + height + 1, k + -1);
placeLeaf(world, i + 6, j + height + 1, k + -1);
placeLeaf(world, i + -7, j + height + 1, k + 0);
placeLog(world, i + -1, j + height + 1, k + 0);
placeLog(world, i + 0, j + height + 1, k + 0);
placeLog(world, i + 1, j + height + 1, k + 0);
placeLeaf(world, i + 7, j + height + 1, k + 0);
placeLeaf(world, i + -6, j + height + 1, k + 1);
placeLog(world, i + 0, j + height + 1, k + 1);
placeLeaf(world, i + 6, j + height + 1, k + 1);
placeLeaf(world, i + -5, j + height + 1, k + 5);
placeLeaf(world, i + 5, j + height + 1, k + 5);
placeLeaf(world, i + -1, j + height + 1, k + 6);
placeLeaf(world, i + 1, j + height + 1, k + 6);
placeLeaf(world, i + 0, j + height + 1, k + 7);
placeLeaf(world, i + 0, j + height + 2, k + -6);
placeLeaf(world, i + -4, j + height + 2, k + -5);
placeLeaf(world, i + -1, j + height + 2, k + -5);
placeLeaf(world, i + 1, j + height + 2, k + -5);
placeLeaf(world, i + 4, j + height + 2, k + -5);
placeLeaf(world, i + -5, j + height + 2, k + -4);
placeLeaf(world, i + -3, j + height + 2, k + -4);
placeLeaf(world, i + -1, j + height + 2, k + -4);
placeLeaf(world, i + 1, j + height + 2, k + -4);
placeLeaf(world, i + 3, j + height + 2, k + -4);
placeLeaf(world, i + 5, j + height + 2, k + -4);
placeLeaf(world, i + -4, j + height + 2, k + -3);
placeLeaf(world, i + -2, j + height + 2, k + -3);
placeLeaf(world, i + -1, j + height + 2, k + -3);
placeLeaf(world, i + 1, j + height + 2, k + -3);
placeLeaf(world, i + 2, j + height + 2, k + -3);
placeLeaf(world, i + 4, j + height + 2, k + -3);
placeLeaf(world, i + -3, j + height + 2, k + -2);
placeLeaf(world, i + -1, j + height + 2, k + -2);
placeLeaf(world, i + 1, j + height + 2, k + -2);
placeLeaf(world, i + 3, j + height + 2, k + -2);
placeLeaf(world, i + -5, j + height + 2, k + -1);
placeLeaf(world, i + -4, j + height + 2, k + -1);
placeLeaf(world, i + -3, j + height + 2, k + -1);
placeLeaf(world, i + -2, j + height + 2, k + -1);
placeLeaf(world, i + -1, j + height + 2, k + -1);
placeLeaf(world, i + 0, j + height + 2, k + -1);
placeLeaf(world, i + 1, j + height + 2, k + -1);
placeLeaf(world, i + 2, j + height + 2, k + -1);
placeLeaf(world, i + 3, j + height + 2, k + -1);
placeLeaf(world, i + 4, j + height + 2, k + -1);
placeLeaf(world, i + 5, j + height + 2, k + -1);
placeLeaf(world, i + -6, j + height + 2, k + 0);
placeLeaf(world, i + -1, j + height + 2, k + 0);
placeLeaf(world, i + 0, j + height + 2, k + 0);
placeLeaf(world, i + 1, j + height + 2, k + 0);
placeLeaf(world, i + 6, j + height + 2, k + 0);
placeLeaf(world, i + -5, j + height + 2, k + 1);
placeLeaf(world, i + -4, j + height + 2, k + 1);
placeLeaf(world, i + -3, j + height + 2, k + 1);
placeLeaf(world, i + -2, j + height + 2, k + 1);
placeLeaf(world, i + -1, j + height + 2, k + 1);
placeLeaf(world, i + 0, j + height + 2, k + 1);
placeLeaf(world, i + 1, j + height + 2, k + 1);
placeLeaf(world, i + 2, j + height + 2, k + 1);
placeLeaf(world, i + 3, j + height + 2, k + 1);
placeLeaf(world, i + 4, j + height + 2, k + 1);
placeLeaf(world, i + 5, j + height + 2, k + 1);
placeLeaf(world, i + -3, j + height + 2, k + 2);
placeLeaf(world, i + -1, j + height + 2, k + 2);
placeLeaf(world, i + 1, j + height + 2, k + 2);
placeLeaf(world, i + 3, j + height + 2, k + 2);
placeLeaf(world, i + -4, j + height + 2, k + 3);
placeLeaf(world, i + -2, j + height + 2, k + 3);
placeLeaf(world, i + -1, j + height + 2, k + 3);
placeLeaf(world, i + 1, j + height + 2, k + 3);
placeLeaf(world, i + 2, j + height + 2, k + 3);
placeLeaf(world, i + 4, j + height + 2, k + 3);
placeLeaf(world, i + -5, j + height + 2, k + 4);
placeLeaf(world, i + -3, j + height + 2, k + 4);
placeLeaf(world, i + -1, j + height + 2, k + 4);
placeLeaf(world, i + 1, j + height + 2, k + 4);
placeLeaf(world, i + 3, j + height + 2, k + 4);
placeLeaf(world, i + 5, j + height + 2, k + 4);
placeLeaf(world, i + -4, j + height + 2, k + 5);
placeLeaf(world, i + -1, j + height + 2, k + 5);
placeLeaf(world, i + 1, j + height + 2, k + 5);
placeLeaf(world, i + 4, j + height + 2, k + 5);
placeLeaf(world, i + 0, j + height + 2, k + 6);
placeLeaf(world, i + 0, j + height + 3, k + -5);
placeLeaf(world, i + -4, j + height + 3, k + -4);
placeLeaf(world, i + 0, j + height + 3, k + -4);
placeLeaf(world, i + 4, j + height + 3, k + -4);
placeLeaf(world, i + -3, j + height + 3, k + -3);
placeLeaf(world, i + 0, j + height + 3, k + -3);
placeLeaf(world, i + 3, j + height + 3, k + -3);
placeLeaf(world, i + -2, j + height + 3, k + -2);
placeLeaf(world, i + 0, j + height + 3, k + -2);
placeLeaf(world, i + 2, j + height + 3, k + -2);
placeLeaf(world, i + -1, j + height + 3, k + -1);
placeLeaf(world, i + 0, j + height + 3, k + -1);
placeLeaf(world, i + 1, j + height + 3, k + -1);
placeLeaf(world, i + -5, j + height + 3, k + 0);
placeLeaf(world, i + -4, j + height + 3, k + 0);
placeLeaf(world, i + -3, j + height + 3, k + 0);
placeLeaf(world, i + -2, j + height + 3, k + 0);
placeLeaf(world, i + -1, j + height + 3, k + 0);
placeLeaf(world, i + 1, j + height + 3, k + 0);
placeLeaf(world, i + 2, j + height + 3, k + 0);
placeLeaf(world, i + 3, j + height + 3, k + 0);
placeLeaf(world, i + 4, j + height + 3, k + 0);
placeLeaf(world, i + 5, j + height + 3, k + 0);
placeLeaf(world, i + -1, j + height + 3, k + 1);
placeLeaf(world, i + 0, j + height + 3, k + 1);
placeLeaf(world, i + 1, j + height + 3, k + 1);
placeLeaf(world, i + -2, j + height + 3, k + 2);
placeLeaf(world, i + 0, j + height + 3, k + 2);
placeLeaf(world, i + 2, j + height + 3, k + 2);
placeLeaf(world, i + -3, j + height + 3, k + 3);
placeLeaf(world, i + 0, j + height + 3, k + 3);
placeLeaf(world, i + 3, j + height + 3, k + 3);
placeLeaf(world, i + -4, j + height + 3, k + 4);
placeLeaf(world, i + 0, j + height + 3, k + 4);
placeLeaf(world, i + 4, j + height + 3, k + 4);
placeLeaf(world, i + 0, j + height + 3, k + 5);
for (int c = 0; c < 4; c++) {
spawnCoconuts(world, new BlockPos(i, j + height + 1, k).relative(Direction.from2DDataValue(i)), random, 2, getLeaf());
}
return true;
}
use of net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration in project Tropicraft by Tropicraft.
the class UpTreeFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
WorldGenLevel world = context.level();
Random rand = context.random();
BlockPos pos = context.origin();
NoneFeatureConfiguration config = context.config();
pos = pos.immutable();
final int height = rand.nextInt(4) + 6;
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
if (goesBeyondWorldSize(world, pos.getY(), height)) {
return false;
}
if (!isBBAvailable(world, pos, height)) {
return false;
}
if (!getSapling().canSurvive(getSapling().defaultBlockState(), world, pos)) {
return false;
}
world.setBlock(pos.below(), Blocks.DIRT.defaultBlockState(), 3);
for (int y = j; y < j + height; y++) {
placeLog(world, i, y, k);
if (rand.nextInt(5) == 0) {
int x = rand.nextInt(3) - 1 + i;
int z = k;
if (x - i == 0) {
z += rand.nextBoolean() ? 1 : -1;
}
placeLeaf(world, x, y, z);
}
if (y == j + height - 1) {
placeLog(world, i + 1, y, k);
placeLog(world, i - 1, y, k);
placeLog(world, i, y, k + 1);
placeLog(world, i, y, k - 1);
}
}
final int radius = rand.nextInt(2) + 3;
genCircle(world, i, j + height, k, radius, 0, getLeaf(), false);
genCircle(world, i, j + height + 1, k, radius + 2, radius, getLeaf(), false);
genCircle(world, i, j + height + 2, k, radius + 3, radius + 2, getLeaf(), false);
return true;
}
Aggregations