Skip to content

Commit cb2f0c7

Browse files
committed
Fix including interaction data in plugin export
1 parent adf6689 commit cb2f0c7

3 files changed

Lines changed: 55 additions & 16 deletions

File tree

schemas/example-plugin-blueprint.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "./plugin-blueprint.schema.json",
3-
"format_version": 1,
3+
"format_version": 2,
44
"settings": {
55
"id": "animated_java:blueprint"
66
},
@@ -39,7 +39,7 @@
3939
"rotation": [5, 180, 0],
4040
"head_rotation": [5, 180]
4141
},
42-
"display_properties": {
42+
"entity_properties": {
4343
"billboard": "vertical",
4444
"custom_brightness": 10,
4545
"custom_name": "'Bone Node'",
@@ -198,7 +198,7 @@
198198
},
199199
"position": [0, 1.625, 0]
200200
},
201-
"display_properties": {
201+
"entity_properties": {
202202
"billboard": "vertical",
203203
"is_glowing": true,
204204
"shadow_radius": 3.0,
@@ -224,7 +224,7 @@
224224
"head_rotation": [4.61854, 202.57734],
225225
"scale": [1.0625, 1.125, 1]
226226
},
227-
"display_properties": {
227+
"entity_properties": {
228228
"billboard": "horizontal",
229229
"custom_brightness": 15,
230230
"custom_name": "'Block Display Node'",
@@ -235,7 +235,7 @@
235235
},
236236
"text_display_node": {
237237
"type": "text_display",
238-
"display_properties": {
238+
"entity_properties": {
239239
"custom_brightness": 5,
240240
"is_custom_brightness_enabled": true,
241241
"is_glowing": true,

schemas/plugin-blueprint.schema.json

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
"type": "object",
184184
"required": ["elements"],
185185
"properties": {
186-
"display_properties": {
186+
"entity_properties": {
187187
"$ref": "#/definitions/bone_display_properties"
188188
},
189189
"elements": {
@@ -204,7 +204,7 @@
204204
"then": {
205205
"type": "object",
206206
"properties": {
207-
"display_properties": {
207+
"entity_properties": {
208208
"$ref": "#/definitions/item_display_properties"
209209
}
210210
}
@@ -219,7 +219,7 @@
219219
"then": {
220220
"type": "object",
221221
"properties": {
222-
"display_properties": {
222+
"entity_properties": {
223223
"$ref": "#/definitions/block_display_properties"
224224
}
225225
}
@@ -234,12 +234,27 @@
234234
"then": {
235235
"type": "object",
236236
"properties": {
237-
"display_properties": {
237+
"entity_properties": {
238238
"$ref": "#/definitions/text_display_properties"
239239
}
240240
}
241241
}
242242
},
243+
{
244+
"if": {
245+
"properties": {
246+
"type": { "const": "interaction" }
247+
}
248+
},
249+
"then": {
250+
"type": "object",
251+
"properties": {
252+
"entity_properties": {
253+
"$ref": "#/definitions/interaction_entity_properties"
254+
}
255+
}
256+
}
257+
},
243258
{
244259
"if": {
245260
"properties": {
@@ -609,6 +624,20 @@
609624
}
610625
]
611626
},
627+
"interaction_entity_properties": {
628+
"type": "object",
629+
"default": {},
630+
"properties": {
631+
"width": {
632+
"type": "number",
633+
"default": 1
634+
},
635+
"height": {
636+
"type": "number",
637+
"default": 1
638+
}
639+
}
640+
},
612641
"dynamic_animation": {
613642
"type": "object",
614643
"required": ["loop_mode", "length"],

src/systems/pluginCompiler.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ type NodeType =
113113
| 'item_display'
114114
| 'block_display'
115115
| 'text_display'
116+
| 'interaction'
116117
| 'structure'
117118
| 'camera'
118119
| 'locator'
@@ -122,14 +123,14 @@ type PluginNode =
122123
type: 'bone'
123124
parent?: string
124125
default_transformation?: NodeTransformation
125-
display_properties?: Record<string, unknown>
126+
entity_properties?: Record<string, unknown>
126127
elements: BoneElement[]
127128
}
128129
| {
129130
type: Exclude<NodeType, 'bone'>
130131
parent?: string
131132
default_transformation?: NodeTransformation
132-
display_properties?: Record<string, unknown>
133+
entity_properties?: Record<string, unknown>
133134
}
134135

135136
type LoopMode = { type: 'once' } | { type: 'hold' } | { type: 'loop'; loop_delay?: string }
@@ -364,7 +365,7 @@ function serializeNode(
364365
return scrubUndefined({
365366
type: 'bone',
366367
...base,
367-
display_properties: displayProps,
368+
entity_properties: displayProps,
368369
elements: serializeBoneElements(model, {
369370
textureIdToKey: options.textureIdToKey,
370371
textureKeyToPaletteId: options.textureKeyToPaletteId,
@@ -375,7 +376,7 @@ function serializeNode(
375376
return scrubUndefined({
376377
type: 'item_display',
377378
...base,
378-
display_properties: scrubUndefined({
379+
entity_properties: scrubUndefined({
379380
...displayProps,
380381
item: (node as any).item,
381382
item_display: (node as any).item_display,
@@ -386,7 +387,7 @@ function serializeNode(
386387
return scrubUndefined({
387388
type: 'block_display',
388389
...base,
389-
display_properties: scrubUndefined({
390+
entity_properties: scrubUndefined({
390391
...displayProps,
391392
block_state: (node as any).block,
392393
}),
@@ -397,7 +398,7 @@ function serializeNode(
397398
return scrubUndefined({
398399
type: 'text_display',
399400
...base,
400-
display_properties: scrubUndefined({
401+
entity_properties: scrubUndefined({
401402
...displayProps,
402403
alignment: (node as any).align,
403404
background_color: argb,
@@ -409,6 +410,15 @@ function serializeNode(
409410
}),
410411
} satisfies PluginNode)
411412
}
413+
case 'interaction':
414+
return scrubUndefined({
415+
type: 'interaction',
416+
...base,
417+
entity_properties: {
418+
width: node.width,
419+
height: node.height,
420+
},
421+
})
412422
case 'struct':
413423
return { type: 'structure', ...base }
414424
case 'camera':
@@ -704,7 +714,7 @@ export function exportPluginBlueprint(options: {
704714
}
705715

706716
const blueprint: PluginBlueprintJson = scrubUndefined({
707-
format_version: 1,
717+
format_version: 2,
708718
settings: {
709719
id: aj.blueprint_id,
710720
},

0 commit comments

Comments
 (0)