Utilities for parsing an existing trade list
parse_give_command(command, name, **kwargs)
Parse a /give command (such as you'd find from a skin lookup site) to extract just the relevant specification that needs to go into the head-list
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command |
str
|
The full |
required |
name |
str
|
The display name to give to the head |
required |
**kwargs |
Any customizations (color, formatting, note block sound) to give
to the head. See: |
{}
|
Returns:
Type | Description |
---|---|
HeadSpec
|
The tokenized head specification |
Raises:
Type | Description |
---|---|
ValueError
|
If the command could not be parsed |
Source code in head_hunter/parse.py
parse_mob_heads(mob)
Extract head specs from a "More Mob Heads" data pack loot table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mob |
str | PathLike
|
Either the name of the mob whose head (or heads) you're looking to parse (in which case this method will attempt to extract the mob head from a "more mob heads" data pack stored in the "packs" folder) or the path of the particular loot table JSON you're wanting to parse |
required |
Returns:
Type | Description |
---|---|
List of HeadSpec
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the specified file doesn't exist or can't be found |
PermissionError
|
If you don't have the ability to open the file |
JSONDecodeError
|
If the specified file is not valid JSON |
Source code in head_hunter/parse.py
parse_wandering_trades(trade_path=None)
Parse an existing trade list
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trade_path |
path
|
The trade list you want to parse. If None is specified,
this method will look for a "wandering trades" pack in the packs folder
and attempt to parse |
None
|
Returns:
Type | Description |
---|---|
list of HeadSpec
|
|
list of str
|
list of block trade commands, with the trade index replaced by the placeholder "IDX" |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the specified trade file doesn't exist |
PermissionError
|
If you don't have the ability to open the trade file |
RuntimeError
|
If a command in the file could not be parsed |
Notes
This function is not smart enough to detect if the full spec doesn't actually match the "skull owner"