use of com.BrassAmber.ba_bt.worldGen.BTJigsawConfiguration in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class LandBattleTower method createPiecesGenerator.
@NotNull
public static Optional<PieceGenerator<BTJigsawConfiguration>> createPiecesGenerator(PieceGeneratorSupplier.Context<BTJigsawConfiguration> context) {
// Returning an empty optional tells the game to skip this spot as it will not generate the structure. -- TelepathicGrunt
if (!LandBattleTower.isFeatureChunk(context)) {
return Optional.empty();
}
/*
* We pass this into addPieces to tell it where to generate the structure.
* If addPieces's last parameter is true, blockpos's Y value is ignored and the
* structure will spawn at terrain height instead. Set that parameter to false to
* force the structure to spawn at blockpos's Y value instead. You got options here!
* -- TelepathicGrunt
*/
BTJigsawConfiguration config = new BTJigsawConfiguration(() -> context.registryAccess().ownedRegistryOrThrow(Registry.TEMPLATE_POOL_REGISTRY).get(new ResourceLocation(BrassAmberBattleTowers.MOD_ID, "land_tower/start_pool")), // As long as it is more than the total number of possible connections the tower will spawn correctly.
12);
PieceGeneratorSupplier.Context<BTJigsawConfiguration> baseTower = new PieceGeneratorSupplier.Context<>(context.chunkGenerator(), context.biomeSource(), context.seed(), context.chunkPos(), config, context.heightAccessor(), context.validBiome(), context.structureManager(), context.registryAccess());
// Get chunk center coordinates
BlockPos centerPos = context.chunkPos().getMiddleBlockPosition(0);
Optional<PieceGenerator<BTJigsawConfiguration>> piecesGenerator;
// All a structure has to do is call this method to turn it into a jigsaw based structure!
piecesGenerator = BTLandJigsawPlacement.addPieces(// Used for JigsawPlacement to get all the proper behaviors done.
baseTower, // Needed in order to create a list of jigsaw pieces when making the structure's layout.
PoolElementStructurePiece::new, // Position of the structure. Y value is ignored if last parameter is set to true. --TelepathicGrunt
centerPos, // Special boundary adjustments for villages. It's... hard to explain. Keep this false and make your pieces not be partially intersecting. --TelepathicGrunt
false, // Place at heightmap (top land). Set this to false for structure to be place at the passed in blockpos's Y value instead.
true, // null here == random rotation.
false);
if (piecesGenerator.isPresent()) {
// I use to debug and quickly find out if the structure is spawning or not and where it is.
// This is returning the coordinates of the center starting piece.
BrassAmberBattleTowers.LOGGER.info("Land Tower at " + centerPos);
}
// Return the pieces generator that is now set up so that the game runs it when it needs to create the layout of structure pieces.
return piecesGenerator;
}
use of com.BrassAmber.ba_bt.worldGen.BTJigsawConfiguration in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class OvergrownLandTower method createPiecesGenerator.
@NotNull
public static Optional<PieceGenerator<BTJigsawConfiguration>> createPiecesGenerator(PieceGeneratorSupplier.Context<BTJigsawConfiguration> context) {
// Returning an empty optional tells the game to skip this spot as it will not generate the structure. -- TelepathicGrunt
if (!OvergrownLandTower.isFeatureChunk(context)) {
return Optional.empty();
}
/*
* We pass this into addPieces to tell it where to generate the structure.
* If addPieces's last parameter is true, blockpos's Y value is ignored and the
* structure will spawn at terrain height instead. Set that parameter to false to
* force the structure to spawn at blockpos's Y value instead. You got options here!
* -- TelepathicGrunt
*/
BTJigsawConfiguration config = new BTJigsawConfiguration(() -> context.registryAccess().ownedRegistryOrThrow(Registry.TEMPLATE_POOL_REGISTRY).get(BrassAmberBattleTowers.locate("land_tower/start_pool_overgrown")), // As long as it is more than the total number of possible connections the tower will spawn correctly.
8);
PieceGeneratorSupplier.Context<BTJigsawConfiguration> baseTower = new PieceGeneratorSupplier.Context<>(context.chunkGenerator(), context.biomeSource(), context.seed(), context.chunkPos(), config, context.heightAccessor(), context.validBiome(), context.structureManager(), context.registryAccess());
// Get chunk center coordinates
BlockPos centerPos = context.chunkPos().getMiddleBlockPosition(0);
Optional<PieceGenerator<BTJigsawConfiguration>> piecesGenerator;
// All a structure has to do is call this method to turn it into a jigsaw based structure!
piecesGenerator = BTLandJigsawPlacement.addPieces(// Used for JigsawPlacement to get all the proper behaviors done.
baseTower, // Needed in order to create a list of jigsaw pieces when making the structure's layout.
PoolElementStructurePiece::new, // Position of the structure. Y value is ignored if last parameter is set to true. --TelepathicGrunt
centerPos, // Special boundary adjustments for villages. It's... hard to explain. Keep this false and make your pieces not be partially intersecting. --TelepathicGrunt
false, // Place at heightmap (top land). Set this to false for structure to be place at the passed in blockpos's Y value instead.
true, // null here == random rotation.
watered);
if (piecesGenerator.isPresent()) {
// I use to debug and quickly find out if the structure is spawning or not and where it is.
// This is returning the coordinates of the center starting piece.
BrassAmberBattleTowers.LOGGER.info("Overgrown Land Tower at " + centerPos);
}
// Return the pieces generator that is now set up so that the game runs it when it needs to create the layout of structure pieces.
return piecesGenerator;
}
Aggregations