Skip to content

Commit d888ad5

Browse files
committed
0.4.5
Add #155 Add #154 Fix #153 Added duplicate Variant action, and Variant sorting to the Variants panel
1 parent 823caf2 commit d888ad5

File tree

11 files changed

+123
-241
lines changed

11 files changed

+123
-241
lines changed

exporters/jsonExporter/jsonConstructor.ts

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ interface ISerializedNodeAnimationFrameEntry {
3232
}
3333

3434
interface ISerealizedAnimation {
35-
frames: ISerializedAnimationFrame[]
35+
start_delay?: number
36+
loop_delay?: number
3637
duration: number
3738
loop_mode: 'once' | 'hold' | 'loop'
3839
affected_bones: string[]
3940
affected_bones_is_a_whitelist: boolean
41+
frames: ISerializedAnimationFrame[]
4042
}
4143

4244
interface ISerializedNode {
4345
type: NodeType
4446
name: string
4547
uuid: string
46-
custom_model_data: number
47-
resource_location: string
48+
nbt: string
49+
custom_model_data?: number
50+
resource_location?: string
4851
}
4952

5053
interface ISerializedVariant {
@@ -92,21 +95,40 @@ function serializeNodeAnimationFrameEntry(
9295
}
9396
}
9497

95-
function serializeNodeMap(nodeMap: Record<string, any>): Record<string, ISerializedNode> {
98+
function serializeNodeMap(
99+
nodeMap: Record<string, AnimatedJava.IRenderedNodes[keyof AnimatedJava.IRenderedNodes]>
100+
): Record<string, ISerializedNode> {
96101
const serializedNodeMap: Record<string, ISerializedNode> = {}
97102
for (const uuid in nodeMap) {
98103
const node = nodeMap[uuid]
99104
const type = node.type
100105
const name = node.name
101-
const custom_model_data = node.customModelData
102-
const resource_location = node.resourceLocation
103-
104-
serializedNodeMap[uuid] = {
105-
type,
106-
name,
107-
uuid,
108-
custom_model_data,
109-
resource_location,
106+
107+
switch (type) {
108+
case 'bone': {
109+
const custom_model_data = node.customModelData
110+
const resource_location = node.resourceLocation
111+
112+
serializedNodeMap[uuid] = {
113+
type,
114+
name,
115+
uuid,
116+
nbt: node.nbt,
117+
custom_model_data,
118+
resource_location,
119+
}
120+
121+
break
122+
}
123+
case 'camera':
124+
case 'locator': {
125+
serializedNodeMap[uuid] = {
126+
type,
127+
name,
128+
uuid,
129+
nbt: node.nbt,
130+
}
131+
}
110132
}
111133
}
112134
return serializedNodeMap
@@ -155,6 +177,8 @@ function serializeAnimationFrame(
155177
}
156178

157179
function serializeAnimation(animation: AnimatedJava.IRenderedAnimation): ISerealizedAnimation {
180+
const start_delay = animation.startDelay
181+
const loop_delay = animation.loopDelay
158182
const frames = animation.frames.map(serializeAnimationFrame)
159183
const duration = animation.duration
160184
const loop_mode = animation.loopMode
@@ -165,6 +189,8 @@ function serializeAnimation(animation: AnimatedJava.IRenderedAnimation): ISereal
165189
const affected_bones_is_a_whitelist = bbAnimation.affected_bones_is_a_whitelist
166190

167191
return {
192+
start_delay,
193+
loop_delay,
168194
frames,
169195
duration,
170196
loop_mode,

exporters/jsonExporter/jsonStructure.json

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
23
"title": "JSON Exporter Structure",
34
"type": "object",
45
"required": ["project_settings", "exporter_settings", "rig", "variants", "animations"],
@@ -52,13 +53,13 @@
5253
}
5354
}
5455
},
55-
"$def": {
56+
"definitions": {
5657
"node_type": {
5758
"enum": ["bone", "locator", "camera"]
5859
},
5960
"node": {
6061
"type": "object",
61-
"required": ["type", "name", "uuid", "custom_model_data", "resource_location"],
62+
"required": ["type", "name", "uuid"],
6263
"properties": {
6364
"type": {
6465
"$ref": "#/definitions/node_type"
@@ -74,6 +75,9 @@
7475
},
7576
"resource_location": {
7677
"type": "string"
78+
},
79+
"nbt": {
80+
"type": "string"
7781
}
7882
}
7983
},
@@ -129,14 +133,17 @@
129133
"affected_bones_is_a_whitelist"
130134
],
131135
"properties": {
132-
"frames": {
133-
"type": "array",
134-
"items": {
135-
"$ref": "#/definitions/animation_frame"
136-
}
136+
"start_delay": {
137+
"type": "number",
138+
"minimum": 0
139+
},
140+
"loop_delay": {
141+
"type": "number",
142+
"minimum": 0
137143
},
138144
"duration": {
139-
"type": "number"
145+
"type": "number",
146+
"minimum": 0
140147
},
141148
"loop_mode": {
142149
"$ref": "#/definitions/animation_loop_mode"
@@ -151,6 +158,12 @@
151158
"affected_bones_is_a_whitelist": {
152159
"type": "boolean",
153160
"description": "If true, only the bones in the list are affected. If false, all bones except those in the list are affected."
161+
},
162+
"frames": {
163+
"type": "array",
164+
"items": {
165+
"$ref": "#/definitions/animation_frame"
166+
}
154167
}
155168
}
156169
},

exporters/jsonExporter/jsonStructure.yaml

Lines changed: 0 additions & 213 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "module",
33
"name": "animated_java",
44
"title": "Animated Java",
5-
"version": "0.4.4",
5+
"version": "0.4.5",
66
"min_blockbench_version": "4.6.5",
77
"author": {
88
"name": "Titus Evans (SnaveSutit)",

src/lang/en.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ animated_java.actions.add_variant.name: Add Variant
250250
animated_java.actions.add_variant.description: Create a new Variant
251251
animated_java.actions.variant_properties.name: Variant Properties
252252
animated_java.actions.variant_properties.description: Open the Variant properties dialog.
253+
animated_java.actions.duplicate_variant.name: Duplicate Variant
254+
animated_java.actions.duplicate_variant.description: Duplicate this Variant.
253255

254256
### Variants Properties Dialog
255257
animated_java.dialog.variant_properties.title: Variant Properties

0 commit comments

Comments
 (0)