simplified-mojang-jsons 0.0.14 → 0.0.16
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/builders/resources/animControllers/AnimControllerTemplateBuilder.d.ts.map +1 -1
- package/dist/index.js +41 -3
- package/dist/index.js.map +2 -2
- package/dist/types/resources/materials/entity/MaterialEntityTemplates.d.ts +2 -2
- package/dist/types/resources/materials/entity/MaterialEntityTemplates.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimControllerTemplateBuilder.d.ts","sourceRoot":"","sources":["../../../../src/builders/resources/animControllers/AnimControllerTemplateBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAA8B,gBAAgB,EAAE,eAAe,EAAE,MAAM,iEAAiE,CAAC;
|
|
1
|
+
{"version":3,"file":"AnimControllerTemplateBuilder.d.ts","sourceRoot":"","sources":["../../../../src/builders/resources/animControllers/AnimControllerTemplateBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAA8B,gBAAgB,EAAE,eAAe,EAAE,MAAM,iEAAiE,CAAC;AAqMtM;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAClC,KAAK,CAAC,IAAI,SAAS,0BAA0B,EAC/C,GAAG,EAAE,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,WACjB,wBAAwB,CAAC,gBAAgB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,YAGpF"}
|
package/dist/index.js
CHANGED
|
@@ -208425,7 +208425,7 @@ var FinalRPAnimControllerBuilderTemplate = class _FinalRPAnimControllerBuilderTe
|
|
|
208425
208425
|
const existing = controllers.find((c) => c.idController === item.idController);
|
|
208426
208426
|
if (existing) {
|
|
208427
208427
|
existing.initialState = item.initialState || existing.initialState;
|
|
208428
|
-
existing.states =
|
|
208428
|
+
existing.states = _FinalRPAnimControllerBuilderTemplate.mergeStates(existing.states, structuredClone(item.states));
|
|
208429
208429
|
} else {
|
|
208430
208430
|
controllers.push(structuredClone(item));
|
|
208431
208431
|
}
|
|
@@ -208434,12 +208434,50 @@ var FinalRPAnimControllerBuilderTemplate = class _FinalRPAnimControllerBuilderTe
|
|
|
208434
208434
|
for (const [id, newStates] of Object.entries(item)) {
|
|
208435
208435
|
const ctrl = controllers.find((c) => c.idController === id);
|
|
208436
208436
|
if (!ctrl) continue;
|
|
208437
|
-
ctrl.states =
|
|
208437
|
+
ctrl.states = _FinalRPAnimControllerBuilderTemplate.mergeStates(ctrl.states, structuredClone(newStates.states));
|
|
208438
208438
|
}
|
|
208439
208439
|
}
|
|
208440
208440
|
}
|
|
208441
208441
|
return { ...def, animControllers: controllers };
|
|
208442
208442
|
}
|
|
208443
|
+
/**
|
|
208444
|
+
* Metodo auxiliar que combina las propiedades de un estado evitando duplicados en sus arrays.
|
|
208445
|
+
* @param {Record<string, any>} base Estado base a considerar.
|
|
208446
|
+
* @param {Record<string, any>} patch Propiedades a convinar.
|
|
208447
|
+
* @returns {Record<string, any>} Devuelve el estado nuevo totalmente convinado.
|
|
208448
|
+
* @author HaJuegos - 04-11-2026
|
|
208449
|
+
* @private
|
|
208450
|
+
* @static
|
|
208451
|
+
*/
|
|
208452
|
+
static mergeState(base, patch) {
|
|
208453
|
+
const out = { ...base };
|
|
208454
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
208455
|
+
const cur = out[k];
|
|
208456
|
+
if (Array.isArray(cur) && Array.isArray(v)) {
|
|
208457
|
+
const seen = new Set(cur.map((x) => JSON.stringify(x)));
|
|
208458
|
+
out[k] = [...cur, ...v.filter((x) => !seen.has(JSON.stringify(x)))];
|
|
208459
|
+
} else {
|
|
208460
|
+
out[k] = v;
|
|
208461
|
+
}
|
|
208462
|
+
}
|
|
208463
|
+
return out;
|
|
208464
|
+
}
|
|
208465
|
+
/**
|
|
208466
|
+
* Metodo auxiliar que combina los estados de un controlador fusionando los existente y añadiendo los nuevos.
|
|
208467
|
+
* @param {Record<string, any>} base Estados base a considerar.
|
|
208468
|
+
* @param {Record<string, any>} patch Estados a combinar.
|
|
208469
|
+
* @returns {Record<string, any>} Devuelve el nuevo estado con los datos combinados.
|
|
208470
|
+
* @author HaJuegos - 04-11-2026
|
|
208471
|
+
* @private
|
|
208472
|
+
* @static
|
|
208473
|
+
*/
|
|
208474
|
+
static mergeStates(base, patch) {
|
|
208475
|
+
const out = { ...base };
|
|
208476
|
+
for (const [id, state] of Object.entries(patch)) {
|
|
208477
|
+
out[id] = out[id] ? _FinalRPAnimControllerBuilderTemplate.mergeState(out[id], state) : state;
|
|
208478
|
+
}
|
|
208479
|
+
return out;
|
|
208480
|
+
}
|
|
208443
208481
|
};
|
|
208444
208482
|
function createRPAnimController(def) {
|
|
208445
208483
|
return (over = {}) => {
|
|
@@ -227187,7 +227225,7 @@ var ResourceMaterialEntityBuilder = class {
|
|
|
227187
227225
|
return this;
|
|
227188
227226
|
}
|
|
227189
227227
|
convertToJSON(stringify) {
|
|
227190
|
-
const materials = {};
|
|
227228
|
+
const materials = { version: "1.0.0" };
|
|
227191
227229
|
for (const { idMaterial, idMaterialReference, variants, ...rest } of this.materialsData ?? []) {
|
|
227192
227230
|
const finalId = idMaterialReference ? `${idMaterial}:${idMaterialReference}` : idMaterial;
|
|
227193
227231
|
materials[finalId] = {
|