Search in sources :

Example 1 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class CommandRetrogen method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    Predicate<Structure> structurePredicate = parameters.get("exp").to(RCP::structurePredicate).optional().orElse(null);
    WorldServer world = parameters.get("dimension").to(MCP.dimension(server, commandSender)).require();
    long count = retrogen(world, structurePredicate);
    commandSender.sendMessage(RecurrentComplex.translations.format("commands.rcretro.count", String.valueOf(count)));
}
Also used : WorldServer(net.minecraft.world.WorldServer) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) RCP(ivorius.reccomplex.commands.parameters.RCP)

Example 2 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class CommandSightInfo method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    WorldStructureGenerationData generationData = WorldStructureGenerationData.get(sender.getEntityWorld());
    WorldStructureGenerationData.Entry entry = generationData.getEntry(UUID.fromString(parameters.get(0).require()));
    if (entry == null)
        throw RecurrentComplex.translations.commandException("commands.rcsightinfo.unknown");
    else {
        ITextComponent area = RCTextStyle.area(RCBlockAreas.from(entry.getBoundingBox()));
        ITextComponent sight = RCTextStyle.sight(entry, true);
        if (entry instanceof WorldStructureGenerationData.StructureEntry) {
            WorldStructureGenerationData.StructureEntry structureEntry = (WorldStructureGenerationData.StructureEntry) entry;
            sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.structure", RCTextStyle.structure(structureEntry.getStructureID()), area, RCTextStyle.copy(String.valueOf(structureEntry.getSeed())), sight));
            Structure structure = StructureRegistry.INSTANCE.get(structureEntry.getStructureID());
            if (structure != null) {
                // TODO generateAsSource not accurate
                NBTStorable instanceData = structure.loadInstanceData(new StructureLoadContext(structureEntry.getTransform(), entry.getBoundingBox(), false), structureEntry.getInstanceData(), RCConfig.getUniversalTransformer());
                List<TextComponentBase> list = structure.instanceDataInfo(instanceData);
                for (TextComponentBase s : list) sender.sendMessage(s);
            }
        } else
            sender.sendMessage(new TextComponentTranslation("commands.rcsightinfo.get", entry.description(), area, sight));
    }
}
Also used : StructureLoadContext(ivorius.reccomplex.world.gen.feature.structure.context.StructureLoadContext) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Parameters(ivorius.mcopts.commands.parameters.Parameters) WorldStructureGenerationData(ivorius.reccomplex.world.gen.feature.WorldStructureGenerationData) ITextComponent(net.minecraft.util.text.ITextComponent) NBTStorable(ivorius.reccomplex.nbt.NBTStorable) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) TextComponentBase(net.minecraft.util.text.TextComponentBase)

Example 3 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure 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 4 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class CommandSanity method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    boolean sane = true;
    if (RecurrentComplex.isLite()) {
        commandSender.sendMessage(new TextComponentString("Recurrent Complex is in lightweight mode!"));
    }
    if (StructureRegistry.INSTANCE.ids().isEmpty()) {
        commandSender.sendMessage(new TextComponentString("No registered structures!"));
        sane = false;
    }
    if (!Files.isReadable(ResourceDirectory.getCustomDirectory().toPath())) {
        commandSender.sendMessage(new TextComponentString("Can't read files from custom directory"));
        sane = false;
    }
    for (ModContainer mod : Loader.instance().getModList()) {
        String domain = mod.getModId();
        Path path = null;
        try {
            path = RCFiles.pathFromResourceLocation(new ResourceLocation(domain.toLowerCase(), ""));
            if (path != null && !Files.isReadable(path)) {
                commandSender.sendMessage(new TextComponentString("Can't read files from mod: " + mod.getModId()));
                sane = false;
            }
        } catch (RCFiles.ResourceLocationLoadException e) {
            RecurrentComplex.logger.error(e);
            commandSender.sendMessage(new TextComponentString("Error reading files from mod " + mod.getModId() + ": "));
            commandSender.sendMessage(new TextComponentString(RCCommands.reason(e)));
            sane = false;
        } finally {
            if (path != null)
                RCFiles.closeQuietly(path.getFileSystem());
        }
    }
    if (!Files.isReadable(ResourceDirectory.getServerDirectory().toPath())) {
        commandSender.sendMessage(new TextComponentString("Can't read files from server directory"));
        sane = false;
    }
    if (!parameters.has("short")) {
        sane &= addStructureLog(commandSender, (s, structure) -> !structure.generationTypes(GenerationType.class).isEmpty(), "Missing generation type");
        sane &= addGenericStructureLog(commandSender, (s, structure) -> !structure.metadata.authors.isEmpty(), "No author");
        sane &= addGenericStructureLog(commandSender, (s, structure) -> structure.transformer.getTransformers().stream().allMatch(t -> t.id().length() > 0), "Transformer has empty ID");
        sane &= addGenerationLog(commandSender, GenerationType.class, (structure, gen) -> gen.id().length() > 0, "Generation type has empty ID");
        sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> StructureSelector.generationWeightInBiome(gen.biomeWeights, b) > 0), "Natural generation type won't accept any known biomes");
        sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> StructureSelector.generationWeightInDimension(gen.dimensionWeights, d.provider) > 0), "Natural generation type won't accept any known dimensions");
        sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> gen.getActiveGenerationWeight() > 0, "Natural generation type has no weight");
        sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> gen.biomeExpression.test(b)), "Vanilla structure generation type won't accept any known biomes");
        sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> gen.getActiveWeight() > 0, "Vanilla structure generation type has no weight");
        sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> gen.minBaseLimit > 0 || gen.maxBaseLimit > 0 || gen.maxScaledLimit > 0 || gen.minScaledLimit > 0, "Vanilla structure is always limited to zero instances");
        sane &= addGenerationLog(commandSender, VanillaDecorationGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> StructureSelector.generationWeightInBiome(gen.biomeWeights, b) > 0), "Vanilla structure generation type won't accept any known biomes");
        sane &= addGenerationLog(commandSender, VanillaDecorationGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> StructureSelector.generationWeightInDimension(gen.dimensionWeights, d.provider) > 0), "Natural generation type won't accept any dimensions");
        sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> gen.getWeight() > 0, "Maze generation type has no weight");
        sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.getMazeID().trim().isEmpty(), "Maze generation type has maze id");
        sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.mazeComponent.rooms.isEmpty(), "Maze generation type has no rooms");
        sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.mazeComponent.exitPaths.isEmpty() || !gen.mazeComponent.defaultConnector.id.equals(ConnectorStrategy.DEFAULT_WALL), "Maze generation type has no walkable exits");
        sane &= addGenerationLog(commandSender, ListGeneration.class, (structure, gen) -> !gen.listID.trim().isEmpty(), "List generation has no list id");
        sane &= addGenerationLog(commandSender, ListGeneration.class, (structure, gen) -> gen.getWeight() > 0, "List generation has no weight");
        sane &= addGenerationLog(commandSender, SaplingGeneration.class, (structure, gen) -> gen.getActiveWeight() > 0, "Sapling generation has no weight");
        sane &= addGenerationLog(commandSender, StaticGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> gen.dimensionExpression.test(d.provider)), "Static generation won't accept any known dimensions");
    }
    if (sane && !parameters.has("silent"))
        commandSender.sendMessage(new TextComponentString("No problems identified!"));
}
Also used : Path(java.nio.file.Path) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) CommandSearchStructure(ivorius.reccomplex.commands.structure.CommandSearchStructure) ivorius.reccomplex.world.gen.feature.structure.generic.generation(ivorius.reccomplex.world.gen.feature.structure.generic.generation) Loader(net.minecraftforge.fml.common.Loader) PriorityQueue(java.util.PriorityQueue) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) RCConfig(ivorius.reccomplex.RCConfig) BiPredicate(java.util.function.BiPredicate) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) RCFiles(ivorius.reccomplex.files.RCFiles) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) StructureSelector(ivorius.reccomplex.world.gen.feature.selector.StructureSelector) Path(java.nio.file.Path) DimensionManager(net.minecraftforge.common.DimensionManager) Files(java.nio.file.Files) World(net.minecraft.world.World) IRegistry(net.minecraft.util.registry.IRegistry) CommandExpecting(ivorius.mcopts.commands.CommandExpecting) ConnectorStrategy(ivorius.reccomplex.world.gen.feature.structure.generic.maze.ConnectorStrategy) TextComponentString(net.minecraft.util.text.TextComponentString) Expect(ivorius.mcopts.commands.parameters.expect.Expect) Stream(java.util.stream.Stream) ICommandSender(net.minecraft.command.ICommandSender) ResourceLocation(net.minecraft.util.ResourceLocation) ModContainer(net.minecraftforge.fml.common.ModContainer) Parameters(ivorius.mcopts.commands.parameters.Parameters) Biome(net.minecraft.world.biome.Biome) Parameters(ivorius.mcopts.commands.parameters.Parameters) ModContainer(net.minecraftforge.fml.common.ModContainer) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString) ResourceLocation(net.minecraft.util.ResourceLocation) RCFiles(ivorius.reccomplex.files.RCFiles)

Example 5 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method planStructuresInChunk.

public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
    MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = NaturalGeneration.selectors(StructureRegistry.INSTANCE).get(biomeGen, world.provider);
    float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
    // TODO Use STRUCTURE_TRIES
    List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
    generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) NaturalStructureSelector(ivorius.reccomplex.world.gen.feature.selector.NaturalStructureSelector) StaticGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.StaticGeneration) Structures(ivorius.reccomplex.world.gen.feature.structure.Structures) Predicate(java.util.function.Predicate) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureSpawnContext(ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) Random(java.util.Random) RCConfig(ivorius.reccomplex.RCConfig) Collectors(java.util.stream.Collectors) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) MathHelper(net.minecraft.util.math.MathHelper) MixingStructureSelector(ivorius.reccomplex.world.gen.feature.selector.MixingStructureSelector) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) WorldServer(net.minecraft.world.WorldServer) IvVecMathHelper(ivorius.ivtoolkit.math.IvVecMathHelper) Biome(net.minecraft.world.biome.Biome) Nullable(javax.annotation.Nullable) ChunkPos(net.minecraft.util.math.ChunkPos) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)16 RCConfig (ivorius.reccomplex.RCConfig)7 StructureRegistry (ivorius.reccomplex.world.gen.feature.structure.StructureRegistry)7 BlockPos (net.minecraft.util.math.BlockPos)7 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)5 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)5 Nullable (javax.annotation.Nullable)5 WorldServer (net.minecraft.world.WorldServer)5 Parameters (ivorius.mcopts.commands.parameters.Parameters)4 Collectors (java.util.stream.Collectors)4 ChunkPos (net.minecraft.util.math.ChunkPos)4 World (net.minecraft.world.World)4 Pair (org.apache.commons.lang3.tuple.Pair)4 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)3 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)3 Expect (ivorius.mcopts.commands.parameters.expect.Expect)3 RCP (ivorius.reccomplex.commands.parameters.RCP)3 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)3 Nonnull (javax.annotation.Nonnull)3 CommandException (net.minecraft.command.CommandException)3