feat(validation): show toast notification when GLB errors are detected on reload
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user