mc-assets 0.2.37 → 0.2.39
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/README.MD +3 -3
- package/dist/assetsParser.js +7 -2
- package/dist/atlasCreator.js +41 -8
- package/dist/blockStatesModels.json +42 -8
- package/dist/blocksAtlasLatest.png +0 -0
- package/dist/blocksAtlasLegacy.png +0 -0
- package/dist/blocksAtlases.json +5464 -5454
- package/dist/itemsAtlasLatest.png +0 -0
- package/dist/itemsAtlasLegacy.png +0 -0
- package/dist/itemsAtlases.json +4658 -4648
- package/dist/particlesAtlasLatest.png +0 -0
- package/dist/particlesAtlasLegacy.png +0 -0
- package/dist/particlesAtlases.json +685 -675
- package/package.json +2 -2
package/README.MD
CHANGED
|
@@ -10,11 +10,11 @@ npm i mc-assets
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- **NEW ITEMS FORMAT SUPPORT!!!** - Get different item models based on conditions (using item, display context, etc)
|
|
14
13
|
- **Automatic Updates** - This library is automatically updated and published to npm.
|
|
15
14
|
- **Fully Typed** - Today is nothing can be done without TypeScript. We ship best type definitions possible.
|
|
16
15
|
- **Early Access** - It always includes the latest pre and rc (release candidate) version.
|
|
17
|
-
- **Version Accurate** - Includes all released versions starting from 1.7.10.
|
|
16
|
+
- **Version Accurate** - Includes data for **all released versions** starting from 1.7.10.
|
|
17
|
+
- **New Items Format Support** - Get different item models based on conditions (using item, display context, etc)
|
|
18
18
|
- **Memory Efficient** - Small installation size, for the fastest download & loading time.
|
|
19
19
|
- **Simple & Complete API** - Works in browsers out of the box and provides parsers for all the data this library provides.
|
|
20
20
|
- **Easy to Use Items Textures** - Includes hand-crafted isometric textures for some blocks.
|
|
@@ -28,7 +28,7 @@ For contributing & building instructions see [building](#building) section.
|
|
|
28
28
|
> Tested on Node.js 18 and above.
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
All blockstates + models + all atlas textures for all versions bundled with rsbuild (uncompressed): 5.
|
|
31
|
+
All blockstates + models + all atlas textures for all versions bundled with rsbuild (uncompressed): 5.12 MB.
|
|
32
32
|
|
|
33
33
|
This packages includes versions for: 1.7.10, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.10, 1.10.1, 1.10.2, 1.11, 1.11.1, 1.11.2, 1.12, 1.12.1, 1.12.2, 1.13, 1.13.1, 1.13.2, 1.14, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.15, 1.15.1, 1.15.2, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.17, 1.17.1, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6, 1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4.
|
|
34
34
|
|
package/dist/assetsParser.js
CHANGED
|
@@ -221,8 +221,13 @@ export class AssetsParser {
|
|
|
221
221
|
this.resolvedModel.elements = structuredClone(model.elements);
|
|
222
222
|
}
|
|
223
223
|
for (const [key, value] of Object.entries(model)) {
|
|
224
|
-
if (
|
|
225
|
-
this.resolvedModel[key]
|
|
224
|
+
if (key !== 'elements' && key !== 'textures' && key !== 'parent') {
|
|
225
|
+
if (this.resolvedModel[key] && typeof this.resolvedModel[key] === 'object' && value && typeof value === 'object') {
|
|
226
|
+
Object.assign(this.resolvedModel[key], value);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
this.resolvedModel[key] = value;
|
|
230
|
+
}
|
|
226
231
|
}
|
|
227
232
|
}
|
|
228
233
|
}
|
package/dist/atlasCreator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaxRectsPacker, PACKING_LOGIC, Rectangle } from 'maxrects-packer';
|
|
2
2
|
export const MAX_CANVAS_SIZE = 16_384;
|
|
3
3
|
function nextPowerOfTwo(n) {
|
|
4
4
|
if (n === 0)
|
|
@@ -20,7 +20,7 @@ export const getAtlasSize = (numberOfTiles, tileSize) => {
|
|
|
20
20
|
};
|
|
21
21
|
export const makeTextureAtlas = ({ input, getLoadedImage, tileSize = 16, getCanvas = (imgSize) => typeof document !== 'undefined' && document.createElement ? document.createElement('canvas') : new globalThis.Canvas(imgSize, imgSize, 'png'), }) => {
|
|
22
22
|
// Pre-calculate all texture dimensions and prepare images
|
|
23
|
-
const texturesWithDimensions = input.map(keyValue => {
|
|
23
|
+
const texturesWithDimensions = [...new Set(input)].map(keyValue => {
|
|
24
24
|
const inputData = getLoadedImage(keyValue);
|
|
25
25
|
let img;
|
|
26
26
|
if (inputData.image) {
|
|
@@ -53,12 +53,45 @@ export const makeTextureAtlas = ({ input, getLoadedImage, tileSize = 16, getCanv
|
|
|
53
53
|
renderSourceStartY: inputData.renderSourceStartY ?? 0,
|
|
54
54
|
};
|
|
55
55
|
});
|
|
56
|
-
// Use
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
// Use MaxRectsPacker to calculate optimal positions
|
|
57
|
+
const packer = new MaxRectsPacker(undefined, undefined, 0, {
|
|
58
|
+
square: true,
|
|
59
|
+
smart: true,
|
|
60
|
+
pot: true,
|
|
61
|
+
logic: PACKING_LOGIC.MAX_AREA,
|
|
62
|
+
});
|
|
63
|
+
// Add all textures as rectangles
|
|
64
|
+
const rectangles = texturesWithDimensions.map(tex => {
|
|
65
|
+
const rect = new Rectangle(tex.renderWidth, tex.renderHeight);
|
|
66
|
+
rect.data = tex; // Store texture data for later use
|
|
67
|
+
return rect;
|
|
68
|
+
});
|
|
69
|
+
packer.addArray(rectangles);
|
|
70
|
+
const firstBin = packer.bins[0];
|
|
71
|
+
if (!firstBin || !firstBin.rects || !firstBin.rects.length) {
|
|
72
|
+
throw new Error('Failed to pack textures');
|
|
73
|
+
}
|
|
74
|
+
const atlas = {
|
|
75
|
+
width: firstBin.width,
|
|
76
|
+
height: firstBin.height,
|
|
77
|
+
coords: firstBin.rects.map(rect => ({
|
|
78
|
+
x: rect.x,
|
|
79
|
+
y: rect.y,
|
|
80
|
+
img: { data: rect.data }
|
|
81
|
+
}))
|
|
82
|
+
};
|
|
83
|
+
// Check for duplicate keyValues in atlas
|
|
84
|
+
const seenKeyValues = new Set();
|
|
85
|
+
for (const coord of atlas.coords) {
|
|
86
|
+
const tex = coord.img.data;
|
|
87
|
+
if (seenKeyValues.has(tex.keyValue)) {
|
|
88
|
+
throw new Error(`Duplicate texture keyValue found in atlas: ${tex.keyValue}`);
|
|
89
|
+
}
|
|
90
|
+
seenKeyValues.add(tex.keyValue);
|
|
91
|
+
}
|
|
92
|
+
if (seenKeyValues.size !== input.length) {
|
|
93
|
+
throw new Error(`Lost some textures in packing: ${input.length - seenKeyValues.size}`);
|
|
94
|
+
}
|
|
62
95
|
// Round up atlas size to power of 2
|
|
63
96
|
const imgSize = Math.max(nextPowerOfTwo(atlas.width), nextPowerOfTwo(atlas.height));
|
|
64
97
|
if (imgSize > MAX_CANVAS_SIZE) {
|
|
@@ -151741,18 +151741,18 @@
|
|
|
151741
151741
|
"gui": {
|
|
151742
151742
|
"rotation": [
|
|
151743
151743
|
30,
|
|
151744
|
-
|
|
151744
|
+
45,
|
|
151745
151745
|
0
|
|
151746
151746
|
],
|
|
151747
151747
|
"translation": [
|
|
151748
151748
|
0,
|
|
151749
|
-
|
|
151749
|
+
-1,
|
|
151750
151750
|
0
|
|
151751
151751
|
],
|
|
151752
151752
|
"scale": [
|
|
151753
|
-
0.
|
|
151754
|
-
0.
|
|
151755
|
-
0.
|
|
151753
|
+
0.8,
|
|
151754
|
+
0.8,
|
|
151755
|
+
0.8
|
|
151756
151756
|
]
|
|
151757
151757
|
},
|
|
151758
151758
|
"ground": {
|
|
@@ -151798,7 +151798,7 @@
|
|
|
151798
151798
|
"translation": [
|
|
151799
151799
|
0,
|
|
151800
151800
|
2.5,
|
|
151801
|
-
|
|
151801
|
+
2
|
|
151802
151802
|
],
|
|
151803
151803
|
"scale": [
|
|
151804
151804
|
0.375,
|
|
@@ -151814,7 +151814,7 @@
|
|
|
151814
151814
|
],
|
|
151815
151815
|
"translation": [
|
|
151816
151816
|
0,
|
|
151817
|
-
|
|
151817
|
+
4.2,
|
|
151818
151818
|
0
|
|
151819
151819
|
],
|
|
151820
151820
|
"scale": [
|
|
@@ -151831,7 +151831,7 @@
|
|
|
151831
151831
|
],
|
|
151832
151832
|
"translation": [
|
|
151833
151833
|
0,
|
|
151834
|
-
|
|
151834
|
+
4.2,
|
|
151835
151835
|
0
|
|
151836
151836
|
],
|
|
151837
151837
|
"scale": [
|
|
@@ -151839,6 +151839,40 @@
|
|
|
151839
151839
|
0.4,
|
|
151840
151840
|
0.4
|
|
151841
151841
|
]
|
|
151842
|
+
},
|
|
151843
|
+
"head": {
|
|
151844
|
+
"rotation": [
|
|
151845
|
+
0,
|
|
151846
|
+
0,
|
|
151847
|
+
0
|
|
151848
|
+
],
|
|
151849
|
+
"translation": [
|
|
151850
|
+
0,
|
|
151851
|
+
-3,
|
|
151852
|
+
-6
|
|
151853
|
+
],
|
|
151854
|
+
"scale": [
|
|
151855
|
+
1,
|
|
151856
|
+
1,
|
|
151857
|
+
1
|
|
151858
|
+
]
|
|
151859
|
+
},
|
|
151860
|
+
"thirdperson_lefthand": {
|
|
151861
|
+
"rotation": [
|
|
151862
|
+
75,
|
|
151863
|
+
-45,
|
|
151864
|
+
0
|
|
151865
|
+
],
|
|
151866
|
+
"translation": [
|
|
151867
|
+
0,
|
|
151868
|
+
2.5,
|
|
151869
|
+
0
|
|
151870
|
+
],
|
|
151871
|
+
"scale": [
|
|
151872
|
+
0.375,
|
|
151873
|
+
0.375,
|
|
151874
|
+
0.375
|
|
151875
|
+
]
|
|
151842
151876
|
}
|
|
151843
151877
|
}
|
|
151844
151878
|
},
|
|
Binary file
|
|
Binary file
|