โฐ stewbeet.plugins.finalyze.custom_blocks_ticking

๐Ÿ“„ Source Code: stewbeet/plugins/finalyze/custom_blocks_ticking/__init__.py ๐Ÿ”—

๐Ÿ”— Dependencies

  • โœ… 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

๐Ÿ“‹ Overview

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.

Some Features Showcase

Automatically links custom blocks timing functions efficiently:

๐ŸŽฏ Purpose

  • โฐ 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 minute

๐Ÿ“‹ Configuration Options

OptionTypeDefaultDescription
tick.mcfunctionfileAuto-detectedCustom block function that runs every tick (20 times/second)
tick_2.mcfunctionfileAuto-detectedCustom block function that runs every 2 ticks (10 times/second)
second.mcfunctionfileAuto-detectedCustom block function that runs every second
second_5.mcfunctionfileAuto-detectedCustom block function that runs every 5 seconds
minute.mcfunctionfileAuto-detectedCustom block function that runs every minute (60 seconds)
Function DetectionautomaticN/AScans custom_blocks/ folder for timing functions
Entity OptimizationautomaticEnabledUses 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.mcfunction for every-tick execution (20 times/second)
  • โฑ๏ธ Detects tick_2.mcfunction for every 2 ticks execution (10 times/second)
  • ๐Ÿ• Detects second.mcfunction for once-per-second execution
  • โฐ Detects second_5.mcfunction for every 5 seconds execution
  • โฒ๏ธ Detects minute.mcfunction for 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}.tick tags for tick-based execution
  • ๐Ÿ”„ Creates {namespace}.tick_2 tags for 2-tick intervals
  • โฐ Creates {namespace}.second tags for second-based ticking
  • โฑ๏ธ Creates {namespace}.second_5 tags for 5-second intervals
  • โฒ๏ธ Creates {namespace}.minute tags for minute-based execution
  • ๐Ÿงน Removes tags during block destruction to prevent memory leaks

๐Ÿ“Š Performance Optimization

Implements scoreboard-based optimization for efficient execution:

  • โšก Tracks #tick_entities count for tick functions
  • ๐Ÿ”„ Tracks #tick_2_entities count for 2-tick functions
  • ๐Ÿ”ข Tracks #second_entities count for second functions
  • โฑ๏ธ Tracks #second_5_entities count for 5-second functions
  • โฒ๏ธ Tracks #minute_entities count 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 tick function for every-tick execution
  • ๐Ÿ”„ Adds to versioned tick_2 function for 2-tick execution
  • โฐ Adds to versioned second function for once-per-second execution
  • โฑ๏ธ Adds to versioned second_5 function for 5-second execution
  • โฒ๏ธ Adds to versioned minute function 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/tick distribution function
  • ๐Ÿ”„ Creates {namespace}:custom_blocks/tick_2 distribution function
  • ๐Ÿ“ฆ Generates {namespace}:custom_blocks/second distribution function
  • โฑ๏ธ Creates {namespace}:custom_blocks/second_5 distribution function
  • โฒ๏ธ Generates {namespace}:custom_blocks/minute distribution 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_blocks system