Block verifier correct

This commit is contained in:
ForestOfLight
2025-04-15 02:23:21 -07:00
Unverified
parent 567abd0f5f
commit 296af63134
7 changed files with 85 additions and 34 deletions
@@ -1,5 +1,7 @@
import { ActionFormData, ModalFormData } from '@minecraft/server-ui';
import { MenuFormBuilder } from './MenuFormBuilder';
import { StructureVerifier } from './StructureVerifier';
import { BlockVerificationLevel } from './BlockVerificationLevel';
export class InstanceEditFormBuilder {
static buildInstance(instance, options) {
@@ -30,4 +32,24 @@ export class InstanceEditFormBuilder {
.slider("Layer", 0, maxLayer, 1, currentLayer)
.submitButton('Set Layer');
}
static async buildStatistics(instance) {
const buildStatisticsForm = new ActionFormData()
.title(MenuFormBuilder.menuTitle)
let message = '';
const structureVerifier = new StructureVerifier(instance);
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.TypeAndStateMatch)}\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)}%%)`;
}
}