Files
minecraft-data/tools/js/syncPcParticleIds.js
T
4c333f153a Partially updated protocol to 1.19.4 (#703)
* Partially updated protocol to 1.19.4

Bot joins world, works fine
Quick update probly something broken
Incompatible with plugins

* Fix for biomes.json wrong copy

* Correct data version

Just found out where to look for that

* Changed to correct biomes.json from reference

* Change to biome schemas from reference

* add missing packets, rename "session" packet to vanilla "chat_session_update"

* Update protocol.json

* set bundle_delimiter void type

* fix order

* fix particleID numbering

* fix error in particle script
Meant to base off of old protocol data, not new

* fix reserved protocol word, add bundle feature

* add missing fields to damage_event packet

* Update protocol.json

* Update protocol.json

---------

Co-authored-by: TFBosoN <me@tfb.su>
Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
Co-authored-by: extremeheat <extreme@protonmail.ch>
2023-06-03 21:37:29 +02:00

24 lines
1.3 KiB
JavaScript

// Sync particle IDs between pc/particles.json and pc/protocol.json
const fs = require('fs')
const oldParticleData = require('../../data/pc/1.19.3/particles.json')
const oldProtocolData = require('../../data/pc/1.19.3/protocol.json')
const particleData = require('../../data/pc/1.19.4/particles.json')
const protocolData = require('../../data/pc/1.19.4/protocol.json')
// const oldParticleDataByName = Object.fromEntries(oldParticleData.map(e => [e.name, e.id]))
const newParticleDataByName = Object.fromEntries(particleData.map(e => [e.name, e.id]))
const oldIdToNew = Object.fromEntries(oldParticleData.map(e => [e.id, newParticleDataByName[e.name]]))
const ppData = oldProtocolData.types.particleData[1]
const newFields = {}
for (const fieldId in ppData.fields) {
const field = ppData.fields[fieldId]
newFields[oldIdToNew[fieldId]] = field
}
protocolData.types.particleData[1].fields = newFields
const json = JSON.stringify(protocolData, null, 2)
// Matching the custom formatting on the JSON is annoying, let's just keep it JS/vscode default 2-space formatting for consistency
// json = json.replace(/\[\s+"option",\s+"string"\s+\],/g, '["option", "string"],').replace(/\[\s+"option",\s+"string"\s+\]/g, '["option", "string"]')
fs.writeFileSync('./protocol.json', json)