use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandEditStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
EntityPlayerMP entityPlayerMP = getCommandSenderAsPlayer(commandSender);
Parameters parameters = Parameters.of(args, expect()::declare);
ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
String structureID = parameters.get("id").optional().orElse(parameters.get(0).require());
GenericStructure base = parameters.get(0).to(p -> RCP.genericStructure(p, false)).require();
GenericStructure from = parameters.get("from").to(p -> RCP.genericStructure(p, false)).optional().orElse(base);
if (base != from) {
from = from.copyAsGenericStructure();
from.worldDataCompound = base.worldDataCompound.copy();
}
PacketEditStructureHandler.openEditStructure(entityPlayerMP, from, entityPlayerMP.getPosition(), structureID, directory);
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandExportStructure 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);
ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(null);
String structureID = parameters.get("id").optional().orElse(parameters.get(0).optional().orElse(null));
GenericStructure from = parameters.get(0).to(RCP::structureFromBlueprint, commandSender).require();
SelectionOwner selectionOwner = RCCommands.getSelectionOwner(commandSender, null, true);
RCCommands.assertSize(commandSender, selectionOwner);
from.worldDataCompound = IvWorldData.capture(commandSender.getEntityWorld(), selectionOwner.getSelection(), true).createTagCompound();
PacketEditStructureHandler.openEditStructure(player, from, selectionOwner.getSelection().getLowerCorner(), structureID, directory);
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandImportStructure method execute.
@Override
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(AxisAlignedTransform2D.ORIGINAL);
BlockPos pos = parameters.get(MCP.pos("x", "y", "z", sender.getPosition(), false)).require();
StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).transform(transform).lowerCoord(pos).asSource(true);
// Can never not place so don't handle
// noinspection OptionalGetWithoutIsPresent
StructureBoundingBox boundingBox = generator.boundingBox().get();
if (structure instanceof GenericStructure && world == sender.getEntityWorld())
OperationRegistry.queueOperation(new OperationGenerateStructure((GenericStructure) structure, structureID, transform, pos, true).withStructureID(structureID).prepare(world), sender);
else
generator.generate();
if (parameters.has("select"))
RCCommands.select(sender, RCBlockAreas.from(boundingBox));
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandLookupStructure method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
String id = parameters.get(0).require();
GenericStructure structure = parameters.get(0).to(p -> RCP.genericStructure(p, false)).require();
Metadata metadata = structure.metadata;
boolean hasWeblink = !metadata.weblink.trim().isEmpty();
ITextComponent weblink = hasWeblink ? new TextComponentString(RCStrings.abbreviateFormatted(metadata.weblink, 30)) : RecurrentComplex.translations.format("commands.rclookup.reply.nolink");
if (hasWeblink) {
weblink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, metadata.weblink));
weblink.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(metadata.weblink)));
}
ITextComponent level = new TextComponentString(StructureRegistry.INSTANCE.status(id).getLevel().toString());
level.getStyle().setColor(TextFormatting.YELLOW);
commandSender.sendMessage(RecurrentComplex.translations.format(StructureRegistry.INSTANCE.hasActive(id) ? "commands.rclookup.reply.generates" : "commands.rclookup.reply.silent", id, RCTextStyle.users(metadata.authors), level, weblink));
if (!metadata.comment.trim().isEmpty())
commandSender.sendMessage(RecurrentComplex.translations.format("commands.rclookup.reply.comment", metadata.comment));
}
use of ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure in project RecurrentComplex by Ivorforce.
the class CommandMapStructure method map.
@Nonnull
public static MapResult map(String structureID, @Nullable ResourceDirectory directory, ICommandSender commandSender, CommandVirtual command, String[] args, boolean inform) throws CommandException {
GenericStructure structure = Parameter.makeUp(null, 0, structureID).to(RCP::structure).require().copyAsGenericStructure();
if (structure == null) {
if (inform)
throw RecurrentComplex.translations.commandException("commands.structure.notGeneric", structureID);
return MapResult.SKIPPED;
}
IvWorldData worldData = structure.constructWorldData();
MockWorld world = new MockWorld.WorldData(worldData);
try {
command.execute(world, new SelectingSender(commandSender, BlockPos.ORIGIN, worldData.blockCollection.area().getHigherCorner()), args);
} catch (MockWorld.VirtualWorldException ex) {
throw RecurrentComplex.translations.commandException("commands.rcmap.nonvirtual.arguments");
}
structure.worldDataCompound = worldData.createTagCompound();
if (directory == null)
return MapResult.SUCCESS;
return PacketSaveStructureHandler.write(commandSender, structure, structureID, directory, true, inform) ? MapResult.SUCCESS : MapResult.FAILED;
}
Aggregations