Voxelum / minecraft-launcher-core-node

Provide packages to install Minecraft, launch Minecraft and more to build launcher with NodeJs/Electron!
https://docs.xmcl.app/en/core/
MIT License
174 stars 25 forks source link

@xmcl/resourcepack - New features (including a "minor" breaking change) #252

Closed John-Dean closed 1 year ago

John-Dean commented 1 year ago

I've done this as 3 independent commits which, in chronological order, do the following:

Commit 1:

Restructured resourcePack.ts's ResourceLocation class to have more outputs as follows:

  • Addition of ofItemModelPath and ofBlockStatePath functions that were missing
  • Change to all of... functions to use a standardized function (deconstruct) instead of repeated code
  • Change to all of... functions inputs to both accept string and ResourceLocation types (Non-breaking change)

Commit 2:

Reworked modelLoader.ts's new ModelLoader().loadModel to:

  • Additional argument: folder
    • defaults to blocks to make this a non-breaking change (mimics existing functionality)
    • allows you to instead use items for item models (for example shown in item frames)
  • Change to variable names to be clearer (parentModel and baseModel)

Commit 3:

  • ❗[Breaking change] Rework to the cache (.models) to instead use resourceLocation.toString() (instead of modelPath)
    • This makes more sense, as different modelPath inputs could resolve to the same model, but resourceLocation.toString() is unique
    • I can find no references to the cache within the code, so this shouldn't break anything within the library
    • Moved the point where items are added to the cache to after the textures are loaded to prevent any potential issues
  • Where a .models cache item is present it is now returned instead of re-loading the resource