use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandMapAllStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args);
ResourceExpression expression = new ResourceExpression(StructureRegistry.INSTANCE::has);
IvOptional.ifAbsent(parameters.rc("exp").expression(expression).optional(), () -> expression.setExpression(""));
ResourceDirectory directory = parameters.rc("dir").resourceDirectory().optional().orElse(ResourceDirectory.ACTIVE);
CommandVirtual virtual = parameters.rc().virtualCommand(server).require();
int saved = 0, failed = 0, skipped = 0;
for (String id : StructureRegistry.INSTANCE.ids()) {
if (!expression.test(new RawResourceLocation(StructureRegistry.INSTANCE.status(id).getDomain(), id)))
continue;
Structure<?> info = StructureRegistry.INSTANCE.get(id);
if (!(info instanceof GenericStructure)) {
skipped++;
continue;
}
GenericStructure structure = (GenericStructure) info;
IvWorldData worldData = structure.constructWorldData();
MockWorld world = new MockWorld.WorldData(worldData);
try {
virtual.execute(world, new CommandSelecting.SelectingSender(commandSender, BlockPos.ORIGIN, worldData.blockCollection.area().getHigherCorner()), parameters.get().move(1).varargs());
} catch (MockWorld.VirtualWorldException ex) {
throw ServerTranslations.commandException("commands.rcmap.nonvirtual.arguments");
}
structure.worldDataCompound = worldData.createTagCompound();
if (PacketSaveStructureHandler.write(commandSender, structure, id, directory, true, false))
saved++;
else
failed++;
}
commandSender.sendMessage(ServerTranslations.format("commands.rcmapall.result", saved, RCTextStyle.path(directory), failed, skipped));
RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.CUSTOM);
RCCommands.tryReload(RecurrentComplex.loader, LeveledRegistry.Level.SERVER);
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandExportStructure method getNewGenericStructure.
public static GenericStructure getNewGenericStructure(ICommandSender commandSender, RCParameter parameter) throws CommandException {
GenericStructure genericStructureInfo;
if (parameter.has(1)) {
genericStructureInfo = parameter.genericStructure().require();
} else {
genericStructureInfo = GenericStructure.createDefaultStructure();
genericStructureInfo.metadata.authors = commandSender.getName();
}
return genericStructureInfo;
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandSelectDuplicate method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "mirror");
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
BlockArea area = selectionOwner.getSelection();
BlockPos pos = parameters.pos("x", "y", "z", commandSender.getPosition(), false).require();
AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(AxisAlignedTransform2D.ORIGINAL);
IvWorldData worldData = IvWorldData.capture(commandSender.getEntityWorld(), area, true);
NBTTagCompound worldDataCompound = worldData.createTagCompound();
GenericStructure structureInfo = GenericStructure.createDefaultStructure();
structureInfo.worldDataCompound = worldDataCompound;
OperationRegistry.queueOperation(new OperationGenerateStructure(structureInfo, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld()), commandSender);
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandSelectMove method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
BlockPos move = parameters.get(RCP.pos("x", "y", "z", BlockPos.ORIGIN, false)).require();
AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(AxisAlignedTransform2D.ORIGINAL);
boolean noselect = parameters.has("noselect");
boolean duplicate = parameters.has("duplicate");
int times = parameters.get("times").to(NaP::asInt).optional().orElse(1);
BlockArea area = selectionOwner.getSelection();
IvWorldData worldData = IvWorldData.capture(commandSender.getEntityWorld(), area, true);
NBTTagCompound worldDataCompound = worldData.createTagCompound();
GenericStructure structure = GenericStructure.createDefaultStructure();
structure.worldDataCompound = worldDataCompound;
BlockPos pos = selectionOwner.getSelection().getLowerCorner();
for (int i = 0; i < times; i++) {
pos = pos.add(move);
if (duplicate)
OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld()), commandSender);
else
OperationRegistry.queueOperation(new OperationMulti(new OperationClearArea(area), new OperationGenerateStructure(structure, null, transform, pos, true).prepare((WorldServer) commandSender.getEntityWorld())), commandSender);
}
if (!noselect) {
StructureGenerator<GenericStructure.InstanceData> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
// noinspection OptionalGetWithoutIsPresent
StructureBoundingBox boundingBox = generator.boundingBox().get();
selectionOwner.setSelection(RCBlockAreas.from(boundingBox));
}
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandPaste method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(sender);
RCEntityInfo entityInfo = RCCommands.getStructureEntityInfo(entityPlayerMP, null);
NBTTagCompound worldData = entityInfo.getWorldDataClipboard();
if (worldData == null)
throw RecurrentComplex.translations.commandException("commands.strucPaste.noClipboard");
WorldServer world = (WorldServer) sender.getEntityWorld();
BlockPos pos = parameters.get(MCP.pos("x", "y", "z", sender.getPosition(), false)).require();
AxisAlignedTransform2D transform = parameters.get(IvP.transform("rotation", "mirror")).optional().orElse(AxisAlignedTransform2D.ORIGINAL);
String seed = parameters.get("seed").optional().orElse(null);
boolean generate = parameters.has("generate");
GenericStructure structure = GenericStructure.createDefaultStructure();
structure.worldDataCompound = worldData;
// TODO Generate with generation info?
OperationRegistry.queueOperation(new OperationGenerateStructure(structure, null, transform, pos, !generate).withSeed(seed).prepare(world), sender);
if (parameters.has("select")) {
StructureGenerator<?> generator = new StructureGenerator<>(structure).transform(transform).lowerCoord(pos);
// Can never not place so don't handle
// noinspection OptionalGetWithoutIsPresent
RCCommands.select(sender, RCBlockAreas.from(generator.boundingBox().get()));
}
}
Aggregations