minecraft-data 3.44.0 → 3.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/doc/history.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # History
2
2
 
3
+ ## 3.45.0
4
+
5
+ * update `minecraft-data`
6
+
3
7
  ## 3.44.0
4
8
 
5
9
  * update `minecraft-data`
@@ -1,28 +1,9 @@
1
1
  const fs = require('fs')
2
2
  const cp = require('child_process')
3
- const https = require('https')
4
3
  const helper = require('./github-helper')
5
4
  const pcManifestURL = 'https://launchermeta.mojang.com/mc/game/version_manifest.json'
6
5
  const changelogURL = 'https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs'
7
6
 
8
- // this is a polyfill for node <18
9
- const fetch = globalThis.fetch || function (url) {
10
- return new Promise((resolve, reject) => {
11
- https.get(url, (res) => {
12
- let data = ''
13
- res.on('data', (chunk) => {
14
- data += chunk
15
- })
16
- res.on('end', () => {
17
- resolve({
18
- ok: true,
19
- text: () => Promise.resolve(data),
20
- json: () => Promise.resolve(JSON.parse(data))
21
- })
22
- })
23
- }).on('error', reject)
24
- })
25
- }
26
7
  const download = (url, dest) => cp.execSync(`curl -L ${url} -o ${dest}`)
27
8
 
28
9
  function buildFirstIssue (title, result, jarData) {
@@ -65,43 +46,78 @@ async function updateManifestPC () {
65
46
  const manifest = await fetch(pcManifestURL).then(res => res.json())
66
47
  // fs.writeFileSync('./manifest.json', JSON.stringify(manifest, null, 2))
67
48
  const knownVersions = protocolVersions.pc.reduce((acc, cur) => (acc[cur.minecraftVersion] = cur, acc), {})
68
- const latestRelease = manifest.latest.release
49
+ const latestVersion = manifest.latest.snapshot
50
+ const latestVersionData = manifest.versions.find(v => v.id === latestVersion)
51
+ const latestVersionIsSnapshot = latestVersionData.type !== 'release'
69
52
 
70
- const title = `Support Minecraft PC ${latestRelease}`
53
+ const title = `Support Minecraft PC ${latestVersion}`
71
54
  const issueStatus = await helper.getIssueStatus(title)
72
55
 
73
- if (supportedVersions.pc.includes(latestRelease)) {
74
- if (issueStatus.open) {
75
- helper.close(issueStatus.id, `Closing as PC ${latestRelease} is now supported`)
56
+ if (latestVersionIsSnapshot) {
57
+ // don't make issues for snapshots
58
+ if (supportedVersions.pc.includes(latestVersion) || knownVersions[latestVersion]) {
59
+ console.log('Latest version is a known snapshot, no work to do')
60
+ return
76
61
  }
77
- console.log('Latest PC version is supported.')
78
- return
79
- } else if (knownVersions[latestRelease]) {
80
- console.log(`Latest PC version ${latestRelease} is known in protocolVersions.json, but not in versions.json (protocol version ${knownVersions[latestRelease].version})`)
81
- return
82
62
  } else {
83
- console.log(`Latest PC version ${latestRelease} is not known in protocolVersions.json, adding and making issue`)
63
+ if (supportedVersions.pc.includes(latestVersion)) {
64
+ if (issueStatus.open) {
65
+ helper.close(issueStatus.id, `Closing as PC ${latestVersion} is now supported`)
66
+ }
67
+ console.log('Latest PC version is supported.')
68
+ return
69
+ } else if (knownVersions[latestVersion]) {
70
+ console.log(`Latest PC version ${latestVersion} is known in protocolVersions.json, but not in versions.json (protocol version ${knownVersions[latestVersion].version})`)
71
+ return
72
+ } else {
73
+ console.log(`Latest PC version ${latestVersion} is not known in protocolVersions.json, adding and making issue`)
74
+ }
84
75
  }
85
- const latestReleaseData = manifest.versions.find(v => v.id === latestRelease)
86
76
 
87
- // Note: We don't use the below check to track if the version is supported properly or not
88
- // (data like protocol/blocks/items/etc is present), just to make sure the known protocol version is correct.
77
+ let versionJson
89
78
  try {
90
- const latestReleaseManifest = await fetch(latestReleaseData.url).then(res => res.json())
79
+ versionJson = await addEntryFor(latestVersion, latestVersionData)
80
+ } catch (e) {
81
+ console.error(e)
82
+
83
+ if (latestVersionIsSnapshot) {
84
+ console.warn('Failed to update protocolVersions.json for the snapshot', latestVersion)
85
+ } else {
86
+ console.log('Latest PC version is not supported and we failed to load data. Opening issue...')
87
+ const issuePayload = buildFirstIssue(title, latestVersionData)
88
+ helper.createIssue(issuePayload)
89
+
90
+ fs.writeFileSync('./issue.md', issuePayload.body)
91
+ console.log('OK, wrote to ./issue.md', issuePayload)
92
+ }
93
+ }
94
+
95
+ if (!latestVersionIsSnapshot && !issueStatus.open && !issueStatus.closed) {
96
+ console.log('Opening issue', versionJson)
97
+ const issuePayload = buildFirstIssue(title, latestVersionData, versionJson)
98
+
99
+ helper.createIssue(issuePayload)
100
+
101
+ fs.writeFileSync('./issue.md', issuePayload.body)
102
+ console.log('OK, wrote to ./issue.md', issuePayload)
103
+ }
104
+
105
+ async function addEntryFor (releaseVersion, releaseData) {
106
+ const latestReleaseManifest = await fetch(releaseData.url).then(res => res.json())
91
107
  // Download client jar
92
- if (!fs.existsSync(`./${latestRelease}.jar`)) {
108
+ if (!fs.existsSync(`./${releaseVersion}.jar`)) {
93
109
  const clientJarUrl = latestReleaseManifest.downloads.client.url
94
110
  console.log('Downloading client jar', clientJarUrl)
95
- download(clientJarUrl, `./${latestRelease}.jar`)
111
+ download(clientJarUrl, `./${releaseVersion}.jar`)
96
112
  }
97
113
 
98
114
  // Log the byte size of the client jar
99
- const clientJarSize = fs.statSync(`./${latestRelease}.jar`).size
100
- console.log(`Downloaded client jar ${latestRelease}.jar (${clientJarSize} bytes), extracting its version.json...`)
115
+ const clientJarSize = fs.statSync(`./${releaseVersion}.jar`).size
116
+ console.log(`Downloaded client jar ${releaseVersion}.jar (${clientJarSize} bytes), extracting its version.json...`)
101
117
 
102
118
  // unzip with tar / unzip, Actions image uses 7z
103
- if (process.platform === 'win32') cp.execSync(`tar -xf ./${latestRelease}.jar version.json`)
104
- else cp.execSync(`7z -y e ./${latestRelease}.jar version.json`, { stdio: 'inherit' })
119
+ if (process.platform === 'win32') cp.execSync(`tar -xf ./${releaseVersion}.jar version.json`)
120
+ else cp.execSync(`7z -y e ./${releaseVersion}.jar version.json`, { stdio: 'inherit' })
105
121
  const versionJson = require('./version.json')
106
122
 
107
123
  let majorVersion
@@ -118,7 +134,7 @@ async function updateManifestPC () {
118
134
  dataVersion: versionJson.world_version,
119
135
  usesNetty: true,
120
136
  majorVersion,
121
- releaseType: latestReleaseData.type
137
+ releaseType: latestVersionData.type
122
138
  }
123
139
  console.log('Adding new entry to pc protocolVersions.json', newEntry)
124
140
  const updatedProtocolVersions = [newEntry, ...protocolVersions.pc]
@@ -134,24 +150,7 @@ async function updateManifestPC () {
134
150
  cp.execSync('git push')
135
151
  }
136
152
 
137
- if (!issueStatus.open && !issueStatus.closed) {
138
- console.log('Opening issue', versionJson)
139
- const issuePayload = buildFirstIssue(title, latestReleaseData, versionJson)
140
-
141
- helper.createIssue(issuePayload)
142
-
143
- fs.writeFileSync('./issue.md', issuePayload.body)
144
- console.log('OK, wrote to ./issue.md', issuePayload)
145
- }
146
- } catch (e) {
147
- console.error(e)
148
-
149
- console.log('Latest PC version is not supported and we failed to load data. Opening issue...')
150
- const issuePayload = buildFirstIssue(title, latestReleaseData)
151
- helper.createIssue(issuePayload)
152
-
153
- fs.writeFileSync('./issue.md', issuePayload.body)
154
- console.log('OK, wrote to ./issue.md', issuePayload)
153
+ return versionJson
155
154
  }
156
155
  }
157
156
 
@@ -14,7 +14,7 @@ jobs:
14
14
  - name: Set up Node.js
15
15
  uses: actions/setup-node@master
16
16
  with:
17
- node-version: 16.0.0
17
+ node-version: 18.0.0
18
18
  - name: Install Github Actions toolkit
19
19
  run: npm i @actions/github
20
20
  working-directory: .github/helper-bot
@@ -1,4 +1,14 @@
1
1
  [
2
+ {
3
+ "name": "smallWorld",
4
+ "description": "world height is 128 blocks",
5
+ "version": "0.14.3"
6
+ },
7
+ {
8
+ "name": "usesPalettedChunks",
9
+ "description": "the chunk format uses local palettes",
10
+ "versions": ["1.16_major", "latest"]
11
+ },
2
12
  {
3
13
  "name": "newRecipeSchema",
4
14
  "description": "New recipe schema",