🧱 custom_blocks#
Sets up the custom blocks of the definitions in the datapack.
- beet_default(ctx: Context)[source]#
Main entry point for the custom blocks plugin. This plugin sets up custom blocks in the datapack based of the given definitions configuration.
- Parameters:
ctx – The beet context.
- write_block_features(
- ns: str,
- blocks: list[Block],
The functions of the features some blocks use, written only when one does.
- warn_unplaceable_blocks() None[source]#
Warn about the blocks without a vanilla block, which nothing can place.
The facing and light predicates, and the rotation and brightness functions every custom block uses.
- write_stats_totals(ns: str, has_growing_seed: bool) None[source]#
The stats lines counting every custom block, and every growing seed when there are any.
aiming#
Where the placer clicked a block being placed, found by stepping along their look, for the hosts of VanillaBlock.half.
- write_aim(ns: str) None[source]#
{ns}:custom_blocks/_aim/main, run as a marker summoned at the center of a block being placed, which it kills.#upperends at 1 when the look of the{ns}.placerplayer leaves the block through its upper half, which is how vanilla picks a top slab, and#floorat 1 when it leaves through the bottom face, the player having clicked the top of the block below.
destroying#
- VANILLA_BLOCKS_TAG: str = 'used_vanilla_blocks'[source]#
The block tag listing every vanilla block a custom block stands in.
- vanilla_block_of(
- vanilla_block: JsonDict,
The vanilla block a custom block stands in, without its states or data,
CUSTOM_BLOCK_ALTERNATIVEfor an item frame block.>>> vanilla_block_of({"id": "minecraft:furnace[lit=false]"}), vanilla_block_of({"contents": True}), vanilla_block_of({}) ('minecraft:furnace', 'minecraft:item_frame', None)
- write_destroy_dispatch(
- ns: str,
- unique_blocks: list[str],
Send a custom block whose vanilla block went missing to the group of blocks sharing that vanilla block.
- write_groups(ns: str, unique_blocks: list[str]) None[source]#
Per vanilla block, its stats line and the group function destroying whichever custom block it was.
- write_block_destroys(ns: str) None[source]#
Per custom block, the destroy function and the one turning the vanilla drop into the custom item.
- write_block_destroy(
- ns: str,
- item: str,
- data: Item,
- block_id: str,
Write the destroy function of one custom block standing in
block_id, and its replace_item function.
- no_silk_touch_content( ) str[source]#
The replace_item commands of a block dropping something else unless mined with silk touch.
An ore relies on common_signals for the silk touch and the count, any other block checks the player’s tool itself.
- loot_table_drop_lines(
- ns: str,
- obj_block: Block,
- loot_table: LootTable | str,
The commands dropping
loot_tablerolled with the breaker’s tool instead of the vanilla drop, when no silk touch was used.
- no_silk_touch_drop_lines(
- ns: str,
- drop: str | JsonDict | NoSilkTouchDrop,
The commands turning the vanilla drop into
drop, an item id or a count of one, when no silk touch was used.
- experience_lines(
- ns: str,
- experience: dict[str, int] | float,
The commands summoning, at the block, the experience points a drop gives when no silk touch was used.
>>> print(experience_lines("ns", {"min": 3, "max": 6}).strip()) execute if score #is_silk_touch ns.data matches 0 summon minecraft:experience_orb store result entity @s Value short 1 run random value 3..6 >>> print(experience_lines("ns", 2.25).strip()) execute if score #is_silk_touch ns.data matches 0 run summon minecraft:experience_orb ~ ~ ~ {Value:2s} execute if score #is_silk_touch ns.data matches 0 if predicate {"type": "minecraft:random_chance","chance": 0.25} run summon minecraft:experience_orb ~ ~ ~ {Value:1s} >>> experience_lines("ns", 0.0) ''
- write_vanilla_checks(
- ns: str,
- unique_blocks: list[str],
The block tag of every vanilla block in use, and the predicates telling whether an entity still stands in its own.
energy#
Registers the custom blocks with energy settings in the energy library, and refuses cables on their blocked faces.
- ENERGY_DIRECTIONS: tuple[str, ...] = ('up', 'down', 'north', 'south', 'east', 'west')[source]#
The directions in the order the energy library numbers them, each followed by its opposite.
- HORIZONTAL_FACINGS: tuple[tuple[str, str], ...] = (('north', '-45..45'), ('east', '45..135'), ('south', '135..-135'), ('west', '-135..-45'))[source]#
Where a machine’s front points for each range of its
y_rotation, clockwise, as the wrench turns it.
- RELATIVE_FACES: dict[str, int] = {'back': 2, 'front': 0, 'left': 1, 'right': 3}[source]#
How many clockwise steps each side face is from the front, left and right as seen by a player facing the front.
- write_energy(ns: str) None[source]#
Register every placeable custom block whose
custom_datahasenergy, and refuse cables on itsblocked_faces.
- write_energy_calls(
- funcs: BlockFunctions,
- energy: JsonDict,
- ns: str,
Register one custom block with the energy library, as a cable, a machine or a battery.
- cable_refusals(tag: str, face: str) list[str][source]#
The commands refusing a cable on one face of the machines with
tag, for each way the machine can face.- Parameters:
face –
top,bottom, or a key ofRELATIVE_FACES.
>>> cable_refusals("a.solar", "top") ['execute if entity @s[tag=a.solar] if score #cable.in energy.data matches 1 run scoreboard players set #cable.out energy.data 0'] >>> [line.split(" matches ")[1][0] for line in cable_refusals("a.generator", "front")] ['3', '5', '2', '4']
host_states#
Displays following a host state that changes after placement, as the corner a stairs host makes or a furnace burning.
- write_host_state(
- block: Block,
Keep the custom_model_data string of the block’s display on the state of
VanillaBlock.host_statesits host is in.It is set on placement and checked every second, the items definition showing the model copy of that state, and only for a block whose resource pack has such a copy.
interactions#
Blocks standing in an invisible host with an interaction entity: broken by hitting it, a seat when used.
- CONVENTION_TAGS: tuple[str, ...] = ('global.ignore', 'global.ignore.kill', 'smithed.entity')[source]#
Tags keeping other packs from killing or moving the entities of a block.
- interaction_of(
- block: Block,
The interaction of a block standing in an invisible host.
- interaction_summon(
- block: Block,
The commands summoning the block’s interaction on its bottom, run at the center of the block.
- interaction_destroy(
- block: Block,
The commands ending the block’s destroy function: feedback, its item unless
#no_dropis 1, and its entities gone.Only a creative player or a weak tool sets
#no_drop, so anything else breaking the block, such as a quarry, gets the item. An item id asno_silk_touch_dropdrops that item instead, as a lit lamp drops an unlit one.
- feedback(
- block: Block,
- sound: str,
The particles of the block’s item and its
hitorbreaksound, at the center of the block.
- write_interactions(
- blocks: list[Block],
The advancements noticing a player hitting or using an interaction, and what each block does then.
- write_block_hit(
- block: Block,
What hitting the block’s interaction does, run as it at the center of the block.
It counts the hit, then breaks the block once enough came.
machines#
Furnaces and brewing stands working VanillaBlock.machine_speed times faster, pushed one tick at a time while they work.
mining#
The tool a block needs to drop its item: enforced by vanilla through a host of the right level, or checked by StewBeet.
- resolve_mining_hosts(
- blocks: list[Block],
Give a block with
miningand no host the default host of its level, and refuse a host that would not enforce it.An ore keeps
VANILLA_BLOCK_FOR_ORES, and an interaction host checks the tool itself, so both may need any tool.- Raises:
ValueError – When no vanilla host enforces the tool, or the host given is not one of
Mining.hosts.
placing#
- FACING: tuple[str, ...] = ('north', 'east', 'south', 'west')[source]#
The horizontal directions, in the order the
#rotationscore numbers them from 1, a block facing the placer.
- LOOK_FACING_HOSTS: tuple[str, ...] = ('_stairs', '_fence_gate')[source]#
Hosts vanilla turns the way the placer looks rather than towards them.
- write_placement( ) tuple[str, str] | None[source]#
Write a custom block’s stats line and the functions placing it.
- Returns:
The vanilla block it stands in and the entity showing it, None when its vanilla block has neither an id nor contents.
- write_frame_search(
- obj_block: Block,
- item: str,
- block: JsonDict,
Write the advancement noticing an item frame block placed, and the function finding the frame it became.
- write_display_placement( ) str[source]#
Write the place functions of a block shown by an item display inside a vanilla block.
- Returns:
The vanilla block’s id, without its states or data.
- setblock_lines(
- block: VanillaBlock,
- custom_name: str,
The commands putting the vanilla block in place, facing as vanilla turns it when
block_facingasks for it, and on the half the placer clicked whenhalfasks for it.A block opening an interface is placed with the custom name, which the interface then shows.
- placed_variants(
- block: VanillaBlock,
- states: list[str],
The states the host can be placed with, each after the condition picking it from the placer’s rotation and clicked half.
- display_setup( ) str[source]#
The commands turning a freshly summoned item display into the block, run as that display.
- write_frame_placement( ) None[source]#
Write the place functions of a block that is an invisible item frame holding its model.
- write_smithed_link(ns: str) None[source]#
Have smithed’s custom block library place the blocks whose item is
CUSTOM_BLOCK_VANILLA, when there are any.
seeds#
- GROWTH_TICKS: tuple[tuple[int, str], ...] = ((60, 'minute'), (5, 'second_5'), (1, 'second'))[source]#
Seconds added to the growth time per call, and the clock calling it, slowest first.
- write_growing_seed(
- obj_block: Block,
- growing_seed: GrowingSeed,
- item: str,
- source_textures: dict[str, str],
Write what makes a seed grow through its stages, and what it drops once fully grown.
- write_update_seed_model(
- obj_block: Block,
- num_stages: int,
- growing_time: int,
Switch the seed’s model to the stage its growth time reached, the last stage being the grown plant.
- write_growth_tick(
- obj_block: Block,
- item: str,
- progress_stages: int,
- growing_time: int,
Advance the growth time on the slowest clock that still reaches every stage on time.
- seed_loot_table(
- pools: list[GrowingSeedLoot],
The loot table a fully grown seed drops, one pool per loot.
A pool’s id is a vanilla item with
minecraft:, one of this pack’s items when plain, and another loot table otherwise.