Animated-Java / animated-java

A Blockbench plugin that makes complex animation a breeze in Minecraft: Java Edition.
Other
159 stars 26 forks source link

[FR] Expose `exportProject` method to API #195

Closed TheAfroOfDoom closed 3 months ago

TheAfroOfDoom commented 3 months ago

Is your feature request related to a problem? Please describe. I have some tooling setup for my map's repository so I only need to commit changes to the model source file (.ajmodel / .ajblueprint). I can safely .gitignore AJ's exported files to minimize diffs and headache while committing.

To support this workflow in AJ v0, my team created a fork of AJ that exposed the safeExportProject method to the API. This allowed us to create a tool that enabled the following behavior:

  1. Run yarn start export in terminal
  2. Blockbench is automatically opened and runs a script that opens each .ajmodel in the repo and calls safeExportProject
  3. Blockbench closes
  4. Your local repo now has AJ export files

Describe the solution you'd like Expose a function to AJ's API that, when called, exports the currently-open Blockbench project as-is. exportProject is the specific method I want exposed.

Describe alternatives you've considered N/A

Additional context N/A

SnaveSutit commented 3 months ago

18d3631 should solve your issue, let me know if it doesn't.

TheAfroOfDoom commented 3 months ago

@SnaveSutit that commit is working after i make some minor changes to adjust to the new blueprint format, so that's good!

but it looks like when i load a "fake model" into blockbench and export it, it saves the file now? this is a change in behavior from AJ v0


basically we:

  1. parse the model file
  2. replace properties specific to one user's paths (e.g. the resourcepack directory path)
  3. load that model into blockbench with loadModelFile()
  4. run AJ's exportProject

haven't looked into exactly what's saving that loaded file to disk on export, but i'm guessing it's related to the new meta.save_location property. is this intentional/required behavior?

TheAfroOfDoom commented 3 months ago

(this is definitely an issue that's specific to my project that is totally fair if you deem i'll just have to find a work-around somehow, but:)

this .ajblueprint file saving after the exporter runs is new. you can see the properties i injected during runtime to the model in memory (NOT to the model on disk)

image

TheAfroOfDoom commented 3 months ago

found it 😭 https://github.com/Animated-Java/animated-java/blob/5f77e264eb75aaf061d09ae1d05c14de89436f62/src/systems/exporter.ts#L91

SnaveSutit commented 3 months ago

I've added an optional argument that allows you to disable the forced save.

TheAfroOfDoom commented 3 months ago

my hero