Library to parse BlazeAndCavesAdvancementsPack and Addons for it
Project description
BACAP_Parser
A Python library to parse BlazeAndCavesAdvancementsPack and its Addons
Requirements
- Python version 3.12 or higher
- BACAP or addon for minecraft 1.21+
Installing
pip install BACAP-Parser
Configuration
To use the library, you first need to configure the parsing parameters, specifically the possible advancement types for each datapack and the list of these datapacks. Example configuration:
from pathlib import Path # All paths must be pathlib.Path classes
task = AdvType(name="task", frames="task", colors=Color("green"))
goal = AdvType(name="goal", frames="goal", colors=Color("#75E1FF"))
# Challenges can also be hidden, so configure default color for hidden advancement in BACAP
challenge = AdvType(name="challenge", frames="challenge",
colors=Color("dark_purple"), hidden_color=BACAP_Parser.DEFAULT_BACAP_HIDDEN_COLOR)
super_challenge = AdvType(name="super_challenge", frames="challenge", colors=Color("#FF2A2A"))
root = AdvType(name="root", frames=("task", "challenge"), colors=Color("#CCCCCC"))
milestone = AdvType(name="milestone", frames="goal", colors=Color("yellow"), tabs="bacap")
advancement_legend = AdvType(name="advancement_legend", frames="challenge", colors=Color("gold"), tabs="bacap")
manager = AdvTypeManager([task, goal, challenge, super_challenge, root, milestone, advancement_legend])
bacap = Datapack(name="bacap", path=Path("datapacks/bacap"),
adv_type_manager=manager, reward_namespace="bacap_rewards", technical_tabs="technical")
# You can use the one AdvTypeManager for many datapacks if they have the same advancement types
bacaped = Datapack(name="bacaped", path=Path("datapacks/bacaped"),
adv_type_manager=manager, reward_namespace="bacaped_rewards", technical_tabs="technical")
bacaped_hardcore = Datapack(name="bacaped_hardcore", path=Path("datapacks/bacaped_hardcore"),
adv_type_manager=manager, reward_namespace="bacaped_rewards", technical_tabs="technical")
parser = Parser(bacap, bacaped, bacaped_hardcore)
Examples
Get Advancements Data
bacap_advs: list[Advancement | TechnicalAdvancement | InvalidAdvancement] = parser.get_datapack(
"bacap").advancement_manager.filtered_list() # Get all advancements except technical and invalid
for adv in bacap_advs:
print(adv.title)
if adv.type.name == "super_challenge":
print(adv.description)
if adv.type.name == "milestone":
print(adv.criteria_list)
- Note: Each datapack has its own
advancement_manager
Filtering
There are three ways to filter advancements.
filtered_iterator allows searching while ignoring or keeping technical advancements, invalid advancements, and normal advancements.
manager: AdvancementManager = parser.get_datapack("bacap").advancement_manager
only_technical: Iterator[TechincalAdvancement] = manager.filtered_iterator(
skip_normal=True, skip_invalid=True, skip_technical=False)
find provides a more flexible setup with the ability to pass filtering parameters.
manager: AdvancementManager = parser.get_datapack("bacap").advancement_manager
parent = manager.find(criteria={"mc_path": adv.parent}, skip_technical=False, skip_invalid=False, limit=1)[0]
deep_find differs from find in three key ways:
- Support for nested attributes.
- Ability to use functions as criteria values.
- Checks for partial matches.
manager = parser.get_datapack("bacap").advancement_manager
advs_with_item_rewards = [adv for adv in manager.deep_find({"reward": lambda reward: bool(trophy)})]
Get trophy with description, item color and components
manager = parser.get_datapack("bacap").advancement_manager
advancements = manager.deep_find(
{"trophy": lambda trophy: bool(trophy)})
random_advancement: Advancement = random.choice(advancements) # Get random advancement class
trophy = random_advancement.trophy # Trophy of the advancement
trophy_item: TrophyItem = trophy.item # Item id of the trophy
description: str = trophy.item.description # String with trophy description
name_color: Color = trophy.item.color # Color class of the trophy color
Add custom tabs
If your datapack has its own tabs with advancements, you can add them by specifying a custom TabNameMapper when creating the datapack.
...
tab_mapper = TabNameMapper({"ultimate_challenges": "The Ultimate Challenges Ever"})
bacap = Datapack(name="custom", path=Path(r"datapacks/custom"),adv_type_manager=manager,
reward_namespace="bacap_rewards", technical_tabs="technical", tab_name_mapper=tab_mapper)
...
Now, when accessing the tab_display attribute of advancements from the ultimate_challenges tab, it will correctly display its display name.
Get HEX/RGB/INT color codes from Minecraft Text Colors
color = Color('light_purple') # Will be converted to HEX representation
rgb_c: tuple[int, int, int] = color.as_rgb # RGB representation of the color
int_c: int = color.as_int # Integer representation of the color
# The Color class also provides static methods for converting between these color storage types.
clr = (100, 150, 200)
new_clr = Color.rgb_to_int(clr) # Will return an Integer representation of RGB color
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 bacap_parser-0.4.tar.gz.
File metadata
- Download URL: bacap_parser-0.4.tar.gz
- Upload date:
- Size: 33.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f76c019799a76f239d1be4e11d2d427972dc207be9922c24c8dc4717a3bb96e
|
|
| MD5 |
299518dba132ca1328effcb03d7ea442
|
|
| BLAKE2b-256 |
509c2641faef1029d2e16f87c6845de44d7663983331b1ef96d2103d0f0dd597
|
Provenance
The following attestation bundles were made for bacap_parser-0.4.tar.gz:
Publisher:
python-publish.yml on ItzSkyReed/BACAP_Parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bacap_parser-0.4.tar.gz -
Subject digest:
9f76c019799a76f239d1be4e11d2d427972dc207be9922c24c8dc4717a3bb96e - Sigstore transparency entry: 160091959
- Sigstore integration time:
-
Permalink:
ItzSkyReed/BACAP_Parser@c1d2892bd1649bcf8c258b2f0520ab6eecf4a340 -
Branch / Tag:
refs/tags/0.4b - Owner: https://github.com/ItzSkyReed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c1d2892bd1649bcf8c258b2f0520ab6eecf4a340 -
Trigger Event:
release
-
Statement type:
File details
Details for the file BACAP_Parser-0.4-py3-none-any.whl.
File metadata
- Download URL: BACAP_Parser-0.4-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12c9610bfd28988f89fb9499823c408f00fc71727b45ca8b29746a64e42510a2
|
|
| MD5 |
68a8acc16b89226a2ee3aa311d6da5a8
|
|
| BLAKE2b-256 |
cf8113bd17231970e965e087e3da19ef64ac08ee1e6283b68a4b278e5e11d50c
|
Provenance
The following attestation bundles were made for BACAP_Parser-0.4-py3-none-any.whl:
Publisher:
python-publish.yml on ItzSkyReed/BACAP_Parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bacap_parser-0.4-py3-none-any.whl -
Subject digest:
12c9610bfd28988f89fb9499823c408f00fc71727b45ca8b29746a64e42510a2 - Sigstore transparency entry: 160091960
- Sigstore integration time:
-
Permalink:
ItzSkyReed/BACAP_Parser@c1d2892bd1649bcf8c258b2f0520ab6eecf4a340 -
Branch / Tag:
refs/tags/0.4b - Owner: https://github.com/ItzSkyReed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c1d2892bd1649bcf8c258b2f0520ab6eecf4a340 -
Trigger Event:
release
-
Statement type: