An automatic resource creation tool for Minecraft 1.13+ Forge modding
Project description
Minecraft Resource Generator
This is a python module aimed to enable simple generation of the many json files that are required for forge modding.
Version History
This tool will be updated to support the latest version of minecraft as soon as possible. For now, the latest version of this tool available for past versions of Minecraft can be found below:
- Minecraft 1.14.x - 1.15.x: Latest
- Minecraft 1.13.x: v0.0.2
Note that unless the minecraft data format changes between versions, this tool will still work on older versions of minecraft.
Usage
mcresources can build many common files that are required for forge modding, and provide utilities to manage a larger project. The following is an outline of the various methods and how to use them in the most efficient manner.
All files generated by mcresources will have a comment ('__comment__') inserted to identify them. This also allows mcresources via the usage of clean_generated_resources() to delete all files that have been generated, allowing the user to see which ones are created manually, and/or manage updating older files to a newer configuration
A few elements are common to multiple methods:
-
name_parts: This represents the resource location for a specific block or item. It can be specified as a string, i.e.'block_ruby_ore', or as a list or tuple if the block uses directories as separators. This means that('ore_blocks', 'ruby')corresponds to the resource locationmodid:ore_blocks/ruby, and the resulting fileruby.jsonwould be found inmodid/blockstates/ore_blocks/. An optional domain can also be specified (minecraft:stone), which will override theResourceManagers domain if nessecary. -
conditions: A single condition can either be specified as a fully specified dictionary (which will be inserted into the json verbatim), or as a string, which will be expanded to{ 'type': string_condition } -
item stacks: An item stack can be specified as a fully specified dictionary (which will be inserted into the json verbatim), or as a string. As a string, it must represent an item resource location, i.e.minecraft:golden_bootswill create the json{ 'item': 'minecraft:golden_boots' }. Additionally, you can prefix the string withtag!to specify that it represents a tag, i.e.tag!forge:rods/woodenwill create the json{ 'tag': 'forge:rods/wooden' }
Contexts
New as of v1.1.0: When calling various ResourceManager methods, they will often return a context object, one of BlockContext, ItemContext, or RecipeContext. This object can be used as a shortcut to add other files for a single block or item, for instance, adding a blockstate, model, item block model, and loot table with only specifying the name once:
rm.blockstate(...).with_item_block_model(...).with_block_model(...)
Contexts can also be obtained directly by calling block(name_parts), or item(name_parts).
In addition, this delegated behavior has been expanded to tags. Tags no longer create single files every time the relevant tag method is called. Instead, they accumulate tag entries in a buffer, allowing multiple tag calls to append entries to a single tag.
In order to finalize tag (and lang / translation) entries, a call to ResourceManager#flush is necessary, which will clear the current buffer for tags and translation entries and write all relevant files.
Factory Methods
For common minecraft block models (slabs, stairs, etc.), there are a number of factory methods which can be used to produce vanilla style blockstates and models for a single block. These make standard assumptions about the parent block's textures and state properties. Currently, there are the following:
make_slab()
- Generates a slab blockstate, along with
_slaband_slab_topmodels, and item model.
make_stairs()
- Generates a stairs blockstate, along with
_stairs,_stairs_inner, and_stairs_outermodels, and item model.
make_fence()
- Generates a fence multipart blockstate, along with
_fence_postand_fence_sidemodels and item model.
make_fence_gate()
- Generates a fence gate blockstate, along with
_fence_gate,_fence_gate_open,_fence_gate_wall, and_fence_gate_wall_openmodels, and item model.
Resource Generators
Blockstates
blockstate(name_parts, model = None, variants = None, use_default_model = True)
name_partsspecifies the block resource location, as seen abovemodelspecifies the model. If not present, it will default tomodid:block/name/parts, meaningblockstate('pink_grass')will create the filemodid/blockstates/pink_grass.json, which has a model ofmodid:block/pink_grassvariantsspecifies the variants as found in the json file. It should be a dictionary as per usual minecraft blockstate files. If it isn't present, it will default to an empty / single variant block:'variants': { '': model }. If present, each variant that does not specify a model will take the default model, unlessuse_default_modelis false.
blockstate_multipart(name_parts, parts)
name_partsspecifies the block resource location, as seen abovepartsspecifies the parts. It must be a sequence of part elements. Each part element can be a dictionary (which will be expanded as{'apply': part}), or a pair of awhenandapplydata, which will be expanded as{'when': part[0], 'apply': part[1]}
Block Models
block_model(name_parts, textures = None, parent = 'block/cube_all')
name_partsspecifies the block resource location, as seen abovetexturesspecifies the textures for this specific model. If it is a string, it will create the json:'textures': { 'texture': textures }. If provided as a dictionary, it will insert'textures': texturesparentspecifies the parent model file
Item Models
item_model(name_parts, textures, parent = 'item/generated', no_textures = False)
name_partsspecifies the item resource location, as seen abovetexturesspecifies the textures. If textures are supplied as strings, i.e.'base_layer', 'middle_layer' ..., it will assign them sequentially to layers, i.e.{ 'layer0': 'base_layer', 'layer1': 'middle_layer' ... }. If a dictionary is provided, it will insert those in the same way as the block modelparentspecifies the parent model fileno_textures, if true, will cause the model to have no textures element
Shapeless Crafting Recipes
crafting_shapeless(name_parts, ingredients, result, group = None, conditions = None)
name_partsspecifies the recipe resource location. Note crafting recipes are automatically added tomodid/data/recipesinredientsspecifies the ingredients. It must be either a list / tuple of item stacks, or a string or dictionary representing an item stack. See above for valid item stack specifications.resultspecifies the recipe result or output. It must be a single item stackgroupspecifies the group the recipe belongs toconditionsspecifies any conditions on the recipe being enabled. It must be a list / tuple of valid condition identifiers, or a string or dictionary representing an item stack
Shaped Crafting Recipes
crafting_shaped(name_parts, pattern, ingredients, result, group = None, conditions = None)
name_partsspecifies the recipe resource location. Note crafting recipes are automatically added tomodid/data/recipespatternspecifies the pattern. It must be a list of strings, i.e.['XXX', ' S ', ' S ']for a pickaxe pattern. The keys must be the same as used in the ingredients field.inredientsspecifies the ingredients. It can be a dictionary of single character keys to item stacks, or it can be a single item stack (which will default to the first key found, and as such should only be used if there is only one unique input)resultspecifies the recipe result or output. It must be a single item stackgroupis as aboveconditionsis as above
Other Recipes or Data
recipe(name_parts, type_in, data_in, group, conditions = None)
data(name_parts, data_in)
This is used to create modded recipes that are loaded via custom deserializers. As such, name_parts needs to include a subdirectory for the recipe type
name_partsspecifies the recipe resource location.type_inspecifies the recipe typedata_inspecifies the json data to be inserted into the recipegroupis as aboveconditionsis as above
Tags
item_tag(name_parts, *values, replace = False)
block_tag(name_parts, *values, replace = False)
fluid_tag(name_parts, *values, replace = False)
entity_tag(name_parts, *values, replace = False)
These are used to create item and block tags respectively
name_partsspecifies the tag resource location, as seen abovevaluesspecifies the values. It can be a single string for one value, or a list / tuple of strings for multiple valuesreplacespecifies the replace field in the json, i.e. if the tag should replace a previous identical entry
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcresources-1.2.1.tar.gz.
File metadata
- Download URL: mcresources-1.2.1.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b4813fe9f6f42e0dfc5ae155615f24ae1d9fcc3c98b065fd53ac7c7677d63ab
|
|
| MD5 |
af04a4c02e055948e3a452f31e75ef59
|
|
| BLAKE2b-256 |
6e49a1cb677749fc40f970a90b1f83873c858846c48830aa90add08470cee28c
|
File details
Details for the file mcresources-1.2.1-py3-none-any.whl.
File metadata
- Download URL: mcresources-1.2.1-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6c580f2da3cc27f41f246faf1a1714b0ce2794d63374ec0ed0bf577c9dc3f56
|
|
| MD5 |
1c1f6c1f3e4b9f6988473889895cf9db
|
|
| BLAKE2b-256 |
9539e499987cd1422650854dfdae50b1c3da8e622b97b765ca32202c286b5013
|