use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration in project RecurrentComplex by Ivorforce.
the class GenericVillagePiece method addComponentParts.
@Override
@ParametersAreNonnullByDefault
public boolean addComponentParts(World world, Random random, StructureBoundingBox boundingBox) {
Structure<?> structure = StructureRegistry.INSTANCE.get(structureID);
if (structure == null)
return false;
GenerationType generationType = structure.generationType(generationID);
if (!(generationType instanceof VanillaGeneration))
return false;
VanillaGeneration vanillaGenInfo = (VanillaGeneration) generationType;
BlockPos structureShift = transform.apply(vanillaGenInfo.spawnShift, new int[] { 1, 1, 1 });
if (this.averageGroundLvl < 0) {
this.averageGroundLvl = this.getAverageGroundLevel(world, boundingBox);
if (this.averageGroundLvl < 0)
return true;
// Structure shift y was included in bounding box, but must be re-added because it is overwritten
this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.minY + structureShift.getY(), 0);
}
if (world instanceof WorldServer)
generate((WorldServer) world, boundingBox, structure, generationType);
return true;
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration in project RecurrentComplex by Ivorforce.
the class GenericVillageCreationHandler method buildComponent.
@Override
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int x, int y, int z, EnumFacing front, int generationDepth) {
Structure structure = StructureRegistry.INSTANCE.get(structureID);
if (structure == null)
return kill(villagePiece);
GenerationType generationType = structure.generationType(generationID);
if (!(generationType instanceof VanillaGeneration))
return kill(villagePiece);
VanillaGeneration vanillaGenInfo = (VanillaGeneration) generationType;
AxisAlignedTransform2D transform = GenericVillagePiece.getTransform(vanillaGenInfo.front, structure.isMirrorable(), structure.isRotatable(), front.getOpposite(), random);
if (!vanillaGenInfo.generatesIn(startPiece.biome) || transform == null)
return kill(villagePiece);
int[] structureSize = RCAxisAlignedTransform.applySize(transform, structure.size());
StructureBoundingBox strucBB = Structures.boundingBox(new BlockPos(x, y, z), structureSize);
if (!GenericVillagePiece.canVillageGoDeeperC(strucBB) || StructureComponent.findIntersecting(pieces, strucBB) != null)
return null;
GenericVillagePiece genericVillagePiece = GenericVillagePiece.create(structureID, generationID, startPiece, generationDepth);
genericVillagePiece.seed = random.nextLong();
if (genericVillagePiece == null)
return kill(villagePiece);
genericVillagePiece.setIds(structureID, generationID);
genericVillagePiece.setOrientation(front, transform, strucBB);
return genericVillagePiece;
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration in project RecurrentComplex by Ivorforce.
the class GenericVillagePiece method prepare.
public void prepare(WorldServer world) {
Structure<?> structure = StructureRegistry.INSTANCE.get(structureID);
if (structure == null)
return;
GenerationType generationType = structure.generationType(generationID);
if (!(generationType instanceof VanillaGeneration))
return;
VanillaGeneration vanillaGenInfo = (VanillaGeneration) generationType;
instanceData = new StructureGenerator<>(structure).seed(seed).environment(environment(world, generationType)).transform(transform).boundingBox(boundingBox).instanceData().map(NBTStorable::writeToNBT).orElse(null);
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration in project RecurrentComplex by Ivorforce.
the class GenericVillageCreationHandler method getVillagePieceWeight.
@Override
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int villageSize) {
Structure structure = StructureRegistry.INSTANCE.hasActive(structureID) ? StructureRegistry.INSTANCE.get(structureID) : null;
if (structure != null) {
float tweakedWeight = RCConfig.tweakedSpawnRate(structureID);
GenerationType generationType = structure.generationType(generationID);
if (generationType instanceof VanillaGeneration) {
VanillaGeneration vanillaGenInfo = (VanillaGeneration) generationType;
int spawnLimit = MathHelper.floor(MathHelper.nextDouble(random, vanillaGenInfo.minBaseLimit + villageSize * vanillaGenInfo.minScaledLimit, vanillaGenInfo.maxBaseLimit + villageSize * vanillaGenInfo.maxScaledLimit) + 0.5);
return new StructureVillagePieces.PieceWeight(getComponentClass(), vanillaGenInfo.getVanillaWeight(tweakedWeight), spawnLimit);
}
}
return new StructureVillagePieces.PieceWeight(getComponentClass(), 0, 0);
}
Aggregations