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);
}
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()));
}
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;
});
}
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);
}
Aggregations