local cache = {} local lastUpdate = {} local searchCooldown = 5 local tickCounter = 0 registerBlockUpdate(function(update) local x, y, z = update.x, update.y, update.z local key = x .. "_" .. y .. "_" .. z cache[key] = update.new lastUpdate[key] = true end) local function findNearestBlock(centerX, centerY, centerZ, horizontal, vertical) local nodes = {} for dx = -horizontal, horizontal do local x = centerX + dx for dz = -horizontal, horizontal do local z = centerZ + dz for dy = -vertical, vertical do local y = centerY + dy local key = x .. "_" .. y .. "_" .. z local blockInfo = cache[key] if not blockInfo or lastUpdate[key] then blockInfo = world.getBlock(x, y, z) cache[key] = blockInfo lastUpdate[key] = nil end if blockInfo and (blockInfo.name == "block.minecraft.purple_terracotta") then table.insert(nodes, { x = x, y = y, z = z}) end end end end return nodes end local nodes = {} registerClientTickPost(function() tickCounter = tickCounter + 1 if tickCounter >= searchCooldown then tickCounter = 0 local centerX = math.floor(player.getPos().x) local centerY = math.floor(player.getPos().y) local centerZ = math.floor(player.getPos().z) threads.startThread(function() nodes = findNearestBlock(centerX, centerY, centerZ, 21, 13) end) end end) registerWorldRenderer(function(context) local renderColors = { {blocks = nodes, r = 255, g = 85, b = 255}, } for _, config in ipairs(renderColors) do for _, block in ipairs(config.blocks) do context.renderFilled({ x = block.x, y = block.y, z = block.z, red = config.r, green = config.g, blue = config.b, alpha = 190, through_walls = true }) end end end)