mc-assets 0.2.27 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/itemsRenderer.js
CHANGED
|
@@ -64,7 +64,7 @@ export class ItemsRenderer {
|
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
model = this.modelsStore.get(this.version, `item/${itemName}`);
|
|
67
|
-
if (!model || model.parent?.includes('block/')
|
|
67
|
+
if (!model || model.parent?.includes('block/')) {
|
|
68
68
|
return this.tryGetFullBlock(itemName, properties);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ItemsRenderer } from './itemsRenderer';
|
|
3
|
+
import { AtlasParser } from './atlasParser';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
// Load test data
|
|
6
|
+
const blockstatesModels = JSON.parse(fs.readFileSync('./dist/blockStatesModels.json', 'utf8'));
|
|
7
|
+
const itemsAtlases = JSON.parse(fs.readFileSync('./dist/itemsAtlases.json', 'utf8'));
|
|
8
|
+
const blocksAtlases = JSON.parse(fs.readFileSync('./dist/blocksAtlases.json', 'utf8'));
|
|
9
|
+
describe('ItemsRenderer', () => {
|
|
10
|
+
const itemsAtlasParser = new AtlasParser(itemsAtlases, '');
|
|
11
|
+
const blocksAtlasParser = new AtlasParser(blocksAtlases, '');
|
|
12
|
+
const renderer = new ItemsRenderer('latest', blockstatesModels, itemsAtlasParser, blocksAtlasParser);
|
|
13
|
+
describe('getItemTexture', () => {
|
|
14
|
+
it('items texture', () => {
|
|
15
|
+
expect(renderer.getItemTexture('item_frame')).toMatchInlineSnapshot(`
|
|
16
|
+
{
|
|
17
|
+
"path": "items",
|
|
18
|
+
"slice": [
|
|
19
|
+
720,
|
|
20
|
+
128,
|
|
21
|
+
16,
|
|
22
|
+
16,
|
|
23
|
+
],
|
|
24
|
+
"type": "items",
|
|
25
|
+
}
|
|
26
|
+
`);
|
|
27
|
+
});
|
|
28
|
+
it('full blocks texture', () => {
|
|
29
|
+
expect(renderer.getItemTexture('stone')).toMatchInlineSnapshot(`
|
|
30
|
+
{
|
|
31
|
+
"left": {
|
|
32
|
+
"path": "blocks",
|
|
33
|
+
"slice": [
|
|
34
|
+
816,
|
|
35
|
+
64,
|
|
36
|
+
16,
|
|
37
|
+
16,
|
|
38
|
+
],
|
|
39
|
+
"type": "blocks",
|
|
40
|
+
},
|
|
41
|
+
"right": {
|
|
42
|
+
"path": "blocks",
|
|
43
|
+
"slice": [
|
|
44
|
+
816,
|
|
45
|
+
64,
|
|
46
|
+
16,
|
|
47
|
+
16,
|
|
48
|
+
],
|
|
49
|
+
"type": "blocks",
|
|
50
|
+
},
|
|
51
|
+
"top": {
|
|
52
|
+
"path": "blocks",
|
|
53
|
+
"slice": [
|
|
54
|
+
816,
|
|
55
|
+
64,
|
|
56
|
+
16,
|
|
57
|
+
16,
|
|
58
|
+
],
|
|
59
|
+
"type": "blocks",
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
`);
|
|
63
|
+
});
|
|
64
|
+
it('invsprite textures', () => {
|
|
65
|
+
expect(renderer.getItemTexture('chest')).toMatchInlineSnapshot(`
|
|
66
|
+
{
|
|
67
|
+
"path": "items",
|
|
68
|
+
"slice": [
|
|
69
|
+
400,
|
|
70
|
+
0,
|
|
71
|
+
16,
|
|
72
|
+
16,
|
|
73
|
+
],
|
|
74
|
+
"type": "items",
|
|
75
|
+
}
|
|
76
|
+
`);
|
|
77
|
+
});
|
|
78
|
+
it('not implemented logic', () => {
|
|
79
|
+
expect(renderer.getItemTexture('cut_copper_slab')).toMatchInlineSnapshot(`undefined`);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('resolveTexture', () => {
|
|
83
|
+
it('should resolve item textures correctly', () => {
|
|
84
|
+
expect(renderer.resolveTexture('items/item_frame')).toMatchInlineSnapshot(`
|
|
85
|
+
{
|
|
86
|
+
"path": "items",
|
|
87
|
+
"slice": [
|
|
88
|
+
720,
|
|
89
|
+
128,
|
|
90
|
+
16,
|
|
91
|
+
16,
|
|
92
|
+
],
|
|
93
|
+
"type": "items",
|
|
94
|
+
}
|
|
95
|
+
`);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mc-assets",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
4
4
|
"author": "Vitaly Turovsky <vital2580@icloud.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"regen-blockentities": "rm -f dist/blockStatesModels.json && tsx src/blockEntities.ts && tsx src/newAssetsBuilder.ts && tsx src/genBlocks.ts",
|
|
61
61
|
"build-consumer": "tsc -p tsconfig.consumer.json",
|
|
62
62
|
"watch-dist": "tsc -p tsconfig.consumer.json -w",
|
|
63
|
-
"build-web": "pnpm --dir web-demo build"
|
|
63
|
+
"build-web": "pnpm --dir web-demo build",
|
|
64
|
+
"test": "vitest"
|
|
64
65
|
}
|
|
65
66
|
}
|