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.
@@ -115,14 +115,14 @@ var init_Axis = __esm({
115
115
  var CubeFace, CubeFaceIndex, CUBE_FACES, CUBE_FACE_OFFSETS;
116
116
  var init_CubeFace = __esm({
117
117
  "src/CubeFace.ts"() {
118
- CubeFace = /* @__PURE__ */ ((CubeFace2) => {
119
- CubeFace2["EAST"] = "east";
120
- CubeFace2["WEST"] = "west";
121
- CubeFace2["UP"] = "up";
122
- CubeFace2["DOWN"] = "down";
123
- CubeFace2["SOUTH"] = "south";
124
- CubeFace2["NORTH"] = "north";
125
- return CubeFace2;
118
+ CubeFace = /* @__PURE__ */ ((CubeFace3) => {
119
+ CubeFace3["EAST"] = "east";
120
+ CubeFace3["WEST"] = "west";
121
+ CubeFace3["UP"] = "up";
122
+ CubeFace3["DOWN"] = "down";
123
+ CubeFace3["SOUTH"] = "south";
124
+ CubeFace3["NORTH"] = "north";
125
+ return CubeFace3;
126
126
  })(CubeFace || {});
127
127
  CubeFaceIndex = /* @__PURE__ */ ((CubeFaceIndex2) => {
128
128
  CubeFaceIndex2[CubeFaceIndex2["EAST"] = 0] = "EAST";
@@ -1315,6 +1315,9 @@ var require_dist = __commonJS({
1315
1315
  });
1316
1316
 
1317
1317
  // src/assets/AssetKey.ts
1318
+ function isResourceLocation(value) {
1319
+ return typeof value === "string" && /^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(value);
1320
+ }
1318
1321
  function isBasicAssetKey(obj) {
1319
1322
  return obj !== null && typeof obj === "object" && typeof obj.namespace === "string" && typeof obj.path === "string";
1320
1323
  }
@@ -1701,7 +1704,7 @@ var init_Models = __esm({
1701
1704
  return model ? restore(model) : void 0;
1702
1705
  }
1703
1706
  static contextIdentifier(id) {
1704
- if (typeof id !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(id)) {
1707
+ if (!isResourceLocation(id)) {
1705
1708
  throw new Error(`Invalid item-preview identifier: ${id}`);
1706
1709
  }
1707
1710
  return id.includes(":") ? id : `minecraft:${id}`;
@@ -1846,6 +1849,8 @@ var init_Models = __esm({
1846
1849
  case "minecraft:trident":
1847
1850
  case "conduit":
1848
1851
  case "minecraft:conduit":
1852
+ case "decorated_pot":
1853
+ case "minecraft:decorated_pot":
1849
1854
  return { model: node.base, special };
1850
1855
  case "shulker_box":
1851
1856
  case "minecraft:shulker_box":
@@ -16199,6 +16204,55 @@ var init_MinecraftCubeTexture = __esm({
16199
16204
  }
16200
16205
  });
16201
16206
 
16207
+ // src/assets/DecoratedPots.ts
16208
+ var POTTERY_SHERDS, DecoratedPots;
16209
+ var init_DecoratedPots = __esm({
16210
+ "src/assets/DecoratedPots.ts"() {
16211
+ init_AssetKey();
16212
+ POTTERY_SHERDS = Object.freeze([
16213
+ "angler",
16214
+ "archer",
16215
+ "arms_up",
16216
+ "blade",
16217
+ "brewer",
16218
+ "burn",
16219
+ "danger",
16220
+ "explorer",
16221
+ "flow",
16222
+ "friend",
16223
+ "guster",
16224
+ "heart",
16225
+ "heartbreak",
16226
+ "howl",
16227
+ "miner",
16228
+ "mourner",
16229
+ "plenty",
16230
+ "prize",
16231
+ "scrape",
16232
+ "sheaf",
16233
+ "shelter",
16234
+ "skull",
16235
+ "snort"
16236
+ ].map((pattern2) => `minecraft:${pattern2}_pottery_sherd`));
16237
+ DecoratedPots = class {
16238
+ /** Reads up to four item IDs in back, left, right, front order; missing and unmapped items use plain sides. */
16239
+ static getSideTextures(value, root) {
16240
+ const items = value === void 0 ? [] : value;
16241
+ if (!Array.isArray(items) || items.length > 4) throw new Error("pot_decorations must be an array of at most four item IDs");
16242
+ const textures = items.map((item) => {
16243
+ if (!isResourceLocation(item)) throw new Error("Pot decorations must be item identifiers");
16244
+ const id = item.includes(":") ? item : `minecraft:${item}`;
16245
+ return POTTERY_SHERDS.includes(id) ? id.slice("minecraft:".length).replace(/_sherd$/, "_pattern") : "decorated_pot_side";
16246
+ });
16247
+ return Object.fromEntries(["back", "left", "right", "front"].map((side, index) => [
16248
+ side,
16249
+ new AssetKey("minecraft", `decorated_pot/${textures[index] ?? "decorated_pot_side"}`, "textures", "entity", "assets", ".png", root)
16250
+ ]));
16251
+ }
16252
+ };
16253
+ }
16254
+ });
16255
+
16202
16256
  // src/error/MineRenderError.ts
16203
16257
  var MineRenderError;
16204
16258
  var init_MineRenderError = __esm({
@@ -17055,6 +17109,7 @@ var init_EntityObject = __esm({
17055
17109
  init_AssetKey();
17056
17110
  init_Materials();
17057
17111
  init_MinecraftCubeTexture();
17112
+ init_CubeFace();
17058
17113
  init_three();
17059
17114
  init_EntityAnimationPlayer();
17060
17115
  _EntityObject = class _EntityObject extends SceneObject {
@@ -17229,11 +17284,11 @@ var init_EntityObject = __esm({
17229
17284
  const group = this.createGroup(`layer:${name}`);
17230
17285
  modelRoot.add(group);
17231
17286
  const inward = !Materials.entityModeCulls(layer.render ?? layer.layer.render);
17232
- this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward);
17287
+ this.createPart("root", layer.layer.root, group, layer.layer.texture, Materials.MISSING_TEXTURE, index, inward, this.options.faces?.[name]);
17233
17288
  });
17234
17289
  this.meshesCreated = true;
17235
17290
  }
17236
- createPart(name, part, parent, textureSize, material, renderOrder, inward = true) {
17291
+ createPart(name, part, parent, textureSize, material, renderOrder, inward = true, faces) {
17237
17292
  const anchor = this.createGroup(name);
17238
17293
  anchor.position.fromArray(part.pose.offset);
17239
17294
  anchor.rotation.set(...part.pose.rotation, "ZYX");
@@ -17254,6 +17309,10 @@ var init_EntityObject = __esm({
17254
17309
  ).clone();
17255
17310
  this.geometries.add(geometry);
17256
17311
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
17312
+ if (faces) {
17313
+ geometry.setIndex(Array.from(geometry.getIndex().array).filter((_, index) => faces.includes(CUBE_FACES[Math.floor(index / 6)])));
17314
+ geometry.clearGroups();
17315
+ }
17257
17316
  if (inward && Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
17258
17317
  const index = Array.from(geometry.getIndex().array);
17259
17318
  geometry.setIndex(index.concat(index.slice().reverse()));
@@ -17264,7 +17323,7 @@ var init_EntityObject = __esm({
17264
17323
  if (this.options.wireframe) this.disposeWireframes.push(addWireframeToMesh(geometry, mesh));
17265
17324
  }
17266
17325
  for (const [childName, child] of Object.entries(part.children)) {
17267
- this.createPart(childName, child, anchor, size, material, renderOrder, inward);
17326
+ this.createPart(childName, child, anchor, size, material, renderOrder, inward, faces);
17268
17327
  }
17269
17328
  }
17270
17329
  async applyTextures() {
@@ -17903,7 +17962,9 @@ var init_SpecialItems = __esm({
17903
17962
  init_AssetKey();
17904
17963
  init_Entities();
17905
17964
  init_BannerPatterns();
17965
+ init_DecoratedPots();
17906
17966
  init_ModelTextures();
17967
+ init_CubeFace();
17907
17968
  SpecialItems = class {
17908
17969
  /** Resolves the static entity parts drawn by a special item renderer, in model units. */
17909
17970
  static async getParts(special, root, components = {}) {
@@ -17929,6 +17990,34 @@ var init_SpecialItems = __esm({
17929
17990
  return { model, transform, rotations };
17930
17991
  };
17931
17992
  switch (special.type) {
17993
+ case "minecraft:decorated_pot":
17994
+ case "decorated_pot": {
17995
+ const sideTextures = DecoratedPots.getSideTextures(components["minecraft:pot_decorations"], root);
17996
+ const baseTexture = texture("decorated_pot_base", "decorated_pot");
17997
+ const [base, sides] = await Promise.all([
17998
+ load("decorated_pot_base", baseTexture, new Matrix48()),
17999
+ load("decorated_pot_sides", texture("decorated_pot_side", "decorated_pot"), new Matrix48())
18000
+ ]);
18001
+ const layers = {
18002
+ base: { key: base.model.key, texture: baseTexture, layer: base.model.layer, render: "solid" }
18003
+ };
18004
+ for (const side of ["front", "back", "left", "right"]) {
18005
+ const part = sides.model.layer.root.children[side];
18006
+ if (!part) throw new Error(`Decorated-pot entity model is missing its ${side} side`);
18007
+ layers[side] = { key: sides.model.key, texture: sideTextures[side], render: "solid", layer: {
18008
+ ...sides.model.layer,
18009
+ root: { ...sides.model.layer.root, cubes: [], children: {
18010
+ [side]: part
18011
+ } }
18012
+ } };
18013
+ }
18014
+ await Promise.all([...new Map(Object.values(layers).map((layer) => [layer.texture.serialize(), layer.texture])).values()].map(async (key) => {
18015
+ if (!await ModelTextures.preload(key)) throw new Error(`Missing special item texture ${key.toNamespacedString()}`);
18016
+ }));
18017
+ base.model = { ...base.model, ...layers.base, layers };
18018
+ base.faces = { front: ["north" /* NORTH */], back: ["north" /* NORTH */], left: ["north" /* NORTH */], right: ["north" /* NORTH */] };
18019
+ return [base];
18020
+ }
17932
18021
  case "minecraft:trident":
17933
18022
  case "trident":
17934
18023
  case "minecraft:conduit":
@@ -18289,7 +18378,7 @@ var init_ModelObject = __esm({
18289
18378
  transform.multiply(new Matrix49().makeTranslation(-8, -8, -8));
18290
18379
  try {
18291
18380
  for (const part of parts2) {
18292
- const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints });
18381
+ const object3 = new EntityObject(part.model, { flip: false, wireframe: this.options.wireframe, tints: part.tints, faces: part.faces });
18293
18382
  object3.matrix.copy(transform).multiply(part.transform);
18294
18383
  object3.matrixWorldNeedsUpdate = true;
18295
18384
  object3.matrixAutoUpdate = false;
@@ -18977,6 +19066,7 @@ var BlockEntities = class {
18977
19066
 
18978
19067
  // src/assets/index.ts
18979
19068
  init_BlockStates();
19069
+ init_DecoratedPots();
18980
19070
  init_Entities();
18981
19071
 
18982
19072
  // src/assets/Fonts.ts
@@ -30702,6 +30792,7 @@ export {
30702
30792
  DEFAULT_UV,
30703
30793
  DISPLAY_POSITIONS,
30704
30794
  DYE_COLORS,
30795
+ DecoratedPots,
30705
30796
  DefaultBlockStates,
30706
30797
  DisplayPosition,
30707
30798
  DisplayTransforms,
@@ -30819,6 +30910,7 @@ export {
30819
30910
  isOrthographicCamera,
30820
30911
  isPerspectiveCamera,
30821
30912
  isQuadArray,
30913
+ isResourceLocation,
30822
30914
  isSceneObject,
30823
30915
  isTransformable,
30824
30916
  isTripleArray,