stewbeet.plugins.finalyze.custom_blocks_ticking
The finalyze.custom_blocks_ticking plugin automatically sets up ticking functionality
for custom blocks by detecting timing functions in the custom_blocks folder.
It generates the necessary infrastructure to call these functions efficiently, including
entity tagging, scoreboard optimization, and proper integration with versioned functions.
Supports multiple timing intervals: tick, tick_2, second, second_5, and minute.
Required: Custom block functions in the custom_blocks/ folder
Optional: Custom blocks with block_name/tick.mcfunction or block_name/second.mcfunction files
Related: Works with datapack.custom_blocks plugin for block infrastructure
Some Features Showcase
Automatically links custom blocks timing functions efficiently:
Source Code: stewbeet/plugins/finalyze/custom_blocks_ticking/__init__.py
What it does
- Automatically detects custom block timing functions (tick, tick_2, second, second_5, minute)
- Sets up entity tagging system for ticking custom blocks
- Implements scoreboard-based performance optimization
- Integrates with versioned function system for proper timing
- Provides efficient execution only when ticking entities exist
- Adds statistics tracking for ticking entities
Configuration
Basic Example Configuration
pipeline:
- ...
- stewbeet.plugins.datapack.custom_blocks # Optional if you are adding custom blocks functions yourself
- ...
- stewbeet.plugins.finalyze.custom_blocks_ticking
- ...
# No specific configuration required - automatically detects timing functions
# Create timing functions in custom_blocks folder:
# custom_blocks/{block_name}/tick.mcfunction - Runs every tick (20 times/second)
# custom_blocks/{block_name}/tick_2.mcfunction - Runs every 2 ticks (10 times/second)
# custom_blocks/{block_name}/second.mcfunction - Runs every second
# custom_blocks/{block_name}/second_5.mcfunction - Runs every 5 seconds
# custom_blocks/{block_name}/minute.mcfunction - Runs every minuteWhen writing those functions from Python, take the path from the block rather than retyping the convention: see Resource Locations:
obj = Block.from_id("electric_furnace")
write_function(obj.functions.tick, "...")
write_function(obj.functions.second, "...")
# Or build the accessor directly from the block ID: same paths, and it works
# even for IDs that have no Block definition:
write_function(BlockFunctions("electric_furnace").tick, "...")Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
tick.mcfunction | file | Auto-detected | Custom block function that runs every tick (20 times/second) |
tick_2.mcfunction | file | Auto-detected | Custom block function that runs every 2 ticks (10 times/second) |
second.mcfunction | file | Auto-detected | Custom block function that runs every second |
second_5.mcfunction | file | Auto-detected | Custom block function that runs every 5 seconds |
minute.mcfunction | file | Auto-detected | Custom block function that runs every minute (60 seconds) |
| Function Detection | automatic | N/A | Scans custom_blocks/ folder for timing functions |
| Entity Optimization | automatic | Enabled | Uses scoreboards to optimize execution when no entities exist |
Features
Automatic Function Detection
Scans the custom_blocks folder for timing functions:
- π Searches for functions in
{namespace}:custom_blocks/{block}/folder - β‘ Detects
tick.mcfunctionfor every-tick execution (20 times/second) - β±οΈ Detects
tick_2.mcfunctionfor every 2 ticks execution (10 times/second) - π Detects
second.mcfunctionfor once-per-second execution - β° Detects
second_5.mcfunctionfor every 5 seconds execution - β²οΈ Detects
minute.mcfunctionfor every minute execution - π― Validates proper folder structure and naming
Entity Tagging System
Sets up proper entity tags for ticking custom blocks:
- π Adds tags during block placement (
place_secondary) - β‘ Creates
{namespace}.ticktags for tick-based execution - π Creates
{namespace}.tick_2tags for 2-tick intervals - β° Creates
{namespace}.secondtags for second-based ticking - β±οΈ Creates
{namespace}.second_5tags for 5-second intervals - β²οΈ Creates
{namespace}.minutetags for minute-based execution - π§Ή Removes tags during block destruction to prevent memory leaks
Performance Optimization
Implements scoreboard-based optimization for efficient execution:
- β‘ Tracks
#tick_entitiescount for tick functions - π Tracks
#tick_2_entitiescount for 2-tick functions - π’ Tracks
#second_entitiescount for second functions - β±οΈ Tracks
#second_5_entitiescount for 5-second functions - β²οΈ Tracks
#minute_entitiescount for minute functions - π― Only executes when entities with tags exist
- βοΈ Prevents unnecessary function calls when no ticking blocks are present
Versioned Function Integration
Integrates with the versioned function system for proper timing:
- β‘ Adds to versioned
tickfunction for every-tick execution - π Adds to versioned
tick_2function for 2-tick execution - β° Adds to versioned
secondfunction for once-per-second execution - β±οΈ Adds to versioned
second_5function for 5-second execution - β²οΈ Adds to versioned
minutefunction for every-minute execution - π― Uses scoreboard checks to optimize performance
- π Proper integration with existing timing infrastructure
Custom Block Function Distribution
Creates centralized distribution functions for multiple custom blocks:
- β‘ Generates
{namespace}:custom_blocks/tickdistribution function - π Creates
{namespace}:custom_blocks/tick_2distribution function - π¦ Generates
{namespace}:custom_blocks/seconddistribution function - β±οΈ Creates
{namespace}:custom_blocks/second_5distribution function - β²οΈ Generates
{namespace}:custom_blocks/minutedistribution function - π·οΈ Uses entity tags to route to specific block functions
- π Allows multiple custom blocks to have ticking functionality
Statistics Integration
Adds ticking entity statistics to the stats system:
- π Initializes scoreboard values for statistics
- β‘ Reports count of entities with tick tags
- π Reports count of entities with tick_2 tags
- π Reports count of entities with second tags
- β±οΈ Reports count of entities with second_5 tags
- β²οΈ Reports count of entities with minute tags
- π― Integrates with existing
_stats_custom_blockssystem
Next steps
- Configuring the build: where this plugin sits in the pipeline.
- All plugins: the rest of the pipeline, in the order it runs.
- Configuring the build: enabling, ordering and configuring plugins.