Support unhandled fields and render_type in java block

This commit is contained in:
JannisX11 2022-12-23 23:29:55 +01:00
parent f1d00ec8b3
commit d065d3f206
3 changed files with 18 additions and 0 deletions

View File

@ -101,6 +101,7 @@ class ModelFormat {
Undo.history.empty();
Undo.index = 0;
Project.export_path = '';
Project.unhandled_root_fields = {};
var old_format = Format;
this.select();

View File

@ -201,6 +201,9 @@ var codec = new Codec('java_block', {
if (checkExport('ambientocclusion', Project.ambientocclusion === false)) {
blockmodel.ambientocclusion = false
}
if (Project.unhandled_root_fields.render_type) {
blockmodel.render_type = Project.unhandled_root_fields.render_type;
}
if (Project.texture_width !== 16 || Project.texture_height !== 16) {
blockmodel.texture_size = [Project.texture_width, Project.texture_height]
}
@ -244,6 +247,9 @@ var codec = new Codec('java_block', {
blockmodel.groups = groups
}
}
for (let key in Project.unhandled_root_fields) {
if (blockmodel[key] === undefined) blockmodel[key] = Project.unhandled_root_fields[key];
}
this.dispatchEvent('compile', {model: blockmodel, options});
if (options.raw) {
return blockmodel
@ -489,6 +495,13 @@ var codec = new Codec('java_block', {
if (model.gui_light === 'front') {
Project.front_gui_light = true;
}
let supported_fields = new Set(['textures', 'elements', 'groups', 'parent', 'display', '__comment', 'credit', 'texture_size', 'overrides', 'ambientocclusion', 'gui_light']);
for (let key in model) {
if (!supported_fields.has(key)) {
Project.unhandled_root_fields[key] = model[key];
}
}
this.dispatchEvent('parsed', {model});
if (add) {
Undo.finishEdit('Add block model')

View File

@ -468,6 +468,10 @@ new Property(ModelProject, 'array', 'timeline_setups', {
exposed: false,
condition: () => Format.animation_mode,
});
new Property(ModelProject, 'object', 'unhandled_root_fields', {
exposed: false,
default: {}
});
ModelProject.all = [];