diff --git a/lib/loader.js b/lib/loader.js index e8771668..494c0f43 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -11,6 +11,7 @@ function mcDataToNode (mcData) { blockStates: mcData.blockStates, // bedrock blockCollisionShapes: mcData.blockCollisionShapes, + blockSelectionShapes: mcData.blockSelectionShapes, biomes: indexes.biomesById, biomesByName: indexes.biomesByName, diff --git a/test/selectionShapes.js b/test/selectionShapes.js new file mode 100644 index 00000000..ac696084 --- /dev/null +++ b/test/selectionShapes.js @@ -0,0 +1,17 @@ +/* eslint-env mocha */ +const assert = require('assert') +const convert = require('../lib/loader') + +describe('selection shapes', () => { + it('exports selection data independently of collision data', () => { + const collision = { blocks: { wheat: 0 }, shapes: { 0: [] } } + const selection = { blocks: { wheat: 0 }, shapes: { 0: [[0, 0, 0, 1, 0.125, 1]] } } + const data = convert({ blockCollisionShapes: collision, blockSelectionShapes: selection }) + assert.strictEqual(data.blockCollisionShapes, collision) + assert.strictEqual(data.blockSelectionShapes, selection) + }) + + it('leaves selection data unavailable for datasets without it', () => { + assert.strictEqual(convert({}).blockSelectionShapes, undefined) + }) +}) diff --git a/typings/index-template.d.ts b/typings/index-template.d.ts index 1a3bfd84..ed6f41f1 100644 --- a/typings/index-template.d.ts +++ b/typings/index-template.d.ts @@ -123,6 +123,9 @@ export interface IndexedData { */ blockCollisionShapes: { blocks: { [name: string]: number | number[] }; shapes: { [id: string]: [number[]] } } + /** Java selection geometry, when available for this version. */ + blockSelectionShapes?: BlockSelectionShapes + loginPacket: LoginPacket items: { [id: number]: Item }