Skip to content
AlcatrazEscapee edited this page Jun 17, 2024 · 6 revisions

Methods

Recursively removes all files generated using by mcresources, as identified by the inserted comment. Removes empty directories

clean_generated_resources(path: str = 'src/main/resources')
  • path: str the initial path to search through
del_none(data_in: Json) -> Json

Writes json to a file.

write(path_parts: Sequence[str], data: Json, indent: int = 2, ensure_ascii: bool = False, on_error: Callable[[str, Exception], Any] = None) -> Any
  • path_parts: Sequence[str] The path elements of the file
  • data: Json The data to write
  • indent: int The indent level for the json output
  • ensure_ascii: bool The ensure_ascii passed to json.dump - if non-ascii characters should be replaced with escape sequences.
  • on_error: Callable[[str, Exception], Any] A consumer of a file name and error if one occurs

Returns: Any 0 if the file was new, 1 if the file was modified, 2 if the file was not modified, 3 if an error occurred

Parses a ResourceLocation from a series of elements. Can accept:

  • A ResourceLocation, return it
  • A Sequence[str], representing a '/' joined resource path.
  • A 'domain:path' representing a domain specification Then either a single element, or an optional domain followed by data element. If a domain is present in the data, the first optional domain is ignored. If no domain is present, the minecraft domain is inferred.
resource_location(*elements: ResourceIdentifier) -> ResourceLocation
str_path(data_in: Sequence[str]) -> List[str]
domain_path_parts(name_parts: Sequence[str], default_domain: str) -> Tuple[str, List[str]]
flatten_list(container: Sequence[T]) -> Sequence[T]
dict_get(data_in: Dict[K, V], key: K, default: DefaultValue = None, map_function: Callable[[V], MapValue] | None = None) -> V | DefaultValue | MapValue
is_sequence(data_in: Any) -> bool
unordered_pair(data_in: Sequence[Any], first_type: type, second_type: type) -> Tuple[Any, Any]
maybe_unordered_pair(data_in: Any, first_type: type, second_type: type) -> Tuple[Any, Any] | None
recipe_condition(data_in: Json, strict: bool = False) -> List[JsonObject] | None
ingredient(data_in: Json) -> Json
item_predicate(data_in: Json) -> Json
item_stack(data_in: Json) -> JsonObject
ingredient_list(data_in: Json) -> List[JsonObject]
item_stack_list(data_in: Json) -> List[JsonObject]
item_stack_dict(data_in: Json, default_char: str = '#') -> Dict[str, JsonObject]

Allows the following formats to define either an item or a tag: 'namespace:path' -> item '#namespace:path' -> tag Also allows the following count specifiers '1 item' '3-5 item' (only if allow_ranges = True) Returns (item name, is tag, minimum count, maximum count)

parse_item_stack(data_in: str, allow_ranges: bool = True) -> Tuple[str, bool, int | None, int | None]
item_model_textures(data_in: Json) -> JsonObject
blockstate_multipart_parts(data_in: Sequence[Json]) -> List[JsonObject]
tag_entry(data_in: ResourceLocation | Sequence[str] | str | JsonObject, domain: str) -> str | JsonObject
lang_parts(data_in: Sequence[Json], entries: Dict[str, str] = None) -> Dict[str, str]
loot_pool(data_in: Json, loot_type: str) -> JsonObject
loot_entries(data_in: Json) -> List[JsonObject] | None
loot_functions(data_in: Json) -> List[JsonObject] | None
loot_conditions(data_in: Json) -> List[JsonObject] | None
loot_default_conditions(loot_type: str) -> List[JsonObject] | None

Creates a configured object from multiple possibilities. Accepts:

  • A tuple consisting of exactly two elements, the type name and the config
  • Otherwise, data is assumed to be a ResourceIdentifier indicating a type name
expand_configured(data: Json) -> JsonObject

Creates a configured placement from multiple possibilities. Accepts:

  • A tuple consisting of exactly two elements, the type name and optional additional parameters

  • A string type name

configured_placement(data: Json) -> JsonObject

Creates a configured object with a type and config

configure(type_name: ResourceIdentifier, config: JsonObject | None = None) -> JsonObject
vertical_anchor(y: int, anchor: Any = 'absolute') -> Tuple[Any, int] | Dict[str, int] | int
as_vertical_anchor(va: Tuple[Any, int] | Dict[str, int] | int) -> Tuple[Any, int] | Dict[str, int] | int

Converts a block state registry name, with optional properties to the format used by all block state codecs

block_state(data: Json) -> JsonObject
validate_crafting_pattern(pattern: Sequence[str], max_width: int = 3, max_height: int = 3)