Skip to main content

Use block features instead of block IDs! (for Minecraft shaderpacks)

Project description

Block Wrangler

A Python library to help Minecraft shader developers deal with block IDs.

It allows shader developers to define "flags" that block states can have, and the script will generate both a block.properties file and corresponding GLSL functions to allow those flags to be used directly in shaders.

It includes all Vanilla blocks and tags, as well as a few custom categories that are commonly used in shaders, and automatically enforces that numerical block IDs are both complete and mutually exclusive.

Installation

pip install block-wrangler

Usage

Below is a simple example of how to use the library. More complete documentation is coming soon.

from block_wrangler import *
from pathlib import Path


shaderpack_root = Path(__file__).parent

def main():
	tags = load_tags()

	mapping = BlockMapping.solve({
		'sway': tags['sway'],
		'sway_bottom': tags['sway/lower'] + tags['sway/short'], # Tags can be combined with the +, -, and & operators
		'crops': tags['minecraft:crops'], # Vanilla tags are included
		'water': blocks('minecraft:water') # Individual blocks can also be referenced by name
	})

	with shaderpack_root.joinpath('shaders/block.properties').open('w') as f:
		f.write(mapping.render_encoder())
	with shaderpack_root.joinpath('shaders/util/block_properties.glsl').open('w') as f:
		f.write(mapping.render_decoder())
	
	print('Done!')

if __name__ == '__main__':
	main()

Core Concepts

The block_wrangler library uses a few main concepts:

Block Types

These represent the different types of blocks that can be found in Minecraft, and all of their properties.

Tags

Tags generate a semantically meaningful group of block states that can be used to define flags.
The library comes with all Vanilla tags, and a few more that are commonly used in shaders.

They can use other tags in their definitions, and their actual contents are calculated on demand.

Block Collections

These are a more concrete representation of a group of block states. Tags can create them, or you can define them manually.

Mappings

Mappings store the actual numeric IDs that go into your block.properties file.

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

block_wrangler-0.0.7.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

block_wrangler-0.0.7-py3-none-any.whl (120.4 kB view details)

Uploaded Python 3

File details

Details for the file block_wrangler-0.0.7.tar.gz.

File metadata

  • Download URL: block_wrangler-0.0.7.tar.gz
  • Upload date:
  • Size: 52.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for block_wrangler-0.0.7.tar.gz
Algorithm Hash digest
SHA256 0bbed4a11d14fad5fe6d4040d204b14ed9a6536bbc092af93456b58856ed89d5
MD5 be7084719efa71f04af083ba7f81ae9e
BLAKE2b-256 7e29873e9efec3c227d585ed179ea5c0c89543204435be498e66255493879d95

See more details on using hashes here.

File details

Details for the file block_wrangler-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: block_wrangler-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 120.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for block_wrangler-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6ab608502400edd63ba4ab6ce0f07e66d93128c975c7979b0b46e2cb2429fef6
MD5 e06040166d43e8640ec7d347d16293ab
BLAKE2b-256 947f4da0bfe96361dce4433612fd231a24a1782d9441b048ade95b189f78cb58

See more details on using hashes here.

Supported by

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