Verification with block rendering and all

This commit is contained in:
ForestOfLight
2025-04-15 19:29:43 -07:00
Unverified
parent 1243cb7d8b
commit 72e9b65d38
16 changed files with 251 additions and 137 deletions
@@ -1,7 +1,7 @@
import { ActionFormData, ModalFormData } from '@minecraft/server-ui';
import { MenuFormBuilder } from './MenuFormBuilder';
import { StructureVerifier } from './StructureVerifier';
import { BlockVerificationLevel } from './BlockVerificationLevel';
import { StructureStatistics } from './StructureStatistics';
export class InstanceEditFormBuilder {
static buildInstance(instance, options) {
@@ -36,20 +36,11 @@ export class InstanceEditFormBuilder {
static async buildStatistics(instance) {
const buildStatisticsForm = new ActionFormData()
.title(MenuFormBuilder.menuTitle)
let message = '';
const structureVerifier = new StructureVerifier(instance, { shouldRender: true });
const statistics = await structureVerifier.verifyStructure();
message += `§fStatistics for §a${instance.name}§f:\n`;
message += `§7Blocks: §2${instance.getTotalVolume() - statistics.correctlyAir}\n`;
message += `§7Correct: §a${this.getFormattedStatistic(statistics, BlockVerificationLevel.Match)}\n`;
message += `§7Block State Incorrect: §e${this.getFormattedStatistic(statistics, BlockVerificationLevel.TypeMatch)}\n`;
message += `§7Incorrect: §c${this.getFormattedStatistic(statistics, BlockVerificationLevel.NoMatch)}\n`;
message += `§7Missing: §c${this.getFormattedStatistic(statistics, BlockVerificationLevel.Missing)}\n`;
buildStatisticsForm.body(message);
return buildStatisticsForm;
}
static getFormattedStatistic(statistics, blockVerificationLevel) {
return `${statistics[blockVerificationLevel]} (${statistics.percentages[blockVerificationLevel].toFixed(2)}%%)`;
const structureVerifier = new StructureVerifier(instance);
const verification = await structureVerifier.verifyStructure();
const statistics = new StructureStatistics(instance, verification);
const statsMessage = statistics.getMessage();
buildStatisticsForm.body(statsMessage);
return { form: buildStatisticsForm, stats: statsMessage };
}
}