Skip to content

Commit

Permalink
Update OptiFine UV validation
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisX11 committed Sep 22, 2024
1 parent 316c716 commit 8589133
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions js/io/formats/optifine_jem.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,12 @@ BARS.defineActions(function() {
})
})

new ValidatorCheck('optifine_jem_uv', {
condition: {formats: ['optifine_entity']},
new ValidatorCheck('zero_wide_uv_faces', {
condition: {formats: ['optifine_entity', 'java_block']},
update_triggers: ['update_selection'],
run() {
for (let cube of Cube.all) {
if (cube.box_uv && Format.id == 'optifine_entity') continue;
let select_cube_button = {
name: 'Select Cube',
icon: 'fa-cube',
Expand All @@ -399,25 +400,16 @@ new ValidatorCheck('optifine_jem_uv', {
for (let fkey in cube.faces) {
let face = cube.faces[fkey];
let uv_size = face.uv_size;
let size_issue, offset_issue;
let size_issue;
for (let i of [0, 1]) {
let size = uv_size[i];
if (Math.roundTo(size, 4) && Math.abs(size) < 1) {
if (Math.abs(size) < 0.00005) {
size_issue = true;
}
if (Math.roundTo(face.uv[i], 4) % 1) {
offset_issue = true;
}
}
if (size_issue) {
this.warn({
message: `The face "${fkey}" on cube "${cube.name}" has invalid UV sizes. UV sizes with an absolute value below 1 but not 0 are invalid in OptiFine models.`,
buttons: [select_cube_button]
})
}
if (offset_issue) {
this.warn({
message: `The face "${fkey}" on cube "${cube.name}" has an invalid UV offset. OptiFine only supports integer values as UV offset.`,
message: `The face "${fkey}" on cube "${cube.name}" has invalid UV sizes. UV sizes cannot be 0.`,
buttons: [select_cube_button]
})
}
Expand Down

0 comments on commit 8589133

Please sign in to comment.