minecraft-data 2.113.0 → 2.113.1

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,3 +1,6 @@
1
+ ## 2.113.1
2
+ * Add block state IDs to all versions with block data
3
+
1
4
  ## 2.113.0
2
5
  * update mcdata
3
6
 
package/lib/indexes.js CHANGED
@@ -1,6 +1,16 @@
1
1
  const indexer = require('./indexer.js')
2
2
 
3
3
  module.exports = function (mcData) {
4
+ if (mcData.blocks?.length) {
5
+ if (!('minStateId' in mcData.blocks[0]) || !('defaultState' in mcData.blocks[0])) {
6
+ for (const block of mcData.blocks) {
7
+ block.minStateId = block.id << 4
8
+ block.maxStateId = block.minStateId + 15
9
+ block.defaultState = block.minStateId
10
+ }
11
+ }
12
+ }
13
+
4
14
  return {
5
15
  biomesById: indexer.buildIndexFromArray(mcData.biomes, 'id'),
6
16
  biomesByName: indexer.buildIndexFromArray(mcData.biomes, 'name'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecraft-data",
3
- "version": "2.113.0",
3
+ "version": "2.113.1",
4
4
  "description": "Provide easy access to minecraft data in node.js",
5
5
  "main": "index.js",
6
6
  "tonicExampleFilename": "example.js",
package/test/load.js CHANGED
@@ -21,3 +21,26 @@ describe('load', () => {
21
21
  assert.strictEqual(firstDataVersion.isNewerOrEqualTo('15w31c'), true) // no dataVersion
22
22
  })
23
23
  })
24
+
25
+ describe('versions with block data have block state IDs', () => {
26
+ const mcData = require('minecraft-data')
27
+ const versions = require('minecraft-data').versions
28
+ let oks = 0
29
+ for (const type in versions) {
30
+ for (const version of versions[type]) {
31
+ it(type + ' ' + version.minecraftVersion, () => {
32
+ const data = mcData(type + '_' + version.minecraftVersion)
33
+ if (data?.blocks) {
34
+ for (const block of data.blocksArray) {
35
+ assert.ok(block.defaultState > -1)
36
+ oks++
37
+ }
38
+ }
39
+ })
40
+ }
41
+ }
42
+ after(() => {
43
+ console.log(oks, 'OKs')
44
+ assert(oks > 0)
45
+ })
46
+ })