use of net.minecraft.world.level.block.Rotation in project The-Aether by Gilded-Games.
the class HolidayTreeFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
BlockPos pos = context.origin();
Random rand = context.random();
WorldGenLevel reader = context.level();
Calendar calendar = Calendar.getInstance();
if ((AetherConfig.COMMON.generate_holiday_tree_seasonally.get() && (calendar.get(Calendar.MONTH) == Calendar.DECEMBER || calendar.get(Calendar.MONTH) == Calendar.JANUARY)) || AetherConfig.COMMON.generate_holiday_tree_always.get()) {
Rotation rotation = Rotation.getRandom(rand);
StructureManager templatemanager = reader.getLevel().getServer().getStructureManager();
StructureTemplate tree = templatemanager.getOrCreate(TREE);
StructureTemplate decor = templatemanager.getOrCreate(DECORATION);
ChunkPos chunkpos = new ChunkPos(pos);
BoundingBox mutableboundingbox = new BoundingBox(chunkpos.getMinBlockX(), 0, chunkpos.getMinBlockZ(), chunkpos.getMaxBlockX(), 256, chunkpos.getMaxBlockZ());
StructurePlaceSettings placementsettings = (new StructurePlaceSettings()).setRotation(rotation).setBoundingBox(mutableboundingbox).setRandom(rand).addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR);
Vec3i size = tree.getSize(rotation);
int rx = Math.floorDiv(size.getX(), 2);
int rz = Math.floorDiv(size.getZ(), 2);
int x = rand.nextInt(16 - size.getX());
int z = rand.nextInt(16 - size.getZ());
int y = reader.getHeight(Heightmap.Types.OCEAN_FLOOR_WG, pos.getX() + x + rx, pos.getZ() + z + rz);
if (y <= 48)
return true;
pos = pos.offset(x, y, z);
for (int i = -rx * 2; i < rx * 2 + 1; i++) {
for (int j = -rz * 2; j < rz * 2 + 1; j++) {
if (i * i + j * j <= 3.5 * rx * rx) {
y = reader.getHeight(Heightmap.Types.OCEAN_FLOOR_WG, pos.getX() + rx + i, pos.getZ() + rz + j);
if (y <= 48)
continue;
BlockPos pos1 = new BlockPos(pos.getX() + rx + i, y, pos.getZ() + rz + j);
if (rand.nextInt(6) == 0) {
this.setBlock(reader, pos1, AetherBlocks.PRESENT.get().defaultBlockState());
} else {
this.setBlock(reader, pos1, Blocks.SNOW.defaultBlockState());
}
}
}
}
BlockPos blockpos1 = tree.getZeroPositionWithTransform(pos, Mirror.NONE, rotation);
tree.placeInWorld(reader, blockpos1, blockpos1, placementsettings, rand, 4);
BlockRotProcessor integrityprocessor = new BlockRotProcessor(0.2F);
placementsettings.clearProcessors().addProcessor(integrityprocessor);
decor.placeInWorld(reader, blockpos1, blockpos1, placementsettings, rand, 4);
}
return true;
}
use of net.minecraft.world.level.block.Rotation in project SolarCraftRepository by FINDERFEED.
the class RadiantLandFloatingIslands method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> ctx) {
WorldGenLevel world = ctx.level();
if (AVAILABLE_TO_SPAWN == null) {
initList(world);
}
BlockPos pos = ctx.origin();
Random random = ctx.random();
Rotation rot = Rotation.getRandom(random);
StructureManager manager = world.getLevel().getStructureManager();
StructureTemplate templ = manager.getOrCreate(List.of(ISLAND1, ISLAND2, ISLAND3, ISLAND4).get(random.nextInt(4)));
StructurePlaceSettings set = new StructurePlaceSettings().addProcessor(BlockIgnoreProcessor.AIR).setRandom(random).setRotation(rot).setBoundingBox(BoundingBox.infinite());
BlockPos blockpos1 = templ.getZeroPositionWithTransform(pos.offset(0, 1, 0), Mirror.NONE, rot);
templ.placeInWorld(world, blockpos1, blockpos1, set, random, 4);
templ.filterBlocks(blockpos1, set, Blocks.SEA_LANTERN).forEach((info) -> {
setBlock(world, info.pos, AVAILABLE_TO_SPAWN.get(world.getRandom().nextInt(AVAILABLE_TO_SPAWN.size())).defaultBlockState());
});
return true;
}
use of net.minecraft.world.level.block.Rotation in project SolarCraftRepository by FINDERFEED.
the class CrystallizedOreVeinFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> ctx) {
WorldGenLevel world = ctx.level();
if (AVAILABLE_TO_SPAWN == null) {
initList(world);
}
BlockPos pos = ctx.origin().below(13);
Random random = ctx.random();
Rotation rot = Rotation.getRandom(random);
StructureManager manager = world.getLevel().getStructureManager();
StructureTemplate templ = manager.getOrCreate(VEIN);
StructurePlaceSettings set = new StructurePlaceSettings().addProcessor(BlockIgnoreProcessor.AIR).setRandom(random).setRotation(rot).setBoundingBox(BoundingBox.infinite());
BlockPos blockpos1 = templ.getZeroPositionWithTransform(pos.offset(0, 1, 0), Mirror.NONE, rot);
templ.placeInWorld(world, blockpos1, blockpos1, set, random, 4);
templ.filterBlocks(blockpos1, set, Blocks.SEA_LANTERN).forEach((info) -> {
setBlock(world, info.pos, AVAILABLE_TO_SPAWN.get(world.getRandom().nextInt(AVAILABLE_TO_SPAWN.size())).defaultBlockState());
});
return true;
}
use of net.minecraft.world.level.block.Rotation in project SolarCraftRepository by FINDERFEED.
the class CrystalCaveOreCrystal method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> ctx) {
WorldGenLevel world = ctx.level();
if (AVAILABLE_TO_SPAWN == null) {
initList(world);
}
BlockPos pos = ctx.origin();
Random random = ctx.random();
BlockState stateAtPos = world.getBlockState(pos);
if (!(stateAtPos.isAir())) {
return false;
}
Optional<Column> column = Column.scan(world, pos, 30, (state) -> state.is(Blocks.AIR) || state.is(Blocks.CAVE_AIR), (state) -> state.is(Blocks.STONE));
if (column.isPresent() && column.get().getFloor().isPresent()) {
Rotation rot = Rotation.getRandom(random);
StructureManager manager = world.getLevel().getStructureManager();
StructureTemplate templ = manager.getOrCreate(ORE_CRYSTAL);
StructurePlaceSettings set = new StructurePlaceSettings().addProcessor(BlockIgnoreProcessor.AIR).setRandom(random).setRotation(rot).setBoundingBox(BoundingBox.infinite());
BlockPos blockpos1 = templ.getZeroPositionWithTransform(pos.offset(-templ.getSize().getX() / 2, 0, -templ.getSize().getZ() / 2), Mirror.NONE, rot);
blockpos1 = new BlockPos(blockpos1.getX(), column.get().getFloor().getAsInt() - 2, blockpos1.getZ());
templ.placeInWorld(world, blockpos1, blockpos1, set, random, 4);
templ.filterBlocks(blockpos1, set, Blocks.SEA_LANTERN).forEach((info) -> {
setBlock(world, info.pos, AVAILABLE_TO_SPAWN.get(world.getRandom().nextInt(AVAILABLE_TO_SPAWN.size())).defaultBlockState());
});
} else {
return false;
}
return true;
}
use of net.minecraft.world.level.block.Rotation in project SolarCraftRepository by FINDERFEED.
the class ChargingStationStructure method generatePieces.
private static void generatePieces(StructurePiecesBuilder p_197089_, PieceGenerator.Context<NoneFeatureConfiguration> ctx) {
int x = (ctx.chunkPos().x << 4) + 7;
int z = (ctx.chunkPos().z << 4) + 7;
int surfaceY = ctx.chunkGenerator().getBaseHeight(x, z, Heightmap.Types.WORLD_SURFACE_WG, ctx.heightAccessor());
BlockPos blockpos = new BlockPos(x, surfaceY, z);
Rotation rotation = Rotation.getRandom(ctx.random());
ChargingStationPieces.start(ctx.structureManager(), blockpos, rotation, p_197089_, ctx.random());
}
Aggregations