minerender 2.1.0-alpha.95 → 2.1.0-alpha.96

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.
@@ -116,14 +116,14 @@ var init_Axis = __esm({
116
116
  var CubeFace, CubeFaceIndex, CUBE_FACES, CUBE_FACE_OFFSETS;
117
117
  var init_CubeFace = __esm({
118
118
  "src/CubeFace.ts"() {
119
- CubeFace = /* @__PURE__ */ ((CubeFace2) => {
120
- CubeFace2["EAST"] = "east";
121
- CubeFace2["WEST"] = "west";
122
- CubeFace2["UP"] = "up";
123
- CubeFace2["DOWN"] = "down";
124
- CubeFace2["SOUTH"] = "south";
125
- CubeFace2["NORTH"] = "north";
126
- return CubeFace2;
119
+ CubeFace = /* @__PURE__ */ ((CubeFace3) => {
120
+ CubeFace3["EAST"] = "east";
121
+ CubeFace3["WEST"] = "west";
122
+ CubeFace3["UP"] = "up";
123
+ CubeFace3["DOWN"] = "down";
124
+ CubeFace3["SOUTH"] = "south";
125
+ CubeFace3["NORTH"] = "north";
126
+ return CubeFace3;
127
127
  })(CubeFace || {});
128
128
  CubeFaceIndex = /* @__PURE__ */ ((CubeFaceIndex2) => {
129
129
  CubeFaceIndex2[CubeFaceIndex2["EAST"] = 0] = "EAST";
@@ -1365,6 +1365,9 @@ var require_dist = __commonJS({
1365
1365
  });
1366
1366
 
1367
1367
  // src/assets/AssetKey.ts
1368
+ function isResourceLocation(value) {
1369
+ return typeof value === "string" && /^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value);
1370
+ }
1368
1371
  function isBasicAssetKey(obj) {
1369
1372
  return obj !== null && typeof obj === "object" && typeof obj.namespace === "string" && typeof obj.path === "string";
1370
1373
  }
@@ -1751,7 +1754,7 @@ var init_Models = __esm({
1751
1754
  return model ? restore(model) : void 0;
1752
1755
  }
1753
1756
  static contextIdentifier(id) {
1754
- if (typeof id !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(id)) {
1757
+ if (!isResourceLocation(id)) {
1755
1758
  throw new Error(`Invalid item-preview identifier: ${id}`);
1756
1759
  }
1757
1760
  return id.includes(":") ? id : `minecraft:${id}`;
@@ -1896,6 +1899,8 @@ var init_Models = __esm({
1896
1899
  case "minecraft:trident":
1897
1900
  case "conduit":
1898
1901
  case "minecraft:conduit":
1902
+ case "decorated_pot":
1903
+ case "minecraft:decorated_pot":
1899
1904
  return { model: node.base, special };
1900
1905
  case "shulker_box":
1901
1906
  case "minecraft:shulker_box":
@@ -16288,6 +16293,55 @@ var init_MinecraftCubeTexture = __esm({
16288
16293
  }
16289
16294
  });
16290
16295
 
16296
+ // src/assets/DecoratedPots.ts
16297
+ var POTTERY_SHERDS, DecoratedPots;
16298
+ var init_DecoratedPots = __esm({
16299
+ "src/assets/DecoratedPots.ts"() {
16300
+ init_AssetKey();
16301
+ POTTERY_SHERDS = Object.freeze([
16302
+ "angler",
16303
+ "archer",
16304
+ "arms_up",
16305
+ "blade",
16306
+ "brewer",
16307
+ "burn",
16308
+ "danger",
16309
+ "explorer",
16310
+ "flow",
16311
+ "friend",
16312
+ "guster",
16313
+ "heart",
16314
+ "heartbreak",
16315
+ "howl",
16316
+ "miner",
16317
+ "mourner",
16318
+ "plenty",
16319
+ "prize",
16320
+ "scrape",
16321
+ "sheaf",
16322
+ "shelter",
16323
+ "skull",
16324
+ "snort"
16325
+ ].map((pattern2) => `minecraft:${pattern2}_pottery_sherd`));
16326
+ DecoratedPots = class {
16327
+ /** Reads up to four item IDs in back, left, right, front order; missing and unmapped items use plain sides. */
16328
+ static getSideTextures(value, root) {
16329
+ const items = value === void 0 ? [] : value;
16330
+ if (!Array.isArray(items) || items.length > 4) throw new Error("pot_decorations must be an array of at most four item IDs");
16331
+ const textures = items.map((item) => {
16332
+ if (!isResourceLocation(item)) throw new Error("Pot decorations must be item identifiers");
16333
+ const id = item.includes(":") ? item : `minecraft:${item}`;
16334
+ return POTTERY_SHERDS.includes(id) ? id.slice("minecraft:".length).replace(/_sherd$/, "_pattern") : "decorated_pot_side";
16335
+ });
16336
+ return Object.fromEntries(["back", "left", "right", "front"].map((side, index) => [
16337
+ side,
16338
+ new AssetKey("minecraft", `decorated_pot/${textures[index] ?? "decorated_pot_side"}`, "textures", "entity", "assets", ".png", root)
16339
+ ]));
16340
+ }
16341
+ };
16342
+ }
16343
+ });
16344
+
16291
16345
  // src/error/MineRenderError.ts
16292
16346
  var MineRenderError;
16293
16347
  var init_MineRenderError = __esm({
@@ -17145,6 +17199,7 @@ var init_EntityObject = __esm({
17145
17199
  init_AssetKey();
17146
17200
  init_Materials();
17147
17201
  init_MinecraftCubeTexture();
17202
+ init_CubeFace();
17148
17203
  init_three();
17149
17204
  init_EntityAnimationPlayer();
17150
17205
  EntityObject = class _EntityObject extends SceneObject {
@@ -17322,11 +17377,11 @@ var init_EntityObject = __esm({
17322
17377
  const group = this.createGroup(`layer:${name}`);
17323
17378
  modelRoot.add(group);
17324
17379
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
17325
- this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward);
17380
+ this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
17326
17381
  });
17327
17382
  this.meshesCreated = true;
17328
17383
  }
17329
- createPart(name, part, parent, textureSize, material, renderOrder, inward = true) {
17384
+ createPart(name, part, parent, textureSize, material, renderOrder, inward = true, faces) {
17330
17385
  const anchor = this.createGroup(name);
17331
17386
  anchor.position.fromArray(part.pose.offset);
17332
17387
  anchor.rotation.set(...part.pose.rotation, "ZYX");
@@ -17347,6 +17402,10 @@ var init_EntityObject = __esm({
17347
17402
  ).clone();
17348
17403
  this.geometries.add(geometry);
17349
17404
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
17405
+ if (faces) {
17406
+ geometry.setIndex(Array.from(geometry.getIndex().array).filter((_, index) => faces.includes(CUBE_FACES[Math.floor(index / 6)])));
17407
+ geometry.clearGroups();
17408
+ }
17350
17409
  if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
17351
17410
  const index = Array.from(geometry.getIndex().array);
17352
17411
  geometry.setIndex(index.concat(index.slice().reverse()));
@@ -17357,7 +17416,7 @@ var init_EntityObject = __esm({
17357
17416
  if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
17358
17417
  }
17359
17418
  for (const [childName, child] of Object.entries(part.children)) {
17360
- this.createPart(childName, child, anchor, size, material, renderOrder, inward);
17419
+ this.createPart(childName, child, anchor, size, material, renderOrder, inward, faces);
17361
17420
  }
17362
17421
  }
17363
17422
  async applyTextures() {
@@ -17994,7 +18053,9 @@ var init_SpecialItems = __esm({
17994
18053
  init_AssetKey();
17995
18054
  init_Entities();
17996
18055
  init_BannerPatterns();
18056
+ init_DecoratedPots();
17997
18057
  init_ModelTextures();
18058
+ init_CubeFace();
17998
18059
  SpecialItems = class {
17999
18060
  /** Resolves the static entity parts drawn by a special item renderer, in model units. */
18000
18061
  static async getParts(special, root, components = {}) {
@@ -18020,6 +18081,34 @@ var init_SpecialItems = __esm({
18020
18081
  return { model, transform, rotations };
18021
18082
  };
18022
18083
  switch (special.type) {
18084
+ case "minecraft:decorated_pot":
18085
+ case "decorated_pot": {
18086
+ const sideTextures = DecoratedPots.getSideTextures(components["minecraft:pot_decorations"], root);
18087
+ const baseTexture = texture("decorated_pot_base", "decorated_pot");
18088
+ const [base, sides] = await Promise.all([
18089
+ load("decorated_pot_base", baseTexture, new Matrix48()),
18090
+ load("decorated_pot_sides", texture("decorated_pot_side", "decorated_pot"), new Matrix48())
18091
+ ]);
18092
+ const layers = {
18093
+ base: { key: base.model.key, texture: baseTexture, layer: base.model.layer, render: "solid" }
18094
+ };
18095
+ for (const side of ["front", "back", "left", "right"]) {
18096
+ const part = sides.model.layer.root.children[side];
18097
+ if (!part) throw new Error(`Decorated-pot entity model is missing its ${side} side`);
18098
+ layers[side] = { key: sides.model.key, texture: sideTextures[side], render: "solid", layer: {
18099
+ ...sides.model.layer,
18100
+ root: { ...sides.model.layer.root, cubes: [], children: {
18101
+ [side]: part
18102
+ } }
18103
+ } };
18104
+ }
18105
+ await Promise.all([...new Map(Object.values(layers).map((layer) => [layer.texture.serialize(), layer.texture])).values()].map(async (key) => {
18106
+ if (!await ModelTextures.preload(key)) throw new Error(`Missing special item texture ${key.toNamespacedString()}`);
18107
+ }));
18108
+ base.model = { ...base.model, ...layers.base, layers };
18109
+ base.faces = { front: ["north" /* NORTH */], back: ["north" /* NORTH */], left: ["north" /* NORTH */], right: ["north" /* NORTH */] };
18110
+ return [base];
18111
+ }
18023
18112
  case "minecraft:trident":
18024
18113
  case "trident":
18025
18114
  case "minecraft:conduit":
@@ -18383,7 +18472,7 @@ var init_ModelObject = __esm({
18383
18472
  transform.multiply(new Matrix49().makeTranslation(-8, -8, -8));
18384
18473
  try {
18385
18474
  for (const part of parts2) {
18386
- const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints });
18475
+ const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
18387
18476
  object3.matrix.copy(transform).multiply(part.transform);
18388
18477
  object3.matrixWorldNeedsUpdate = true;
18389
18478
  object3.matrixAutoUpdate = false;
@@ -19023,6 +19112,7 @@ var BlockEntities = class {
19023
19112
 
19024
19113
  // src/assets/index.ts
19025
19114
  init_BlockStates();
19115
+ init_DecoratedPots();
19026
19116
  init_Entities();
19027
19117
 
19028
19118
  // src/assets/Fonts.ts
@@ -30750,6 +30840,7 @@ export {
30750
30840
  DEFAULT_UV,
30751
30841
  DISPLAY_POSITIONS,
30752
30842
  DYE_COLORS,
30843
+ DecoratedPots,
30753
30844
  DefaultBlockStates,
30754
30845
  DisplayPosition,
30755
30846
  DisplayTransforms,
@@ -30869,6 +30960,7 @@ export {
30869
30960
  isOrthographicCamera,
30870
30961
  isPerspectiveCamera,
30871
30962
  isQuadArray,
30963
+ isResourceLocation,
30872
30964
  isSceneObject,
30873
30965
  isTransformable,
30874
30966
  isTripleArray,