Skip to content

Commit

Permalink
make default watch script not watch model files
Browse files Browse the repository at this point in the history
- its kinda janky
- add script to still watch models as well with `yarn start watch.experimental`
- update readme accordingly
  • Loading branch information
TheAfroOfDoom committed Jan 27, 2024
1 parent 5cdd1d8 commit dfd1a56
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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(
Expand Down
7 changes: 6 additions & 1 deletion package-scripts/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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();

0 comments on commit dfd1a56

Please sign in to comment.