From 836a5efa51a7364f7a10d1c56ba4a07ce2afc104 Mon Sep 17 00:00:00 2001 From: Pix3lPirat3 Date: Sun, 13 Sep 2026 01:03:51 -0700 Subject: [PATCH] Expose block selection shapes in the data API Expose optional blockSelectionShapes through the indexed API and generated TypeScript declarations. Keep collision data separate and preserve absence for versions without selection data. Depends on the new minecraft-data schema and datasets. --- lib/loader.js | 1 + test/selectionShapes.js | 17 +++++++++++++++++ typings/index-template.d.ts | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 test/selectionShapes.js 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 }