feat(validation): show toast notification when GLB errors are detected on reload

This commit is contained in:
NotEvil
2026-04-17 02:20:08 +02:00
parent 9dfd2d1724
commit b0766fecc6
2 changed files with 45 additions and 1 deletions

View File

@@ -6,6 +6,9 @@ import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.toasts.SystemToast;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
@@ -129,6 +132,21 @@ public class GlbValidationReloadListener
"[GltfValidation] Validated {} GLBs: {} passed, {} with warnings, {} with errors",
total, passed, withWarnings, withErrors
);
// Show toast notification for errors so artists don't have to check logs
if (withErrors > 0) {
int errorCount = withErrors;
Minecraft.getInstance().tell(() ->
Minecraft.getInstance().getToasts().addToast(
SystemToast.multiline(
Minecraft.getInstance(),
SystemToast.SystemToastIds.PACK_LOAD_FAILURE,
Component.literal("TiedUp! GLB Validation"),
Component.literal(errorCount + " model(s) have errors. Run /tiedup validate")
)
)
);
}
}
private static boolean hasWarnings(GlbValidationResult result) {