πŸ—οΈ stewbeet.plugins.finalyze.basic_datapack_structure

πŸ“„ Source Code: stewbeet/plugins/finalyze/basic_datapack_structure/__init__.py πŸ”—

πŸ”— Dependencies

  • βœ… Required: Project ID and version in context
  • πŸ”§ Optional: Versioned timing functions (tick_2, second, second_5, minute)
  • πŸ“‹ Related: Works with versioned function system

πŸ“‹ Overview

The finalyze.basic_datapack_structure plugin sets up essential timing infrastructure
for Minecraft datapacks by creating timer systems for different intervals. It automatically
detects existing versioned timing functions and generates the necessary tick-based
logic to call them at proper intervals with optimized load distribution.

Feature Showcase

Timer systems for different intervals (tick_2, second, second_5, minute):

🎯 Purpose

  • ⏰ Sets up basic timing infrastructure for datapacks
  • πŸ”„ Creates timer systems for different intervals (tick_2, second, second_5, minute)
  • πŸ“Š Implements scoreboard-based timing logic
  • ⚑ Optimizes load distribution with offset timing
  • 🎯 Automatically detects existing timing functions
  • πŸ—οΈ Provides foundation for datapack timing systems

βš™οΈ Configuration

🎯 Basic Example Configuration

pipeline: - ... - stewbeet.plugins.finalyze.basic_datapack_structure - ... # No specific configuration required - automatically detects timing functions # Creates timer infrastructure for any existing versioned functions: # {namespace}:v{version}/tick_2 - Every 2 ticks (0.1 seconds) # {namespace}:v{version}/second - Every second # {namespace}:v{version}/second_5 - Every 5 seconds # {namespace}:v{version}/minute - Every minute

πŸ“‹ Configuration Options

OptionTypeDefaultDescription
tick_2functionAuto-detectedFunction called every 2 ticks (0.1 seconds)
secondfunctionAuto-detectedFunction called every second (20 ticks)
second_5functionAuto-detectedFunction called every 5 seconds (100 ticks)
minutefunctionAuto-detectedFunction called every minute (1200 ticks)
Timer OffsetautomaticEnabledOffset timing for better load distribution

✨ Features

πŸ” Automatic Function Detection

Scans for existing versioned timing functions in the datapack:

  • πŸ“ Detects v{version}/tick_2 functions for high-frequency timing
  • ⏱️ Identifies v{version}/second functions for per-second execution
  • πŸ• Finds v{version}/second_5 functions for 5-second intervals
  • ⏰ Locates v{version}/minute functions for minute-based timing

πŸ“Š Timer Reset System

Implements proper timer initialization for each detected function:

  • πŸ”„ Resets #tick_2 timer to 1 for immediate first execution
  • ⏱️ Initializes #second timer to 0 for standard counting
  • πŸ• Sets #second_5 timer to -10 for offset execution
  • ⏰ Resets #minute timer to 1 for proper timing

⚑ Load Distribution Optimization

Uses offset timing to distribute computational load:

  • 🎯 tick_2 executes at 3+ ticks instead of 2 for offset
  • πŸ• second_5 starts at -10 to spread load (90+ ticks instead of 100)
  • ⚑ Prevents multiple timers from executing simultaneously
  • πŸ“ˆ Improves server performance by avoiding tick spikes

πŸ”’ Scoreboard Timer Logic

Creates efficient scoreboard-based timing system:

  • πŸ“Š Increments timer scoreboards each tick
  • 🎯 #tick_2 increments for 2-tick timing
  • ⏱️ #second increments for 20-tick (1 second) timing
  • πŸ• #second_5 increments for 100-tick (5 second) timing
  • ⏰ #minute increments for 1200-tick (1 minute) timing

🎯 Conditional Function Execution

Implements threshold-based function calling:

  • πŸ”„ Calls tick_2 when score reaches 3+ (offset timing)
  • ⏱️ Executes second when score reaches 20+ (1 second)
  • πŸ• Triggers second_5 when score reaches 90+ (offset 5 ticks)
  • ⏰ Invokes minute when score reaches 1200+ (1 minute)

πŸ—οΈ Tick File Integration

Integrates timing logic into the main tick function:

  • πŸ“ Prepends timer logic to existing tick functions
  • πŸ”§ Ensures timing infrastructure runs before other tick logic
  • ⚑ Maintains proper execution order for dependent systems
  • 🎯 Provides foundation for all datapack timing needs