use of net.minecraft.world.level.block.Rotation in project SolarCraftRepository by FINDERFEED.
the class CrystalBossRoomStructure 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());
CrystalBossRoomStructurePieces.start(ctx.structureManager(), blockpos, rotation, p_197089_, ctx.random());
}
use of net.minecraft.world.level.block.Rotation in project SolarCraftRepository by FINDERFEED.
the class DimensionalShardStructure 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.NONE;
DimStructPieces.start(ctx.structureManager(), blockpos, rotation, p_197089_, ctx.random());
}
use of net.minecraft.world.level.block.Rotation in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class BTLandJigsawPlacement method addPieces.
public static Optional<PieceGenerator<BTJigsawConfiguration>> addPieces(PieceGeneratorSupplier.Context<BTJigsawConfiguration> context, BTLandJigsawPlacement.PieceFactory pieceFactory, BlockPos placementPos, boolean boundaryAdjust, boolean useHeightMap, boolean water) {
WorldgenRandom worldgenrandom = new WorldgenRandom(new LegacyRandomSource(0L));
worldgenrandom.setLargeFeatureSeed(context.seed(), context.chunkPos().x, context.chunkPos().z);
RegistryAccess registryaccess = context.registryAccess();
BTJigsawConfiguration jigsawconfiguration = context.config();
ChunkGenerator chunkgenerator = context.chunkGenerator();
StructureManager structuremanager = context.structureManager();
LevelHeightAccessor levelheightaccessor = context.heightAccessor();
Predicate<Biome> predicate = context.validBiome();
StructureFeature.bootstrap();
Registry<StructureTemplatePool> registry = registryaccess.registryOrThrow(Registry.TEMPLATE_POOL_REGISTRY);
Rotation rotation = Rotation.getRandom(worldgenrandom);
watered = water;
StructureTemplatePool structuretemplatepool = jigsawconfiguration.startPool().get();
StructurePoolElement structurepoolelement = structuretemplatepool.getRandomTemplate(worldgenrandom);
if (structurepoolelement == EmptyPoolElement.INSTANCE) {
return Optional.empty();
} else {
PoolElementStructurePiece poolelementstructurepiece = pieceFactory.create(structuremanager, structurepoolelement, placementPos, structurepoolelement.getGroundLevelDelta(), rotation, structurepoolelement.getBoundingBox(structuremanager, placementPos, rotation));
BoundingBox boundingbox = poolelementstructurepiece.getBoundingBox();
int bbX = (boundingbox.maxX() + boundingbox.minX()) / 2;
int bbZ = (boundingbox.maxZ() + boundingbox.minZ()) / 2;
int ppY;
if (useHeightMap) {
ppY = placementPos.getY() + chunkgenerator.getFirstFreeHeight(bbX, bbZ, Heightmap.Types.WORLD_SURFACE_WG, levelheightaccessor);
} else {
ppY = placementPos.getY();
}
if (watered) {
poolelementstructurepiece.move(0, -5, 0);
}
if (!predicate.test(chunkgenerator.getNoiseBiome(QuartPos.fromBlock(bbX), QuartPos.fromBlock(ppY), QuartPos.fromBlock(bbZ)))) {
return Optional.empty();
} else {
int pieceYlevel = boundingbox.minY() + poolelementstructurepiece.getGroundLevelDelta();
poolelementstructurepiece.move(0, ppY - pieceYlevel, 0);
return Optional.of((piecesBuilder, pieceGenContext) -> {
List<PoolElementStructurePiece> list = Lists.newArrayList();
list.add(poolelementstructurepiece);
if (jigsawconfiguration.maxDepth() > 0) {
int sizeLimit = 120;
AABB aabb = new AABB(bbX - sizeLimit, ppY - sizeLimit, bbZ - sizeLimit, bbX + sizeLimit + 1, ppY + sizeLimit + 1, bbZ + sizeLimit + 1);
BTLandJigsawPlacement.Placer BTLandJigsawPlacement$placer = new BTLandJigsawPlacement.Placer(registry, jigsawconfiguration.maxDepth(), pieceFactory, chunkgenerator, structuremanager, list, worldgenrandom);
BTLandJigsawPlacement$placer.placing.addLast(new BTLandJigsawPlacement.PieceState(poolelementstructurepiece, new MutableObject<>(Shapes.join(Shapes.create(aabb), Shapes.create(AABB.of(boundingbox)), BooleanOp.ONLY_FIRST)), 0));
while (!BTLandJigsawPlacement$placer.placing.isEmpty()) {
BTLandJigsawPlacement.PieceState BTLandJigsawPlacement$piecestate = BTLandJigsawPlacement$placer.placing.removeFirst();
BTLandJigsawPlacement$placer.tryPlacingChildren(BTLandJigsawPlacement$piecestate.piece, BTLandJigsawPlacement$piecestate.free, BTLandJigsawPlacement$piecestate.depth, boundaryAdjust, levelheightaccessor);
}
list.forEach(piecesBuilder::addPiece);
}
});
}
}
}
use of net.minecraft.world.level.block.Rotation in project Create by Creators-of-Create.
the class ControllerRailBlock method onWrenched.
@Override
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
Level world = context.getLevel();
if (world.isClientSide)
return InteractionResult.SUCCESS;
BlockPos pos = context.getClickedPos();
for (Rotation testRotation : new Rotation[] { Rotation.CLOCKWISE_90, Rotation.CLOCKWISE_180, Rotation.COUNTERCLOCKWISE_90 }) {
BlockState testState = rotate(state, testRotation);
if (isStableWith(testState, world, pos)) {
placeAndNotify(testState, pos, world);
return InteractionResult.SUCCESS;
}
}
BlockState testState = state.setValue(BACKWARDS, !state.getValue(BACKWARDS));
if (isStableWith(testState, world, pos))
placeAndNotify(testState, pos, world);
return InteractionResult.SUCCESS;
}
use of net.minecraft.world.level.block.Rotation in project The-Aether by Gilded-Games.
the class CrystalTreeFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
WorldGenLevel reader = context.level();
BlockPos pos = context.origin();
Random rand = context.random();
Rotation rotation = Rotation.getRandom(rand);
StructureManager templatemanager = reader.getLevel().getServer().getStructureManager();
StructureTemplate tree = templatemanager.getOrCreate(TREE);
StructureTemplate fruit = templatemanager.getOrCreate(FRUIT);
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 vec3i = tree.getSize(rotation);
int x = rand.nextInt(16 - vec3i.getX());
int z = rand.nextInt(16 - vec3i.getZ());
int y = Math.max(Math.min(reader.getHeight(Heightmap.Types.OCEAN_FLOOR_WG, pos.getX() + x, pos.getZ() + z) + rand.nextInt(20) + 40, 200), 100);
BlockPos blockpos1 = tree.getZeroPositionWithTransform(pos.offset(x, y, z), Mirror.NONE, rotation);
tree.placeInWorld(reader, blockpos1, blockpos1, placementsettings, rand, 4);
BlockRotProcessor integrityprocessor = new BlockRotProcessor(0.2F);
placementsettings.clearProcessors().addProcessor(integrityprocessor);
fruit.placeInWorld(reader, blockpos1, blockpos1, placementsettings, rand, 4);
return true;
}
Aggregations