Skip to content

Commit 9d16a1f

Browse files
committed
🚧 Add null state for fully transparent models.
1 parent 0b438c2 commit 9d16a1f

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

schemas/pluginJson.schema.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"required": [
1212
"export_namespace",
1313
"bounding_box",
14-
"display_item",
1514
"custom_model_data_offset",
1615
"baked_animations"
1716
],
@@ -185,6 +184,10 @@
185184
"properties": {
186185
"model": {
187186
"oneOf": [
187+
{
188+
"type": "null",
189+
"description": "If the model is null it means all of the textures for this model were replaced with the internal transparency texture"
190+
},
188191
{ "$ref": "#/definitions/vanillaModel" },
189192
{ "$ref": "#/definitions/variantModel" }
190193
]
@@ -247,7 +250,7 @@
247250
},
248251
"node": {
249252
"type": "object",
250-
"required": ["type", "name", "safe_name", "uuid", "default_transform"],
253+
"required": ["type", "name", "uuid", "default_transform"],
251254
"properties": {
252255
"type": {
253256
"type": "string",
@@ -262,7 +265,6 @@
262265
]
263266
},
264267
"name": { "type": "string" },
265-
"safe_name": { "type": "string" },
266268
"uuid": { "type": "string" },
267269
"parent": { "type": "string" },
268270
"default_transform": {
@@ -436,7 +438,6 @@
436438
"type": "object",
437439
"required": [
438440
"name",
439-
"safe_name",
440441
"duration",
441442
"loop_delay",
442443
"loop_mode",
@@ -446,7 +447,6 @@
446447
"additionalProperties": false,
447448
"properties": {
448449
"name": { "type": "string" },
449-
"safe_name": { "type": "string" },
450450
"duration": { "type": "number" },
451451
"loop_delay": { "type": "number" },
452452
"loop_mode": { "type": "string", "enum": ["none", "loop", "ping-pong"] },
@@ -665,13 +665,9 @@
665665
},
666666
"texture": {
667667
"type": "object",
668-
"required": ["name", "id", "src"],
668+
"required": ["name", "src"],
669669
"properties": {
670670
"name": { "type": "string" },
671-
"id": {
672-
"type": "string",
673-
"description": "The ID of the texture used when making vanilla models."
674-
},
675671
"src": {
676672
"type": "string",
677673
"description": "A data URL containing the texture image."

src/components/animationProperties.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
label={translate('dialog.animation_properties.animation_name.title')}
4242
tooltip={translate('dialog.animation_properties.animation_name.description')}
4343
bind:value={animationName}
44+
defaultValue={'new'}
4445
valueChecker={animationNameValueChecker}
4546
/>
4647

@@ -61,6 +62,7 @@
6162
tooltip={translate('dialog.animation_properties.loop_delay.description')}
6263
min={0}
6364
bind:value={loopDelay}
65+
defaultValue={0}
6466
/>
6567

6668
<Collection

src/systems/datapackCompiler/animation.mcb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,14 @@ dir <%export_namespace%> {
665665
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/variants/<%variant.name%>/apply'}
666666
REPEAT (Object.values(rig.nodes)) as node {
667667
IF (node.type === 'bone' && !variant.excluded_nodes.includes(node.uuid) && (variant.models[node.uuid] !== undefined || node.configs.variants[variant.uuid] !== undefined)) {
668+
668669
execute on passengers if entity @s[tag=aj.<%export_namespace%>.bone.<%node.safe_name%>] run {
669670
IF (variant.models[node.uuid] !== undefined) {
670-
data modify entity @s item.components.minecraft:custom_model_data set value <%variant.models[node.uuid].custom_model_data%>
671+
IF (variant.models[node.uuid].model === null) {
672+
data modify entity @s item.components.minecraft:custom_model_data set value 1
673+
} ELSE {
674+
data modify entity @s item.components.minecraft:custom_model_data set value <%variant.models[node.uuid].custom_model_data%>
675+
}
671676
}
672677
IF (node.configs.variants[variant.uuid]) {
673678
<%%

src/systems/jsonCompiler.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ interface ExportedTexture {
101101
src: string
102102
}
103103
type ExportedVariantModel = Omit<IRenderedVariantModel, 'model_path' | 'resource_location'> & {
104-
model: IRenderedModel
104+
model: IRenderedModel | null
105105
custom_model_data: number
106106
}
107107
type ExportedVariant = Omit<IRenderedVariant, 'models'> & {
@@ -203,14 +203,7 @@ function serializeVariant(rig: IRenderedRig, variant: IRenderedVariant): Exporte
203203
...variant,
204204
models: mapObjEntries(variant.models, (uuid, model) => {
205205
const json: ExportedVariantModel = {
206-
model: {
207-
...model.model,
208-
// textures: mapObjEntries(model.model.textures, (id, path) => {
209-
// const actualTexture = rig.textures[id]
210-
// if (!actualTexture) return [id, path]
211-
// return [id, actualTexture.uuid]
212-
// }),
213-
},
206+
model: model.model,
214207
custom_model_data: model.custom_model_data,
215208
}
216209
return [uuid, json]

src/systems/rigRenderer.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export interface IRenderedNodes {
148148
export type AnyRenderedNode = IRenderedNodes[keyof IRenderedNodes]
149149

150150
export interface IRenderedVariantModel {
151-
model: IRenderedModel
151+
model: IRenderedModel | null
152152
custom_model_data: number
153153
model_path: string
154154
resource_location: string
@@ -383,7 +383,7 @@ function renderGroup(
383383
break
384384
}
385385
case node instanceof Cube: {
386-
renderCube(node, rig, groupModel.model)
386+
renderCube(node, rig, groupModel.model!)
387387
rig.includes_custom_models = true
388388
break
389389
}
@@ -393,7 +393,7 @@ function renderGroup(
393393
}
394394

395395
// Export a struct instead of a bone if no elements are present
396-
if (!groupModel.model.elements || groupModel.model.elements.length === 0) {
396+
if (!groupModel.model || !groupModel.model.elements || groupModel.model.elements.length === 0) {
397397
delete defaultVariant.models[group.uuid]
398398
const struct: IRenderedNodes['Struct'] = {
399399
type: 'struct',
@@ -559,6 +559,9 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
559559
if (variant.excludedNodes.find(v => v.value === uuid)) continue
560560
const textures: IRenderedModel['textures'] = {}
561561

562+
// Is set false if any texture other than the internal transparency texture is found.
563+
let isTransparent = true
564+
562565
for (const [fromUUID, toUUID] of variant.textureMap.map.entries()) {
563566
const fromTexture = Texture.all.find(t => t.uuid === fromUUID)
564567
if (!fromTexture) throw new Error(`From texture not found: ${fromUUID}`)
@@ -573,11 +576,12 @@ function renderVariantModels(variant: Variant, rig: IRenderedRig) {
573576
rig
574577
).resourceLocation
575578
rig.textures[toTexture.id] = toTexture
579+
isTransparent = false
576580
}
577581
}
578582

579-
// Don't export models without any texture changes
580-
if (Object.keys(textures).length === 0) continue
583+
// Don't export models without any texture changes, or that are fully transparent.
584+
if (isTransparent || Object.keys(textures).length === 0) continue
581585

582586
const modelParent = PathModule.join(
583587
rig.model_export_folder,

test_blueprints/armor_stand.ajblueprint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"show_bounding_box": false,
1212
"auto_bounding_box": true,
1313
"bounding_box": [95, 32],
14-
"enable_plugin_mode": false,
14+
"enable_plugin_mode": true,
1515
"resource_pack_export_mode": "raw",
1616
"data_pack_export_mode": "raw",
1717
"display_item": "minecraft:white_dye",
@@ -3061,7 +3061,7 @@
30613061
"override": false,
30623062
"length": 0.8,
30633063
"snapping": 20,
3064-
"selected": false,
3064+
"selected": true,
30653065
"saved": false,
30663066
"path": "",
30673067
"anim_time_update": "",

0 commit comments

Comments
 (0)