Support OptiFine shadow size and attach

This commit is contained in:
JannisX11 2021-08-08 23:43:06 +02:00
parent 5f9bbb3714
commit c1be9dcc8c
4 changed files with 13 additions and 1 deletions

View File

@ -19,6 +19,7 @@ var codec = new Codec('optifine_entity', {
entitymodel.texture = Texture.getDefault().name
}
entitymodel.textureSize = [Project.texture_width, Project.texture_height];
if (Project.shadow_size != 1) entitymodel.shadowSize = Math.clamp(Project.shadow_size, 0, 1);
entitymodel.models = []
Outliner.root.forEach(function(g) {
@ -49,6 +50,9 @@ var codec = new Codec('optifine_entity', {
if (g.mirror_uv) {
bone.mirrorTexture = 'u'
}
if (g.cem_attach) {
bone.attach = true;
}
function populate(p_model, group, depth) {
@ -156,6 +160,7 @@ var codec = new Codec('optifine_entity', {
Project.texture_width = parseInt(model.textureSize[0])||16;
Project.texture_height = parseInt(model.textureSize[1])||16;
}
if (typeof model.shadowSize == 'number') Project.shadow_size = model.shadowSize;
let empty_face = {uv: [0, 0, 0, 0], texture: null}
if (model.models) {
model.models.forEach(function(b) {
@ -168,7 +173,8 @@ var codec = new Codec('optifine_entity', {
origin: b.translate,
rotation: b.rotate,
mirror_uv: (b.mirrorTexture && b.mirrorTexture.includes('u')),
cem_animations: b.animations
cem_animations: b.animations,
cem_attach: b.attach
})
group.origin[1] *= -1;
group.origin[2] *= -1;

View File

@ -283,6 +283,10 @@ new Property(ModelProject, 'vector', 'visible_box', {
new Property(ModelProject, 'string', 'variable_placeholders', {
exposed: false,
});
new Property(ModelProject, 'number', 'shadow_size', {
label: 'dialog.project.shadow_size',
condition: {formats: ['optifine_entity']}
});
ModelProject.all = [];

View File

@ -486,6 +486,7 @@ class Group extends OutlinerNode {
new Property(Group, 'vector', 'rotation');
new Property(Group, 'string', 'bedrock_binding', {condition: () => Format.id == 'bedrock'});
new Property(Group, 'array', 'cem_animations', {condition: () => Format.id == 'optifine_entity'});
new Property(Group, 'boolean', 'cem_attach', {condition: () => Format.id == 'optifine_entity'});
new Property(Group, 'number', 'color');

View File

@ -278,6 +278,7 @@
"dialog.project.uv_mode.box_uv": "Box UV",
"dialog.project.uv_mode.face_uv": "Per-face UV",
"dialog.project.texture_size": "Texture Size",
"dialog.project.shadow_size": "Shadow Size",
"dialog.convert_project.title": "Convert Project",
"dialog.convert_project.text": "Are you sure you want to convert this project? You cannot undo this step.",