A collection of beet and bolt plugins
Project description
ps_beet_bolt
A collection of my beet and bolt plugins
bolt-item
To be able to use on_equip, on_unequip, on_attack, on_attacked, on_consume or on_tick, you have to require the specific plugin in your beet json/yaml/yml file.
You also need to add the respecive library for on_attack and on_attacked (argon) or on_equip and on_unequip (tungsten) to work
require:
- bolt
- ps_beet_bolt.register.bolt_item # on_consume, on_tick
- ps_beet_bolt.register.tungsten # on_equip, on_unequip
- ps_beet_bolt.register.argon # on_attack, on_attacked
data_pack:
load:
- libraries/mc-tungsten* # on_equip, on_unequip
- libraries/mc-argon* # on_attack, on_attacked
- src
Example code with explanations:
from ps_beet_bolt.bolt_item import bolt_item, transformer, custom_component, event_decorator
from tungsten:decorators import on_equip, on_unequip
from argon:decorators import on_attack, on_attacked
from bolt_item:decorators import on_consume, on_tick
@event_decorator
def on_block_interact(func, item):
"""
You can use the @event_decorator to add any functionality you like. You can modify
the items components, and read any information.
"""
path = f'{item.namespace}:bolt-item/item/{item.id}/on_block_interact/{func.__name__}'
advancement path { "criteria": { "criteria": {
"trigger": "minecraft:item_used_on_block",
"conditions": { "location": [{
"condition": "minecraft:match_tool",
"predicate": {
"items": item.base_item,
"components": {
"custom_data": {
"bolt-item": { "id": f'{item.namespace}:{item.id}' }
}
}
}}]
}}},
"rewards": { "function": path }
}
function path:
advancement revoke @s only path
func()
class ParentItem:
"""
All the special decorators, vanilla components and custom components get
inherited, even if the parent class is not an item itself.
"""
lore = [{"text":"MyPack","color":"blue"}]
@transformer(component = "item_name")
def item_name_transformer(item, item_name):
"""
A @transformer takes the previous value of a components and sets it to the return value.
You can chain as many transformer after each other as you like.
They are applied from parent to child, from top to bottom.
"""
return {"text":item_name,"color":"red"}
@bolt_item
class ActualItem(ParentItem):
"""
Any classes with the @bolt_item decorator are treated as item and get a .components and a .base_item
attribute set. Those can be used to create loot tables or other stuff.
"""
item_name = "Awesome Item"
story = "This item special"
consumable = {}
equippable = {"slot":"head"}
@on_block_interact
def say_hi_it_interacted_with_block():
"""
This is the custom event decorator added earlier in the file, for more examples look through
this libraries bolt code.
"""
say I INTERACTED WITH THE BLOCK USING THIS ITEM
@custom_component(component = "story")
def story_handler(item, story):
"""
@custom_component handlers take an attribute and can modify the item's components based on
that input.
"""
item.lore = [{"text":story, "color":"gray"}] + item.get("lore", [])
@on_consume(return_item = True)
def infinitely_eddible():
"""
@on_consume runs when the item is consumed. If return_item is set to True, the item stays in
the players inventory. This can be used for right click abilities with cooldown provided by
the use_cooldown component.
"""
say THIS ITEM WAS CONSUMED, THIS ITEM IS NOT REMOVED FROM THE INVENTORY HOWEVER SINCE RETURN ITEM IS TRUE, THIS CAN BE USED TO TRIGGER A COOL DOWN ON RIGHT CLICK
@on_tick(interval = "10s", full_slot = "armor.head")
def yap_every_10_seconds():
"""
This uses schedules to run this command in the given interval when it's equipped on the given slot.
"""
say ANOTHER 10 SECONDS HAVE PASSED AND I AM WEARING THIS ITEM ON MY HEAD
@on_equip(slot = "head")
def add_resistance():
"""
@on_unequip requires tungsten. This function runs when a player unequips this item from the given slot.
"""
effect give @s resistance infinite 1
@on_unequip(slot = "head")
def remove_resistance():
"""
@on_equip requires tungsten. This function runs when a player equips this item in the given slot.
"""
effect clear @s resistance
@on_attack(slot = "mainhand")
def attack_my_enemies():
"""
@on_attack requires argon. This function runs when a player attacks an enemy with this item in
the given slot. @s is enemy; on attacker is player.
"""
say I AM AN ATTACKED ENEMY
on attacker say I AM THE PLAYER WHO ATTACKED THE ENEMY WITH THIS ITEM IN THEIR MAINHAND
@on_attacked(full_slot = "weapon.mainhand")
def attacked_by_enemies():
"""
@on_attacked requires argon. This function runs when a player is attacked with this item in
the given slot. @s is player; on attacker is enemy.
"""
say I AM THE PLAYER WHO GOT ATTACKED WHILE HOLDING THIS ITEM IN MY MAINHAND
on attacker say I AM THE ENEMY WHO DID IT
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 ps_beet_bolt-1.0.0.tar.gz.
File metadata
- Download URL: ps_beet_bolt-1.0.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95fad6f2dc868f2914f9f44ca942a5bc61b9df2fdaf76ed40dc04699ce58aeb2
|
|
| MD5 |
b9bbca5af4a20624bd12359a9bac9532
|
|
| BLAKE2b-256 |
beb18d128b9322d75b42aafa811cbca50c9706baae323ee38865f4726653321f
|
File details
Details for the file ps_beet_bolt-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ps_beet_bolt-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
218f0555201305e4792c99d0988e16a197254eeccdd44eb7ebaa08fa61e81779
|
|
| MD5 |
c49fead2d9568c63940bd778b82dbfdf
|
|
| BLAKE2b-256 |
4c518d1e9cb3658ea2dc18155c9bf788325a94dd176c46f439d70d27d735db4e
|