Skip to main content

A Python Data Generator for Minecraft 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 Minecraft modding.

Pack Format

Updates of this tool will track the latest pack format (pack_format in a resource pack) as soon as possible. In order to generate resources compliant with a specific pack format, the latest version can be found below

Pack Format Minimum Minecraft Version Latest mcresources Version
8 1.18 Latest
7 1.17 1.4.6
6 1.16.2 1.4.6
5 1.15 1.3.3
4 1.13 0.0.2

Usage

mcresources can build many common files that are required for modding, and provide utilities to manage a larger project. The following is an outline of the various methods. More detail can be found in the documentation comments of each individual method or module.

To get started, the following imports are available from mcresources:

  • ResourceManager: A class to manage creation of resources.
  • loot_tables: A series of helper functions for building loot tables.
  • surface_rules: A series of helper functions for building surface rules.
  • utils: A series of utility functions.

Resource Manager

ResourceManager is a class which has methods to generate both vanilla Minecraft data files, and methods to generate entirely custom data files. The design of these data generators is intended to both allow the full range of generated data, and also make the most common operations the most simple. For example, generating a loot table for a block with a standard loot drop, of the block itself, can be inferred from the single call:

rm.block_loot('my_block', 'modid:my_block')

However, block_loot also supports generating loot tables with multiple pools, entries, conditions, or functions as desired for more uncommon or complex use cases.

ResourceManager exposes the following resource methods:

Assets

  • blockstate(): Generates blockstate assets with a variants key
  • blockstate_multipart(): Generates blockstate assets using the multipart blockstate style.
  • block_model(): Generates block model files, either with textures or elements.
  • custom_block_model(): Generates block models for use with custom Forge model loaders.
  • item_model(): Generates item model files.
  • custom_item_model(): Generates item models for use with custom Forge model loaders.
  • lang(): Adds translation keys to an internal buffer. To write all language files, call ResourceManager.flush()

Data

  • crafting_shapeless(): Generates a shapeless crafting recipe
  • crafting_shaped(): Generates a shaped crafting recipe
  • recipe(): Generates an arbitrary custom recipe type, for use in generating mod recipes.
  • advancement(): Generates a custom advancement.
  • item_tag(), block_tag(), entity_tag(), fluid_tag(): Generates custom tags. These do not write files upon call, and instead accumulate tags in an internal buffer. To write all buffered tags, call ResourceManager.flush()
  • block_loot: Generates loot tables for blocks.
  • data(): Generates a custom data file for datapacks.

World Generation

  • dimension(): Generates a world generation dimension, with an arbitrary generator.
  • dimension_type(): Generates a world generation dimension type with all vanilla parameters supported.
  • biome(): Generates a world generation biome with all vanilla parameters supported.
  • configured_carver(): Generates a configured carver.
  • configured_feature(): Generates a configured feature.
  • configured_structure_feature(): Generates a configured structure.
  • placed_feature: Generates a placed feature, from a feature and a list of placements.
  • noise: Generates a world generation noise definition.
  • noise_settings: Generates a world generation noise settings. In order to build surface rules, see surface_rules
  • processor_list: Generates a processor list.
  • template_pool: Generates a template pool.

Misc

  • block(): Creates a named BlockContext
  • item(): Creates a named ItemContext
  • write(): Writes an arbitrary data file.

All files generated by mcresources will have a comment ('__comment__') inserted to identify them. This also allows mcresources via the usage of utils.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

Contexts

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(), or item().

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:

All of these methods take the form of a make_[block type] method that can be invoked on a BlockContext. For instance,

rm.block('myblock').make_slab()

These create the required block state, block and item models, adhering to vanilla style naming conventions and using vanilla base models. Thus adding standard block assets for wood or stone variants can be done simply.

The following methods are available:

  • make_slab()
  • make_stairs()
  • make_fence()
  • make_fence_gate()
  • make_wall()
  • make_door()
  • make_trapdoor()
  • make_button()
  • make_pressure_plate()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcresources-1.5.7.tar.gz (23.0 kB view hashes)

Uploaded Source

Built Distribution

mcresources-1.5.7-py3-none-any.whl (25.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page