Skip to content

Commit

Permalink
paths list -> obj
Browse files Browse the repository at this point in the history
  • Loading branch information
aidant19 committed Jan 10, 2024
1 parent 3cc0b74 commit 2e52c93
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/ajexport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ if (typeof AnimatedJava === 'undefined') {
const paths = getConfigPaths(
'C:\\Users\\Aidan\\Documents\\Media_Storage\\active_projects\\flowey_remaster\\omega-flowey-minecraft-remastered\\scripts\\config.json',
);
const dir = paths[3].concat('/');
const model_dir = paths.ajmodelPath.concat('/');
console.log('Target paths: ', paths);
const files = readdirSync(dir).filter((file) => file.includes('ajmodel'));
const files = readdirSync(model_dir).filter((file) => file.includes('ajmodel'));
const exportNextFile = () => {
if (Project) {
Project.close();
Expand All @@ -30,7 +30,7 @@ const exportNextFile = () => {
}
consoleLogJson({ file });
if (file.includes('ajmodel')) {
const content = readFileSync(dir.concat(file), 'utf-8');
const content = readFileSync(model_dir.concat(file), 'utf-8');
const name = file.split('/').pop();
const fileObj = {
path: file,
Expand All @@ -45,19 +45,19 @@ exportNextFile();

function injectModelPackPaths(modelContent, paths) {
const f = JSON.parse(modelContent);
f.animated_java.settings.resource_pack_mcmeta = paths[0];
f.animated_java.settings.resource_pack_mcmeta = paths.resourcePackPath;
f.animated_java.exporter_settings[
'animated_java:datapack_exporter'
].datapack_mcmeta = paths[1];
].datapack_mcmeta = paths.dataPackPath;
for (const texture of f.textures) {
texture.path = texture.path.replaceAll('\\', '/');
if (texture.path.includes('.minecraft')) {
const x = texture.path.split('assets')[1];
const newPath = `${paths[2]}/assets${x}`;
const newPath = `${paths.assetsPath}/assets${x}`;
texture.path = newPath;
} else if (texture.path.includes('resourcepack/assets')) {
const x = texture.path.split('resourcepack/assets')[1];
const resourcePackBase = paths[0].split('resourcepack')[0];
const resourcePackBase = paths.resourcePackPath.split('resourcepack')[0];
const newPath = `${resourcePackBase}resourcepack/assets${x}`;
texture.path = newPath;
}
Expand All @@ -71,5 +71,5 @@ function getConfigPaths(configFile) {
const dataPackPath = f.datapack_mcmeta;
const assetsPath = f.assets_path;
const ajmodelPath = f.ajmodel_folder;
return [resourcePackPath, dataPackPath, assetsPath, ajmodelPath];
return { resourcePackPath, dataPackPath, assetsPath, ajmodelPath };
}

0 comments on commit 2e52c93

Please sign in to comment.