mc-assets 0.2.8 → 0.2.10
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 +2 -18
- package/dist/assetsParser.js +29 -18
- package/dist/blockStatesModels.json +2142 -2144
- package/dist/blocksAtlasLatest.png +0 -0
- package/dist/blocksAtlases.json +74 -46
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -35,6 +35,8 @@ This packages includes versions for: 1.7.10, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.
|
|
|
35
35
|
<summary>Included Block Entities (Additional Block Models) (132):</summary>
|
|
36
36
|
|
|
37
37
|
- ✅ item_frame
|
|
38
|
+
- ✅ sign
|
|
39
|
+
- ✅ wall_sign
|
|
38
40
|
- ✅ acacia_sign
|
|
39
41
|
- ✅ acacia_wall_sign
|
|
40
42
|
- ✅ birch_sign
|
|
@@ -164,28 +166,10 @@ This packages includes versions for: 1.7.10, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.
|
|
|
164
166
|
- ✅ yellow_wall_banner
|
|
165
167
|
- ✅ zombie_head
|
|
166
168
|
- ✅ zombie_wall_head
|
|
167
|
-
- ✅ sign
|
|
168
|
-
- ✅ wall_sign
|
|
169
|
-
- ❌ black_glazed_terracotta
|
|
170
|
-
- ❌ blue_glazed_terracotta
|
|
171
|
-
- ❌ brown_glazed_terracotta
|
|
172
|
-
- ❌ cyan_glazed_terracotta
|
|
173
169
|
- ❌ end_gateway
|
|
174
170
|
- ❌ end_portal
|
|
175
|
-
- ❌ gray_glazed_terracotta
|
|
176
|
-
- ❌ green_glazed_terracotta
|
|
177
|
-
- ❌ light_blue_glazed_terracotta
|
|
178
|
-
- ❌ light_gray_glazed_terracotta
|
|
179
|
-
- ❌ lime_glazed_terracotta
|
|
180
|
-
- ❌ magenta_glazed_terracotta
|
|
181
|
-
- ❌ orange_glazed_terracotta
|
|
182
|
-
- ❌ pink_glazed_terracotta
|
|
183
|
-
- ❌ purple_glazed_terracotta
|
|
184
|
-
- ❌ red_glazed_terracotta
|
|
185
171
|
- ❌ structure_void
|
|
186
172
|
- ❌ trial_spawner
|
|
187
|
-
- ❌ white_glazed_terracotta
|
|
188
|
-
- ❌ yellow_glazed_terracotta
|
|
189
173
|
|
|
190
174
|
</details>
|
|
191
175
|
|
package/dist/assetsParser.js
CHANGED
|
@@ -143,7 +143,19 @@ export class AssetsParser {
|
|
|
143
143
|
const modelData = this.blockModelsStore.get(this.version, model);
|
|
144
144
|
if (!modelData)
|
|
145
145
|
return;
|
|
146
|
-
const
|
|
146
|
+
const collectedParentModels = [];
|
|
147
|
+
const collectModels = (model) => {
|
|
148
|
+
collectedParentModels.push(model);
|
|
149
|
+
if (model.parent) {
|
|
150
|
+
const parent = this.blockModelsStore.get(this.version, model.parent);
|
|
151
|
+
if (!parent)
|
|
152
|
+
return;
|
|
153
|
+
collectModels(parent);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
collectModels(modelData);
|
|
157
|
+
collectedParentModels.reverse(); // from parent to child
|
|
158
|
+
for (const model of collectedParentModels) {
|
|
147
159
|
if (model.ambientocclusion !== undefined) {
|
|
148
160
|
this.resolvedModel.ao = model.ambientocclusion;
|
|
149
161
|
}
|
|
@@ -153,8 +165,10 @@ export class AssetsParser {
|
|
|
153
165
|
if (model.textures) {
|
|
154
166
|
this.resolvedModel.textures ??= {};
|
|
155
167
|
for (let [key, value] of Object.entries(model.textures)) {
|
|
156
|
-
if (value.includes('#'))
|
|
157
|
-
|
|
168
|
+
if (value.includes('#'))
|
|
169
|
+
value = value.split('/').at(-1);
|
|
170
|
+
if (value.startsWith('#')) {
|
|
171
|
+
const key = value.slice(1);
|
|
158
172
|
if (this.resolvedModel.textures[key]) {
|
|
159
173
|
value = this.resolvedModel.textures[key];
|
|
160
174
|
}
|
|
@@ -163,38 +177,35 @@ export class AssetsParser {
|
|
|
163
177
|
}
|
|
164
178
|
}
|
|
165
179
|
if (model.elements) {
|
|
166
|
-
this.resolvedModel.elements
|
|
167
|
-
this.resolvedModel.elements.push(...structuredClone(model.elements));
|
|
180
|
+
this.resolvedModel.elements = structuredClone(model.elements);
|
|
168
181
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return;
|
|
173
|
-
resolveModel(parent);
|
|
174
|
-
}
|
|
175
|
-
return model;
|
|
176
|
-
};
|
|
177
|
-
resolveModel(modelData);
|
|
178
|
-
const resolveTexture = (originalTexturePath, _originalKey) => {
|
|
182
|
+
}
|
|
183
|
+
const resolveTexture = (originalTexturePath, _originalKey, chain) => {
|
|
184
|
+
chain.push(_originalKey);
|
|
179
185
|
if (originalTexturePath.includes('#')) {
|
|
180
186
|
originalTexturePath = originalTexturePath.split('/').at(-1).replace('#', '');
|
|
181
187
|
this.resolvedModel.textures ??= {};
|
|
188
|
+
if (chain.includes(originalTexturePath)) {
|
|
189
|
+
console.warn(`${debugQueryName}: Circular texture reference detected: ${chain.join(' -> ')}`);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
182
192
|
const existingKey = this.resolvedModel.textures[originalTexturePath];
|
|
183
193
|
if (!existingKey) {
|
|
184
194
|
// todo this also needs to be done at the validation stage
|
|
185
195
|
// throw new Error(`Cannot resolve texture ${key} to ${value} because it is not defined`)
|
|
186
196
|
console.warn(`${debugQueryName}: Cannot resolve texture ${originalTexturePath} for ${_originalKey} because it is not defined`);
|
|
197
|
+
return;
|
|
187
198
|
}
|
|
188
199
|
else {
|
|
189
|
-
return existingKey;
|
|
200
|
+
return resolveTexture(existingKey, originalTexturePath, chain);
|
|
190
201
|
}
|
|
191
202
|
}
|
|
192
|
-
return;
|
|
203
|
+
return originalTexturePath;
|
|
193
204
|
};
|
|
194
205
|
for (let [key, value] of Object.entries(this.resolvedModel.textures ?? {})) {
|
|
195
206
|
if (!value.includes('#'))
|
|
196
207
|
continue;
|
|
197
|
-
const resolved = resolveTexture(value, key);
|
|
208
|
+
const resolved = resolveTexture(value, key, []);
|
|
198
209
|
if (resolved)
|
|
199
210
|
this.resolvedModel.textures[key] = resolved;
|
|
200
211
|
else
|