Search in sources :

Example 1 with VanillaGeneration

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;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer) VanillaGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 2 with VanillaGeneration

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;
}
Also used : StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) BlockPos(net.minecraft.util.math.BlockPos) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) VanillaGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType)

Example 3 with VanillaGeneration

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);
}
Also used : StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) NBTStorable(ivorius.reccomplex.nbt.NBTStorable) VanillaGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType)

Example 4 with VanillaGeneration

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);
}
Also used : Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) VanillaGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType)

Aggregations

GenerationType (ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType)4 VanillaGeneration (ivorius.reccomplex.world.gen.feature.structure.generic.generation.VanillaGeneration)4 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)2 BlockPos (net.minecraft.util.math.BlockPos)2 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)1 NBTStorable (ivorius.reccomplex.nbt.NBTStorable)1 StructureGenerator (ivorius.reccomplex.world.gen.feature.StructureGenerator)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 WorldServer (net.minecraft.world.WorldServer)1 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)1