forked from mirror/ObjToSchematic
Namespaced block_ids.json, updated schematic-friendly.test.ts
This commit is contained in:
parent
507a4045ee
commit
e6e8259475
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,8 @@ import fs from 'fs';
|
||||
import { NBT, TagType } from 'prismarine-nbt';
|
||||
|
||||
import { BlockMesh } from '../block_mesh';
|
||||
import { StatusHandler } from '../status';
|
||||
import { StatusHandler, StatusID } from '../status';
|
||||
import { LOG_WARN } from '../util/log_util';
|
||||
import { saveNBT } from '../util/nbt_util';
|
||||
import { AppPaths, PathUtil } from '../util/path_util';
|
||||
import { Vector3 } from '../vector';
|
||||
@ -42,7 +43,9 @@ export class Schematic extends IExporter {
|
||||
StatusHandler.Get.add(
|
||||
'warning',
|
||||
`${numBlocksUnsupported} blocks (${unsupportedBlocks.size} unique) are not supported by the .schematic format, Stone block are used in their place. Try using the schematic-friendly palette, or export using .litematica`,
|
||||
StatusID.SchematicUnsupportedBlocks,
|
||||
);
|
||||
LOG_WARN(unsupportedBlocks);
|
||||
}
|
||||
|
||||
const nbt: NBT = {
|
||||
|
@ -4,9 +4,17 @@ import { LOG, LOG_MAJOR, LOG_WARN } from './util/log_util';
|
||||
|
||||
export type StatusType = 'warning' | 'info';
|
||||
|
||||
/* eslint-disable */
|
||||
export enum StatusID {
|
||||
SchematicUnsupportedBlocks
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
||||
|
||||
export type StatusMessage = {
|
||||
status: StatusType,
|
||||
message: string,
|
||||
id?: StatusID,
|
||||
}
|
||||
|
||||
export class StatusHandler {
|
||||
@ -26,9 +34,13 @@ export class StatusHandler {
|
||||
this._statusMessages = [];
|
||||
}
|
||||
|
||||
public add(status: StatusType, message: string) {
|
||||
public add(status: StatusType, message: string, id?: StatusID) {
|
||||
(status === 'warning' ? LOG_WARN : LOG)(message);
|
||||
this._statusMessages.push({ status: status, message: message });
|
||||
this._statusMessages.push({ status: status, message: message, id: id });
|
||||
}
|
||||
|
||||
public hasId(id: StatusID) {
|
||||
return this._statusMessages.some((x) => { return x.id === id; });
|
||||
}
|
||||
|
||||
public hasStatusMessages(statusType: StatusType): boolean {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { StatusHandler, StatusID } from '../src/status';
|
||||
import { AppPaths, PathUtil } from '../src/util/path_util';
|
||||
import { WorkerClient } from '../src/worker_client';
|
||||
import { headlessConfig } from '../tools/headless-config';
|
||||
@ -10,9 +11,14 @@ test('Schematic-friendly Palette', () => {
|
||||
|
||||
config.import.filepath = PathUtil.join(AppPaths.Get.resources, './samples/skull.obj');
|
||||
config.assign.blockPalette = 'schematic-friendly';
|
||||
config.export.exporter = 'schematic';
|
||||
config.export.filepath = PathUtil.join(AppPaths.Get.testData, '../out/friendly.schematic');
|
||||
|
||||
const worker = WorkerClient.Get;
|
||||
worker.import(headlessConfig.import);
|
||||
worker.voxelise(headlessConfig.voxelise);
|
||||
worker.assign(headlessConfig.assign);
|
||||
worker.export(headlessConfig.export);
|
||||
|
||||
expect(StatusHandler.Get.hasId(StatusID.SchematicUnsupportedBlocks)).toBe(false);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user