### Implement Custom Vein Mining Executor in Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt This snippet demonstrates how to create a custom vein mining scanning algorithm by extending `SequencedVeinMiningExecutorGenerator`. The example `VerticalColumnExecutor` scans blocks in a vertical column, both upwards and downwards from a starting point, and can be registered and used within the Bandit mod. ```kotlin import cn.elytra.mod.bandit.mining.executor.SequencedVeinMiningExecutorGenerator import cn.elytra.mod.bandit.common.mining.VeinMiningContext import com.gtnewhorizon.gtnhlib.blockpos.BlockPos import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow // Custom executor that scans in a vertical column class VerticalColumnExecutor( private val height: Int = 64 ) : SequencedVeinMiningExecutorGenerator() { override fun createSequence(context: VeinMiningContext): Flow = flow { val x = context.center.x val z = context.center.z val startY = context.center.y // Scan upward for (y in startY until minOf(startY + height, 256)) { val pos = BlockPos(x, y, z) if (isBlockMatchingVein(context, pos)) { emit(pos) } } // Scan downward for (y in (startY - 1) downTo maxOf(startY - height, 0)) { val pos = BlockPos(x, y, z) if (isBlockMatchingVein(context, pos)) { emit(pos) } } } override fun getUnlocalizedName(): String = "bandit.executor.vertical-column" } // Register and use the custom executor ExecutorGeneratorRegistry.register(20, VerticalColumnExecutor(height = 32)) // Generate and execute the mining task val executor = VerticalColumnExecutor() val miningTask: suspend () -> Unit = executor.generate(context) // miningTask() will mine all matching blocks in a vertical column ``` -------------------------------- ### Manage Player Vein Mining Data and Settings in Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt The `VeinMiningPlayerData` class handles per-player vein mining state, including active jobs, configuration settings, and cached block data. It allows starting, stopping, and configuring vein mining operations for individual players. ```kotlin import cn.elytra.mod.bandit.common.player_data.veinMiningData import cn.elytra.mod.bandit.common.player_data.VeinMiningPlayerData import cn.elytra.mod.bandit.mining.exception.CommandCancellation // Access player's vein mining data val playerData = player.veinMiningData // Check if mining is in progress if (playerData.hasJobRunning) { println("Player is currently vein mining") } // Configure player settings (auto-persists to world save) playerData.veinMiningExecutorId = 1 // Manhattan+ playerData.veinMiningBlockFilterId = 0 // Match block playerData.harvestedDropPosition = VeinMiningContext.DropPosition.DROP_TO_PLAYER playerData.harvestedDropTiming = VeinMiningContext.DropTiming.EVENTUALLY playerData.stopVeinMiningOnKeyRelease = true // Start vein mining at coordinates playerData.startVeinMining(100, 64, 200) // Stop ongoing vein mining playerData.cancelJob(CommandCancellation()) // Clear player data on disconnect playerData.stopAndClear(PlayerLeftCancellation()) // Get current executor and filter val executor = playerData.getExecutorGenerator() val filter = playerData.getBlockFilter() // Precalculate blocks for preview (if executor supports caching) playerData.precalculateVeinBlocks() val cachedBlocks = playerData.precalculatedVeinBlocks ``` -------------------------------- ### VeinMiningContext Kotlin Configuration Source: https://context7.com/elytraservers/bandit-legacy/llms.txt Demonstrates the creation and usage of the `VeinMiningContext` data class in Kotlin. This class holds the state and configuration for a vein mining operation, including world, position, block type, player, filter, and drop settings. It also shows how to access mining statistics. ```kotlin import cn.elytra.mod.bandit.common.mining.VeinMiningContext import cn.elytra.mod.bandit.common.mining.VeinMiningContext.DropPosition import cn.elytra.mod.bandit.common.mining.VeinMiningContext.DropTiming import cn.elytra.mod.bandit.mining.filter.VeinMiningBlockFilter import com.gtnewhorizon.gtnhlib.blockpos.BlockPos import net.minecraft.init.Blocks // Create a vein mining context for iron ore mining val context = VeinMiningContext( world = player.worldObj, center = BlockPos(100, 64, 200), blockAndMeta = Blocks.iron_ore to 0, blockTileEntity = null, playerSupplier = { player as EntityPlayerMP }, filter = VeinMiningBlockFilter.MATCH_BLOCK, executionId = 1, veinMiningMaxCountLimit = 256, // Max blocks to mine veinMiningCountPerOperation = 64, // Blocks per tick batch harvestedDropPosition = DropPosition.DROP_TO_PLAYER, harvestedDropTiming = DropTiming.ITEM_IMMEDIATELY_XP_EVENTUALLY ) // Access player and stats during mining val currentPlayer = context.getPlayer() val blocksMined = context.statBlocksMined.get() val itemsDropped = context.statItemDropped val xpCollected = context.statXpValueCollected.get() ``` -------------------------------- ### Implement Custom Vein Mining Block Filters in Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt Demonstrates creating custom block filters for vein mining using `DelegatedBlockFilter` for simple lambda-based filters and implementing the `VeinMiningBlockFilter` interface directly for more complex logic. These filters control which blocks are considered for vein mining. ```kotlin import cn.elytra.mod.bandit.mining.filter.VeinMiningBlockFilter import cn.elytra.mod.bandit.mining.filter.DelegatedBlockFilter import cn.elytra.mod.bandit.common.mining.VeinMiningContext import com.gtnewhorizon.gtnhlib.blockpos.BlockPos // Simple filter using DelegatedBlockFilter val hardnessFilter = DelegatedBlockFilter("bandit.block-filter.hardness") { context, pos -> val block = context.world.getBlock(pos.x, pos.y, pos.z) val hardness = block.getBlockHardness(context.world, pos.x, pos.y, pos.z) hardness >= 0 && hardness <= 5.0f // Only mine blocks with hardness 0-5 } // Complex filter implementing the interface directly class OreGroupFilter( private val oreNames: Set ) : VeinMiningBlockFilter { override fun isBlockMatching(context: VeinMiningContext, pos: BlockPos): Boolean { val block = context.world.getBlock(pos.x, pos.y, pos.z) val blockName = block.unlocalizedName.lowercase() return oreNames.any { ore -> blockName.contains(ore) } } override fun getUnlocalizedName(): String = "bandit.block-filter.ore-group" } // Create filter for specific ore types val preciousOresFilter = OreGroupFilter(setOf("gold", "diamond", "emerald", "lapis")) // Register custom filters BlockFilterRegistry.register(20, hardnessFilter) BlockFilterRegistry.register(21, preciousOresFilter) ``` -------------------------------- ### Manage Bandit Mining Executors with Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt The ExecutorGeneratorRegistry allows for the management of available scanning algorithms used in vein mining. It supports retrieving all registered executors, specific executors by ID, or a default executor if a specified ID is not found. Custom executors can also be registered with unique IDs and configurations. ```kotlin import cn.elytra.mod.bandit.mining.ExecutorGeneratorRegistry import cn.elytra.mod.bandit.mining.executor.ManhattanExecutorGenerator import cn.elytra.mod.bandit.mining.executor.LargeScanExecutorGenerator // Get all registered executors val executors = ExecutorGeneratorRegistry.all() // Returns: {0=Manhattan, 1=Manhattan+, 2=Large-scan, 3=Manhattan Large} // Get specific executor by ID val manhattanExecutor = ExecutorGeneratorRegistry.get(0) // Get executor with fallback to default (Manhattan) val executor = ExecutorGeneratorRegistry.getOrDefault(5) // Returns Manhattan if 5 not found // Built-in executors: // ID 0: Manhattan - 8-block radius, scans directly connected neighbors (6 directions) // ID 1: Manhattan+ - 8-block radius, scans 3x3x3 cube neighbors (26 directions) // ID 2: Large-scan - 32-block cube radius, scans all blocks in area // ID 3: Manhattan Large - 16-block radius, scans 3x3x3 cube neighbors // Register a custom executor ExecutorGeneratorRegistry.register(10, ManhattanExecutorGenerator( name = "bandit.executor.custom", maxManhattanRange = 24, plusMode = true )) ``` -------------------------------- ### Accessing Bandit Mod Configuration in Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt Provides a way to access the mod's configuration values at runtime using the `BanditConfig` object. Note that these values are read-only after initialization. ```kotlin import cn.elytra.mod.bandit.BanditConfig // Access configuration values (read-only at runtime) val manhattanRadius = BanditConfig.manhattanRadius // Default: 8 val manhattanLargeRadius = BanditConfig.manhattanLargeRadius // Default: 16 val largeScanRadiusXZ = BanditConfig.largeScanRadiusXZ // Default: 32 val largeScanRadiusY = BanditConfig.largeScanRadiusY // Default: 32 ``` -------------------------------- ### Bandit Legacy In-Game Commands Source: https://context7.com/elytraservers/bandit-legacy/llms.txt Provides a comprehensive list of in-game commands for controlling Bandit Legacy's vein mining functionality. These commands allow users to stop mining, configure scanning algorithms (executors), set block filters, and manage item/XP drop behavior and timing. ```bash # Stop an ongoing vein mining task /bandit stop # View and set executor generator (scanning algorithm) /bandit executor # Show current executor /bandit executor 0 # Set to Manhattan (8-block radius, direct neighbors) /bandit executor 1 # Set to Manhattan+ (8-block radius, 3x3x3 neighbors) /bandit executor 2 # Set to Large-scan (32-block cube radius) /bandit executor 3 # Set to Manhattan Large (16-block radius, 3x3x3 neighbors) # View and set block filter /bandit filter # Show current filter /bandit filter 0 # Match block type only /bandit filter 1 # Match block type and metadata /bandit filter 2 # Match all blocks # Configure drop position /bandit drop_pos # Show current setting /bandit drop_pos drop_at_start # Drop items at first mined block /bandit drop_pos drop_to_player # Drop items at player location # Configure drop timing /bandit drop_timing # Show current setting /bandit drop_timing immediately # Drop items and XP as blocks are mined /bandit drop_timing eventually # Collect all drops, release at end /bandit drop_timing item_immediately_xp_eventually # Items immediate, XP at end # Configure stop-on-key-release behavior /bandit stop_on_release true # Stop mining when keybind is released /bandit stop_on_release false # Continue mining until complete or /bandit stop ``` -------------------------------- ### Manage Bandit Mining Block Filters with Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt The BlockFilterRegistry manages block matching filters essential for vein mining operations. It provides functionality to retrieve all filters, specific filters by ID, or a default filter. Custom filters can be registered to define specific block inclusion criteria. ```kotlin import cn.elytra.mod.bandit.mining.BlockFilterRegistry import cn.elytra.mod.bandit.mining.filter.VeinMiningBlockFilter import cn.elytra.mod.bandit.mining.filter.DelegatedBlockFilter // Get all registered filters val filters = BlockFilterRegistry.all() // Returns: {0=MATCH_BLOCK, 1=MATCH_BLOCK_AND_META, 2=ALL} // Get specific filter val matchBlockFilter = BlockFilterRegistry.get(0) // Get filter with fallback to default (MATCH_BLOCK) val filter = BlockFilterRegistry.getOrDefault(99) // Built-in filters: // ID 0: MATCH_BLOCK - Matches same block type, ignores metadata // ID 1: MATCH_BLOCK_AND_META - Matches block type AND metadata exactly // ID 2: ALL - Matches any block // Use filter to check if block matches val matches = VeinMiningBlockFilter.MATCH_BLOCK.isBlockMatching(context, BlockPos(100, 64, 200)) // Register a custom filter BlockFilterRegistry.register(10, DelegatedBlockFilter("bandit.block-filter.ores-only") { context, pos -> val block = context.world.getBlock(pos.x, pos.y, pos.z) block.unlocalizedName.contains("ore", ignoreCase = true) }) ``` -------------------------------- ### Network Synchronization with BanditNetwork in Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt Handles client-server communication for syncing vein mining state, settings, and notifications. This includes syncing settings, block caches, and various types of notifications to clients. ```kotlin import cn.elytra.mod.bandit.network.BanditNetwork import cn.elytra.mod.bandit.common.player_data.VeinMiningNoticeType import com.gtnewhorizon.gtnhlib.blockpos.BlockPos // Client-side: Sync settings to server BanditNetwork.syncStatusToServer(status = true) // Enable vein mining BanditNetwork.syncSettingsToServer(executorId = 1, blockFilterId = 0) // Server-side: Sync settings to client BanditNetwork.syncSettingsToClient(playerMP, executorId = 2, blockFilterId = 1) // Sync block cache to client for preview rendering val blockPositions = listOf(BlockPos(100, 64, 200), BlockPos(101, 64, 200)) BanditNetwork.syncBlockCacheToClient(playerMP, blockPositions) // Send notification to client val noticeId = BanditNetwork.pushSimpleNoticeToClient( p = playerMP, noticeType = VeinMiningNoticeType.TASK_STARTING, fadeDelay = 0, // Ticks before fade starts fadeTicks = 0 // Fade duration (0 = no auto-fade) ) // Send completion notification with statistics BanditNetwork.pushCompletionNoticeToClient( p = playerMP, extraData = mapOf( "statBlocksMined" to 128, "statItemDropped" to 256 ), fadeDelay = 40, fadeTicks = 20 ) // Manually end a notification BanditNetwork.endNoticeToClient(playerMP, noticeId, fadeDelay = 10, fadeTicks = 20) ``` -------------------------------- ### Configuration File Structure for Bandit Legacy Source: https://context7.com/elytraservers/bandit-legacy/llms.txt Defines the configuration settings for the Bandit mod, stored in `config/bandit.cfg`. These settings control the scanning radii for different executor types. ```properties # config/bandit.cfg executor { # Manhattan and Manhattan+ scanning radius (default: 8) I:manhattan-radius=8 # Manhattan Large scanning radius (default: 16) I:manhattan-large-radius=16 # Large-scan horizontal radius (default: 32) I:large-scan-radius-xz=32 # Large-scan vertical radius (default: 32) I:large-scan-radius-y=32 } ``` -------------------------------- ### Utilize HarvestCollector for Deferred Drop Handling in Kotlin Source: https://context7.com/elytraservers/bandit-legacy/llms.txt The `HarvestCollector` utility allows for the collection of dropped items and experience during block harvesting, enabling deferred processing for performance. It can be used within a scope or manually managed for advanced scenarios. ```kotlin import cn.elytra.mod.bandit.mining.HarvestCollector import net.minecraft.item.ItemStack // Collect drops during block harvesting val (droppedItems, xpValue) = HarvestCollector.withHarvestCollectorScope { // Any block breaking code here will have drops intercepted player.theItemInWorldManager.tryHarvestBlock(x, y, z) player.theItemInWorldManager.tryHarvestBlock(x + 1, y, z) player.theItemInWorldManager.tryHarvestBlock(x + 2, y, z) } // Process collected drops println("Collected ${droppedItems.size} item stacks") println("Total XP value: $xpValue") droppedItems.forEach { itemStack: ItemStack -> println("${itemStack.displayName} x${itemStack.stackSize}") } // Manual collection (for advanced use cases) HarvestCollector.clear() HarvestCollector.shouldCollect = true // ... perform harvesting operations ... HarvestCollector.shouldCollect = false val (items, xp) = HarvestCollector.getAndClear() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.