use of ivorius.reccomplex.files.loading.ResourceDirectory 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.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.
the class PacketSaveInvGenComponentHandler method processServer.
@Override
public void processServer(PacketSaveInvGenComponent message, MessageContext ctx, WorldServer server) {
NetHandlerPlayServer playServer = ctx.getServerHandler();
EntityPlayerMP player = playServer.player;
if (RecurrentComplex.checkPerms(player))
return;
SaveDirectoryData.Result saveDirectoryDataResult = message.getSaveDirectoryDataResult();
String id = message.getKey();
ResourceDirectory saveDir = saveDirectoryDataResult.directory;
ResourceDirectory delDir = saveDir.opposite();
GenericItemCollectionRegistry.INSTANCE.register(id, "", message.getInventoryGenerator(), saveDir.isActive(), saveDir.getLevel());
if (RCCommands.informSaveResult((message.getInventoryGenerator() != null && id != null) && RecurrentComplex.saver.trySave(saveDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, saveDir, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id)) {
if (saveDirectoryDataResult.deleteOther)
RCCommands.informDeleteResult(RecurrentComplex.saver.tryDeleteWithID(delDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id, delDir);
ItemStack heldItem = playServer.player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem != null && heldItem.getItem() instanceof ItemInventoryGenComponentTag)
ItemInventoryGenComponentTag.setComponentKey(heldItem, id);
player.openContainer.detectAndSendChanges();
}
}
use of ivorius.reccomplex.files.loading.ResourceDirectory in project RecurrentComplex by Ivorforce.
the class CommandVisitFiles method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
ResourceDirectory directory = parameters.get("directory").to(RCP::resourceDirectory).optional().orElse(ResourceDirectory.ACTIVE);
OpenGlHelper.openFile(directory.toFile());
}
use of ivorius.reccomplex.files.loading.ResourceDirectory 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.files.loading.ResourceDirectory 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);
}
Aggregations