Search in sources :

Example 16 with GenericStructure

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

the class CommandConvertSchematic method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    EntityPlayerMP player = getCommandSenderAsPlayer(commandSender);
    if (args.length < 1)
        throw RecurrentComplex.translations.wrongUsageException("commands.rcconvertschematic.usage");
    ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
    String schematicName = parameters.get(0).require();
    String structureID = parameters.get("id").optional().orElse(schematicName);
    SchematicFile schematicFile = CommandImportSchematic.parseSchematic(schematicName);
    GenericStructure from = parameters.get("from").to(RCP::structureFromBlueprint, commandSender).require();
    from.worldDataCompound = CommandExportSchematic.toWorldData(schematicFile).createTagCompound();
    PacketEditStructureHandler.openEditStructure(player, from, player.getPosition(), structureID, directory);
}
Also used : SchematicFile(ivorius.reccomplex.world.gen.feature.structure.schematics.SchematicFile) Parameters(ivorius.mcopts.commands.parameters.Parameters) ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) RCP(ivorius.reccomplex.commands.parameters.RCP) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 17 with GenericStructure

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

the class CommandGenerateStructure method execute.

@Override
@ParametersAreNonnullByDefault
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    Parameters parameters = Parameters.of(args, expect()::declare);
    String structureID = parameters.get(0).require();
    Structure<?> structure = parameters.get(0).to(RCP::structure).require();
    WorldServer world = parameters.get("dimension").to(MCP.dimension(server, sender)).require();
    AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(null);
    GenerationType generationType = parameters.get("gen").to(RCP::generationType, structure).require();
    BlockSurfacePos pos = parameters.get(IvP.surfacePos("x", "z", sender.getPosition(), false)).require();
    String seed = parameters.get("seed").optional().orElseGet(() -> RandomStringUtils.randomAlphanumeric(20).toUpperCase());
    boolean suggest = parameters.has("suggest");
    Placer placer = generationType.placer();
    StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).generationInfo(generationType).seed(RCStrings.seed(seed)).structureID(structureID).randomPosition(pos, placer).fromCenter(true).maturity(suggest ? SUGGEST : FIRST).transform(transform);
    if (structure instanceof GenericStructure && world == sender.getEntityWorld()) {
        GenericStructure genericStructureInfo = (GenericStructure) structure;
        // noinspection unchecked
        if (!OperationRegistry.queueOperation(new OperationGenerateStructure(genericStructureInfo, generationType.id(), generator.transform(), generator.lowerCoord().orElse(null), false).withSeed(seed).withStructureID(structureID).prepare((Optional<GenericStructure.InstanceData>) generator.instanceData()), sender))
            return;
    } else {
        StructureGenerator.GenerationResult result = generator.generate();
        if (result instanceof StructureGenerator.GenerationResult.Failure) {
            String reason = ((StructureGenerator.GenerationResult.Failure) result).description;
            throw RecurrentComplex.translations.commandException("commands.strucGen.failure", reason);
        }
    }
    if (parameters.has("select"))
        RCCommands.select(sender, RCBlockAreas.from(generator.boundingBox().get()));
}
Also used : OperationGenerateStructure(ivorius.reccomplex.operation.OperationGenerateStructure) Parameters(ivorius.mcopts.commands.parameters.Parameters) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) Placer(ivorius.reccomplex.world.gen.feature.structure.Placer) WorldServer(net.minecraft.world.WorldServer) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 18 with GenericStructure

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

the class RCP method structureFromBlueprint.

public static Parameter<GenericStructure> structureFromBlueprint(Parameter<String> p, ICommandSender sender) {
    return genericStructure(p, true).map(GenericStructure::copyAsGenericStructure).orElseGet(() -> {
        GenericStructure structure = GenericStructure.createDefaultStructure();
        structure.metadata.authors = sender.getName();
        return structure;
    });
}
Also used : GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 19 with GenericStructure

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

the class WorldScriptHolder method generate.

@Override
public void generate(StructureSpawnContext context, RunTransformer transformer, NBTNone instanceData, BlockPos pos) {
    if (worldData == null) {
        return;
    }
    GenericStructure structure = new GenericStructure();
    structure.worldDataCompound = worldData.copy();
    int[] strucSize = structure.size();
    BlockPos strucCoord = context.transform.apply(origin, new int[] { 1, 1, 1 }).subtract(context.transform.apply(BlockPos.ORIGIN, strucSize)).add(pos);
    new StructureGenerator<>(structure).asChild(context).transformer(transformer).lowerCoord(strucCoord).generationPredicate(p -> !p.equals(pos)).generate();
    context.setBlock(pos, replaceState, 2);
}
Also used : RunTransformer(ivorius.reccomplex.world.gen.feature.structure.generic.transformers.RunTransformer) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) Blocks(net.minecraft.init.Blocks) StructureSpawnContext(ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext) TableDataSource(ivorius.reccomplex.gui.table.datasource.TableDataSource) TableDataSourceWorldScriptHolder(ivorius.reccomplex.gui.worldscripts.TableDataSourceWorldScriptHolder) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) NBTNone(ivorius.reccomplex.nbt.NBTNone) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nullable(javax.annotation.Nullable) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) StructureLoadContext(ivorius.reccomplex.world.gen.feature.structure.context.StructureLoadContext) StructurePrepareContext(ivorius.reccomplex.world.gen.feature.structure.context.StructurePrepareContext) NBTBase(net.minecraft.nbt.NBTBase) BlockPositions(ivorius.ivtoolkit.blocks.BlockPositions) BlockStates(ivorius.ivtoolkit.blocks.BlockStates) BlockPos(net.minecraft.util.math.BlockPos) MCRegistry(ivorius.ivtoolkit.tools.MCRegistry) TableNavigator(ivorius.reccomplex.gui.table.TableNavigator) IBlockState(net.minecraft.block.state.IBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) TableDelegate(ivorius.reccomplex.gui.table.TableDelegate) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Aggregations

GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)19 BlockPos (net.minecraft.util.math.BlockPos)7 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)6 StructureGenerator (ivorius.reccomplex.world.gen.feature.StructureGenerator)6 WorldServer (net.minecraft.world.WorldServer)6 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)5 Parameters (ivorius.mcopts.commands.parameters.Parameters)5 RCP (ivorius.reccomplex.commands.parameters.RCP)5 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 OperationGenerateStructure (ivorius.reccomplex.operation.OperationGenerateStructure)4 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)3 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)3 RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)3 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 BlockPositions (ivorius.ivtoolkit.blocks.BlockPositions)2 MockWorld (ivorius.ivtoolkit.world.MockWorld)2 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)2 ivorius.mcopts.commands.parameters (ivorius.mcopts.commands.parameters)2