deathcap / artpacks

cascading texture/sound artwork pack loader
http://deathcap.github.io/artpacks/
7 stars 3 forks source link

Indirect texture loading support (model definitions) #16

Open deathcap opened 8 years ago

deathcap commented 8 years ago

Currently, the API provided by this module returns a texture given its name (artpacks.getTexture('crafting_table_top'), etc.). Plugins which add blocks have their own list of textures for each of the cube sides, for example voxel-workbench:

      @registry.registerBlock 'workbench', {texture: ['crafting_table_top', 'planks_oak', 'crafting_table_side'], onInteract: () =>

This knowledge could be better abstracted away and factored out into artpacks, so it can be changed by the user in customized art packs (also dovetails nicely with non-cubic block texture support).

The resource pack format used by Minecraft has JSON definitions, models/block/crafting_table.json defines (https://github.com/vogonistic/mineflayer-voxel/pull/1#issuecomment-170300198):

{
    "parent": "block/cube",
    "textures": {
        "particle": "blocks/crafting_table_front",
        "down": "blocks/planks_oak",
        "up": "blocks/crafting_table_top",
        "north": "blocks/crafting_table_front",
        "east": "blocks/crafting_table_side",
        "south": "blocks/crafting_table_side",
        "west": "blocks/crafting_table_front"
    }
}

In addition to recognizing the .png and .mcmeta files, artpacks could also read the .json block models (see also: arbitrary model definitions to WebGL: https://github.com/deathcap/block-models; down/up/north/east/south/west to cube-side-array faces) and supply a getBlockTextures() (or whatever) API. The implementation in voxel-workbench would only have to say the block model is "crafting_table", and then it would be textured dynamically appropriately. Consider how to fit into https://github.com/voxel/voxel-stitch, which reads texture names from voxel-registry and texture data from artpacks.

deathcap commented 8 years ago

This would very useful for items in voxel-clientmc (https://github.com/voxel/voxel-clientmc/pull/26), where the item name -> item texture mapping is non-obvious (wheat_seeds is items/seeds_wheat). Relevant: minecraft-data images https://github.com/PrismarineJS/minecraft-data/issues/78