diff --git a/README.md b/README.md index de5824072..9d8860edc 100644 --- a/README.md +++ b/README.md @@ -83,19 +83,24 @@ We also recommend using [blockcolors.app](https://blockcolors.app/) to get a rep Read the descriptions of the following scripts and run them when it is recommended to: -1. `yarn start`: this does two important things: +1. `yarn start export`: run the AJ model export script - 1. keeps your local repository's content synced with your `.minecraft` directory -- datapack/resourcepack changes will reflect in-game - 2. watches `.ajmodel` files and runs our auto-exporter on them -- this reads all `.ajmodel` files in your local repo and runs Animated Java's `Export Project` function on them. + 1. add `ELECTRON_ENABLE_LOGGING=1` to your `.env` file to enable log-passthrough from Blockbench's renderer process to the main process. **Run this if your `watch.models` script (from `yarn start watch.experimental`) runs into an error while exporting AJ models.** + + We recommend running `yarn start export` at least once, and every time changes to `.ajmodel` files occur from new incoming commits. + +2. `yarn start`: this keeps your local repository's content synced with your `.minecraft` directory -- datapack/resourcepack changes will reflect in-game + + 1. if you run `yarn start watch.experimental`, it also watches `.ajmodel` files and runs our auto-exporter on them -- this reads all `.ajmodel` files in your local repo and runs Animated Java's `Export Project` function on them. 1. we specifically _do not_ commit AJ's exported files to the repo since they are _very large_ 2. the `watch.models` script _will not_ work if you already have Blockbench open, so don't expect it to do anything while that's the case + 3. its a little janky and experimental still, so \*\*we recommend manually running `yarn start export` if you run into issues relating to Animated Java export files (missing models, animations, attacks not playing properly) We recommend keeping `yarn start` running at all times while working on the project. -2. `yarn sync`: zips your Minecraft world and copies it to the repo as (`world.zip`). This is how we handle version-control for the actual Minecraft world. This is especially important to run and commit if you make any _physical changes_ to the world like breaking/placing blocks. -3. `yarn lint`: runs Prettier, ESLint, and our custom linting rules on our files. Run this prior to pushing commits to save on our workflow hours. -4. `yarn start export`: manually run the AJ model export script - 1. add `ELECTRON_ENABLE_LOGGING=1` to your `.env` file to enable log-passthrough from Blockbench's renderer process to the main process. **Run this if your `watch.models` script (from `yarn start`) runs into an error while exporting AJ models.** +3. `yarn sync`: zips your Minecraft world and copies it to the repo as (`world.zip`). This is how we handle version-control for the actual Minecraft world. This is especially important to run and commit if you make any _physical changes_ to the world like breaking/placing blocks. + +4. `yarn lint`: runs Prettier, ESLint, and our custom linting rules on our files. Run this prior to pushing commits to save on our workflow hours. #### Adding a new model/animation diff --git a/package-scripts.js b/package-scripts.js index 0682ea821..d6e111882 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -25,7 +25,9 @@ const worldName = process.env.WORLD_NAME; const minecraftWorldPath = `${minecraftPath}/saves/${worldName}`; +// we have to resolve this path so we can use it with Blockbench const ajexportScriptPath = resolve('./package-scripts/modules/ajexport.js'); +const watchScriptPath = './package-scripts/watch.js'; const allAnimatedJavaExportFiles = [ 'datapacks/animated_java/data', @@ -40,7 +42,10 @@ const allAnimatedJavaExportFiles = [ module.exports = { scripts: { default: 'nps watch', - watch: 'node ./package-scripts/watch', + watch: { + default: `node ${watchScriptPath}`, + experimental: `node ${watchScriptPath} --experimental`, + }, sync: { default: 'nps sync.world', world: series( diff --git a/package-scripts/watch.js b/package-scripts/watch.js index e3239a5af..104ff5ad2 100644 --- a/package-scripts/watch.js +++ b/package-scripts/watch.js @@ -5,6 +5,7 @@ const findProcess = require('find-process'); const { copy, remove, readFile, writeFile } = require('fs-extra'); const { glob } = require('glob'); const { difference, findKey, uniq } = require('lodash'); +const minimist = require('minimist'); const { spawn } = require('node:child_process'); const { resolve, parse } = require('path'); @@ -427,12 +428,16 @@ const deleteStaleExportFiles = async () => { }; const main = async () => { + const argv = minimist(process.argv.slice(2)); + await deleteStaleExportFiles(); const SHOW_VERBOSE = false; watchDatapacks(SHOW_VERBOSE); watchResourcepack(SHOW_VERBOSE); - watchModels(); + if (argv.experimental) { + watchModels(); + } }; main();