mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 09:35:35 -05:00
15 lines
653 B
JavaScript
15 lines
653 B
JavaScript
const { instrumentsArray } = require('minecraft-data')('1.15.2') // chip hardcoding moment
|
|
|
|
function parseTXTSong (data) {
|
|
let length = 0
|
|
const notes = String(data).split(/\r\n|\r|\n/).map(line => {
|
|
const [tick, pitch, instrument] = line.split(':').map(Number)
|
|
if (tick === undefined || pitch === undefined || instrument === undefined) return undefined
|
|
const time = tick * 50
|
|
length = Math.max(length, time)
|
|
return { time, pitch, instrument: instrumentsArray[instrument].name, volume: 1 }
|
|
}).filter(note => note !== undefined)
|
|
return { name: '', notes, loop: false, loopPosition: 0, length }
|
|
}
|
|
|
|
module.exports = parseTXTSong
|