minerender 2.1.0-alpha.89 → 2.1.0-alpha.90
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/browser/index.d.mts +24 -1
- package/dist/browser/index.d.ts +24 -1
- package/dist/browser/index.js +201 -51
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +201 -51
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +209 -56
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +24 -1
- package/dist/node/index.d.ts +24 -1
- package/dist/node/index.js +202 -51
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +201 -51
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -23238,46 +23238,46 @@ function matchesCondition(condition, state) {
|
|
|
23238
23238
|
}
|
|
23239
23239
|
var BlockStateResolver = class {
|
|
23240
23240
|
/** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
|
|
23241
|
-
static async defaults(
|
|
23242
|
-
const defaults =
|
|
23241
|
+
static async defaults(blockState3) {
|
|
23242
|
+
const defaults = blockState3.key ? await BlockStates.getDefaultState(blockState3.key) : void 0;
|
|
23243
23243
|
const state = {};
|
|
23244
23244
|
if (defaults && Object.keys(defaults).length > 0) {
|
|
23245
23245
|
for (const key in defaults) state[key] = defaults[key].default;
|
|
23246
|
-
} else if (
|
|
23247
|
-
const variant = Object.keys(
|
|
23246
|
+
} else if (blockState3.variants) {
|
|
23247
|
+
const variant = Object.keys(blockState3.variants)[0];
|
|
23248
23248
|
if (variant) {
|
|
23249
23249
|
for (const property of variant.split(",")) {
|
|
23250
23250
|
const [key, value] = property.split("=");
|
|
23251
23251
|
state[key] = value;
|
|
23252
23252
|
}
|
|
23253
23253
|
}
|
|
23254
|
-
} else if (
|
|
23255
|
-
const condition =
|
|
23254
|
+
} else if (blockState3.multipart) {
|
|
23255
|
+
const condition = blockState3.multipart.map((part) => part.when).find((when) => when !== void 0 && Object.values(when).every((value) => typeof value === "string"));
|
|
23256
23256
|
for (const [key, value] of Object.entries(condition ?? {})) state[key] = value.split("|")[0];
|
|
23257
23257
|
}
|
|
23258
23258
|
return state;
|
|
23259
23259
|
}
|
|
23260
23260
|
/** Selects matching models. Supply `choose` to control selection within each alternatives array. */
|
|
23261
|
-
static select(
|
|
23262
|
-
return this.matching(
|
|
23261
|
+
static select(blockState3, state, choose = this.choose) {
|
|
23262
|
+
return this.matching(blockState3, state).map(choose);
|
|
23263
23263
|
}
|
|
23264
23264
|
/** Returns matching model groups before choosing weighted alternatives. */
|
|
23265
|
-
static matching(
|
|
23265
|
+
static matching(blockState3, state) {
|
|
23266
23266
|
const out = [];
|
|
23267
|
-
if (
|
|
23268
|
-
if (Object.keys(
|
|
23269
|
-
out.push(
|
|
23267
|
+
if (blockState3.variants) {
|
|
23268
|
+
if (Object.keys(blockState3.variants).length === 1 && "" in blockState3.variants) {
|
|
23269
|
+
out.push(blockState3.variants[""]);
|
|
23270
23270
|
} else {
|
|
23271
|
-
for (const variantKey in
|
|
23271
|
+
for (const variantKey in blockState3.variants) {
|
|
23272
23272
|
const matches = variantKey.split(",").every((property) => {
|
|
23273
23273
|
const [key, value] = property.split("=");
|
|
23274
23274
|
return `${state[key]}` === `${value}`;
|
|
23275
23275
|
});
|
|
23276
|
-
if (matches) out.push(
|
|
23276
|
+
if (matches) out.push(blockState3.variants[variantKey]);
|
|
23277
23277
|
}
|
|
23278
23278
|
}
|
|
23279
|
-
} else if (
|
|
23280
|
-
for (const part of
|
|
23279
|
+
} else if (blockState3.multipart) {
|
|
23280
|
+
for (const part of blockState3.multipart) {
|
|
23281
23281
|
if (part.apply && (!part.when || matchesCondition(part.when, state))) {
|
|
23282
23282
|
out.push(part.apply);
|
|
23283
23283
|
}
|
|
@@ -23405,9 +23405,9 @@ init_ModelCulling();
|
|
|
23405
23405
|
init_FluidGeometry();
|
|
23406
23406
|
init_Entities();
|
|
23407
23407
|
var BlockObject = class _BlockObject extends SceneObject {
|
|
23408
|
-
constructor(
|
|
23408
|
+
constructor(blockState3, options) {
|
|
23409
23409
|
super(options);
|
|
23410
|
-
this.blockState =
|
|
23410
|
+
this.blockState = blockState3;
|
|
23411
23411
|
this.isBlockObject = true;
|
|
23412
23412
|
this._previousState = {};
|
|
23413
23413
|
this._state = {};
|
|
@@ -23796,6 +23796,155 @@ function isBlockObject(obj) {
|
|
|
23796
23796
|
init_FluidGeometry();
|
|
23797
23797
|
init_FluidModelObject();
|
|
23798
23798
|
|
|
23799
|
+
// src/model/multiblock/LitematicaParser.ts
|
|
23800
|
+
init_MineRenderError();
|
|
23801
|
+
var LitematicaParser = class {
|
|
23802
|
+
/**
|
|
23803
|
+
* Parses decoded NBT, preserving subregion placement and omitting air.
|
|
23804
|
+
* Later entries in regions replace earlier cells, including with air.
|
|
23805
|
+
* Size encloses all region bounds; positions retain the schematic origin.
|
|
23806
|
+
* Metadata and scheduled ticks are not imported. Named regions can be placed individually.
|
|
23807
|
+
*/
|
|
23808
|
+
static async parse(nbt) {
|
|
23809
|
+
const tags = nbt.value;
|
|
23810
|
+
const version2 = integer2(tags.Version, "Version");
|
|
23811
|
+
if (version2 < 5 || version2 > 7) throw new MineRenderError(`Unsupported Litematica version ${version2}; expected 5, 6, or 7`);
|
|
23812
|
+
const dataVersion = tags.MinecraftDataVersion === void 0 ? void 0 : integer2(tags.MinecraftDataVersion, "MinecraftDataVersion");
|
|
23813
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
23814
|
+
const regions = [];
|
|
23815
|
+
const min = [Infinity, Infinity, Infinity];
|
|
23816
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
23817
|
+
for (const [name, tag] of Object.entries(compound(tags.Regions, "Regions"))) {
|
|
23818
|
+
const region = readRegion(compound(tag, `region ${name}`), name, dataVersion, blocks);
|
|
23819
|
+
regions.push(region);
|
|
23820
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
23821
|
+
const start = minimum(region.position[axis], region.signedSize[axis]);
|
|
23822
|
+
min[axis] = Math.min(min[axis], start);
|
|
23823
|
+
max[axis] = Math.max(max[axis], start + region.size[axis]);
|
|
23824
|
+
}
|
|
23825
|
+
}
|
|
23826
|
+
return {
|
|
23827
|
+
size: regions.length ? min.map((value, axis) => max[axis] - value) : [0, 0, 0],
|
|
23828
|
+
blocks: [...blocks.values()],
|
|
23829
|
+
entities: regions.flatMap((region) => region.entities ?? []),
|
|
23830
|
+
dataVersion,
|
|
23831
|
+
regions
|
|
23832
|
+
};
|
|
23833
|
+
}
|
|
23834
|
+
};
|
|
23835
|
+
function readRegion(tags, name, dataVersion, combined) {
|
|
23836
|
+
const position = blockPosition(compound(tags.Position, `region ${name} Position`));
|
|
23837
|
+
const signedSize = blockPosition(compound(tags.Size, `region ${name} Size`));
|
|
23838
|
+
if (signedSize.some((value) => value === 0)) throw new MineRenderError(`Litematica region ${name} dimensions must be nonzero`);
|
|
23839
|
+
const size = signedSize.map(Math.abs);
|
|
23840
|
+
const min = position.map((value, axis) => minimum(value, signedSize[axis]));
|
|
23841
|
+
const [width, height, length] = size;
|
|
23842
|
+
const volume = width * height * length;
|
|
23843
|
+
const palette = compounds(tags.BlockStatePalette, "BlockStatePalette").map(blockState);
|
|
23844
|
+
if (!palette.length) throw new MineRenderError(`Litematica region ${name} has no block palette`);
|
|
23845
|
+
const bits = Math.max(2, Math.ceil(Math.log2(palette.length)));
|
|
23846
|
+
if (!Number.isSafeInteger(volume * bits)) throw new MineRenderError(`Litematica region ${name} volume is too large`);
|
|
23847
|
+
const packed = tags.BlockStates;
|
|
23848
|
+
const expected = Math.ceil(volume * bits / 64);
|
|
23849
|
+
if (packed?.type !== "longArray" || !Array.isArray(packed.value) || packed.value.length !== expected) {
|
|
23850
|
+
throw new MineRenderError(`Litematica region ${name} BlockStates must contain ${expected} longs`);
|
|
23851
|
+
}
|
|
23852
|
+
const words = packed.value.map((pair) => {
|
|
23853
|
+
if (!Array.isArray(pair) || pair.length !== 2 || !pair.every((value) => Number.isInteger(value) && value >= -2147483648 && value <= 4294967295)) {
|
|
23854
|
+
throw new MineRenderError(`Litematica region ${name} has an invalid BlockStates long`);
|
|
23855
|
+
}
|
|
23856
|
+
return [pair[0] >>> 0, pair[1] >>> 0];
|
|
23857
|
+
});
|
|
23858
|
+
const blockEntities = /* @__PURE__ */ new Map();
|
|
23859
|
+
for (const tile of compounds(tags.TileEntities, "TileEntities")) {
|
|
23860
|
+
const pos = blockPosition(tile);
|
|
23861
|
+
if (pos.some((value2, axis) => value2 < 0 || value2 >= size[axis])) {
|
|
23862
|
+
throw new MineRenderError(`Litematica region ${name} block entity is outside its dimensions`);
|
|
23863
|
+
}
|
|
23864
|
+
const index = pos[0] + pos[2] * width + pos[1] * width * length;
|
|
23865
|
+
if (blockEntities.has(index)) throw new MineRenderError(`Duplicate Litematica block entity at index ${index}`);
|
|
23866
|
+
const value = { ...tile };
|
|
23867
|
+
for (const [axis, key] of ["x", "y", "z"].entries()) value[key] = { type: "int", value: pos[axis] + min[axis] };
|
|
23868
|
+
blockEntities.set(index, { type: "compound", value });
|
|
23869
|
+
}
|
|
23870
|
+
const blocks = [];
|
|
23871
|
+
const mask = 2 ** bits - 1;
|
|
23872
|
+
for (let index = 0; index < volume; index++) {
|
|
23873
|
+
const word = Math.floor(index * bits / 64);
|
|
23874
|
+
const shift = index * bits % 64;
|
|
23875
|
+
const [high, low] = words[word];
|
|
23876
|
+
let value = shift < 32 ? low >>> shift : high >>> shift - 32;
|
|
23877
|
+
if (shift < 32 && shift + bits > 32) value |= high << 32 - shift;
|
|
23878
|
+
if (shift + bits > 64) value |= words[word + 1][1] << 64 - shift;
|
|
23879
|
+
const id = (value & mask) >>> 0;
|
|
23880
|
+
const state = palette[id];
|
|
23881
|
+
if (!state) throw new MineRenderError(`Litematica region ${name} palette index ${id} does not exist`);
|
|
23882
|
+
const pos = [
|
|
23883
|
+
index % width + min[0],
|
|
23884
|
+
Math.floor(index / (width * length)) + min[1],
|
|
23885
|
+
Math.floor(index / width) % length + min[2]
|
|
23886
|
+
];
|
|
23887
|
+
const key = pos.join(",");
|
|
23888
|
+
if (["minecraft:air", "minecraft:cave_air", "minecraft:void_air"].includes(state.type)) {
|
|
23889
|
+
combined.delete(key);
|
|
23890
|
+
continue;
|
|
23891
|
+
}
|
|
23892
|
+
const block = { type: state.type, properties: { ...state.properties }, position: pos, nbt: blockEntities.get(index) };
|
|
23893
|
+
blocks.push(block);
|
|
23894
|
+
combined.set(key, block);
|
|
23895
|
+
}
|
|
23896
|
+
const entities = compounds(tags.Entities, "Entities").map((entity) => {
|
|
23897
|
+
const pos = entity.Pos;
|
|
23898
|
+
if (pos?.type !== "list" || pos.value.type !== "double" || pos.value.value.length !== 3 || !pos.value.value.every(Number.isFinite)) {
|
|
23899
|
+
throw new MineRenderError(`Litematica region ${name} entity Pos must contain three doubles`);
|
|
23900
|
+
}
|
|
23901
|
+
const absolute = pos.value.value.map((value2, axis) => value2 + position[axis]);
|
|
23902
|
+
const value = { ...entity, Pos: { type: "list", value: { type: "double", value: [...absolute] } } };
|
|
23903
|
+
return { position: absolute, nbt: { type: "compound", value } };
|
|
23904
|
+
});
|
|
23905
|
+
return { name, position, signedSize, size, blocks, entities, dataVersion };
|
|
23906
|
+
}
|
|
23907
|
+
function minimum(position, size) {
|
|
23908
|
+
return position + Math.min(0, size + 1);
|
|
23909
|
+
}
|
|
23910
|
+
function integer2(tag, name) {
|
|
23911
|
+
if (tag?.type !== "int" || !Number.isInteger(tag.value) || tag.value < -2147483648 || tag.value > 2147483647) {
|
|
23912
|
+
throw new MineRenderError(`Litematica ${name} must be an int`);
|
|
23913
|
+
}
|
|
23914
|
+
return tag.value;
|
|
23915
|
+
}
|
|
23916
|
+
function compound(tag, name) {
|
|
23917
|
+
if (tag?.type !== "compound" || !tag.value || typeof tag.value !== "object" || Array.isArray(tag.value)) {
|
|
23918
|
+
throw new MineRenderError(`Litematica ${name} must be a compound`);
|
|
23919
|
+
}
|
|
23920
|
+
return tag.value;
|
|
23921
|
+
}
|
|
23922
|
+
function blockPosition(tags) {
|
|
23923
|
+
return ["x", "y", "z"].map((axis) => integer2(tags[axis], axis));
|
|
23924
|
+
}
|
|
23925
|
+
function compounds(tag, name) {
|
|
23926
|
+
if (tag === void 0) return [];
|
|
23927
|
+
if (tag.type === "list" && Array.isArray(tag.value.value)) {
|
|
23928
|
+
if (tag.value.value.length === 0) return [];
|
|
23929
|
+
if (tag.value.type === "compound") return tag.value.value;
|
|
23930
|
+
}
|
|
23931
|
+
throw new MineRenderError(`Litematica ${name} must be a compound list`);
|
|
23932
|
+
}
|
|
23933
|
+
function blockState(tags) {
|
|
23934
|
+
const name = tags.Name;
|
|
23935
|
+
if (name?.type !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(name.value)) {
|
|
23936
|
+
throw new MineRenderError("Litematica palette entry must have a block Name");
|
|
23937
|
+
}
|
|
23938
|
+
const properties = {};
|
|
23939
|
+
if (tags.Properties !== void 0) {
|
|
23940
|
+
for (const [key, tag] of Object.entries(compound(tags.Properties, "block Properties"))) {
|
|
23941
|
+
if (tag?.type !== "string") throw new MineRenderError("Litematica block properties must be strings");
|
|
23942
|
+
Object.defineProperty(properties, key, { value: tag.value, enumerable: true, writable: true, configurable: true });
|
|
23943
|
+
}
|
|
23944
|
+
}
|
|
23945
|
+
return { type: name.value.includes(":") ? name.value : `minecraft:${name.value}`, properties };
|
|
23946
|
+
}
|
|
23947
|
+
|
|
23799
23948
|
// src/model/multiblock/SchematicParser.ts
|
|
23800
23949
|
init_MineRenderError();
|
|
23801
23950
|
|
|
@@ -25596,12 +25745,12 @@ var SpongeSchematicParser = class {
|
|
|
25596
25745
|
* Biomes and metadata are not imported, and DataVersion does not trigger migration.
|
|
25597
25746
|
*/
|
|
25598
25747
|
static async parse(nbt) {
|
|
25599
|
-
const tags = nbt.value.Schematic === void 0 ? nbt.value :
|
|
25600
|
-
const version2 =
|
|
25748
|
+
const tags = nbt.value.Schematic === void 0 ? nbt.value : compound2(nbt.value.Schematic, "Schematic");
|
|
25749
|
+
const version2 = integer3(tags.Version, "Version");
|
|
25601
25750
|
if (version2 !== 2 && version2 !== 3) {
|
|
25602
25751
|
throw new MineRenderError(`Unsupported Sponge schematic version ${version2}; expected 2 or 3`);
|
|
25603
25752
|
}
|
|
25604
|
-
const dataVersion =
|
|
25753
|
+
const dataVersion = integer3(tags.DataVersion, "DataVersion");
|
|
25605
25754
|
const size = ["Width", "Height", "Length"].map((name) => {
|
|
25606
25755
|
const tag = tags[name];
|
|
25607
25756
|
if (tag?.type !== "short" || !Number.isInteger(tag.value) || tag.value < -32768 || tag.value > 65535 || tag.value === 0) {
|
|
@@ -25611,19 +25760,19 @@ var SpongeSchematicParser = class {
|
|
|
25611
25760
|
});
|
|
25612
25761
|
const offset = tags.Offset === void 0 ? [0, 0, 0] : intPosition(tags.Offset, "Offset");
|
|
25613
25762
|
const blocks = [];
|
|
25614
|
-
const container = version2 === 2 ? tags : tags.Blocks === void 0 ? void 0 :
|
|
25763
|
+
const container = version2 === 2 ? tags : tags.Blocks === void 0 ? void 0 : compound2(tags.Blocks, "Blocks");
|
|
25615
25764
|
if (container) {
|
|
25616
25765
|
const paletteTag = container.Palette;
|
|
25617
25766
|
if (!paletteTag) throw new MineRenderError("Sponge schematic requires a local Palette; global block IDs are not supported");
|
|
25618
25767
|
const palette = /* @__PURE__ */ new Map();
|
|
25619
|
-
const paletteMax = version2 === 2 && tags.PaletteMax !== void 0 ?
|
|
25768
|
+
const paletteMax = version2 === 2 && tags.PaletteMax !== void 0 ? integer3(tags.PaletteMax, "PaletteMax") : void 0;
|
|
25620
25769
|
if (paletteMax !== void 0 && paletteMax <= 0) throw new MineRenderError("Sponge schematic PaletteMax must be positive");
|
|
25621
|
-
for (const [state, tag] of Object.entries(
|
|
25622
|
-
const id =
|
|
25770
|
+
for (const [state, tag] of Object.entries(compound2(paletteTag, "Palette"))) {
|
|
25771
|
+
const id = integer3(tag, "Palette index");
|
|
25623
25772
|
if (id < 0 || palette.has(id) || paletteMax !== void 0 && id >= paletteMax) {
|
|
25624
25773
|
throw new MineRenderError(`Invalid or duplicate Sponge schematic palette index ${id}`);
|
|
25625
25774
|
}
|
|
25626
|
-
palette.set(id,
|
|
25775
|
+
palette.set(id, blockState2(state));
|
|
25627
25776
|
}
|
|
25628
25777
|
const [width, height, length] = size;
|
|
25629
25778
|
const volume = width * height * length;
|
|
@@ -25689,13 +25838,13 @@ var SpongeSchematicParser = class {
|
|
|
25689
25838
|
return { size, blocks, entities, dataVersion };
|
|
25690
25839
|
}
|
|
25691
25840
|
};
|
|
25692
|
-
function
|
|
25841
|
+
function integer3(tag, name) {
|
|
25693
25842
|
if (tag?.type !== "int" || !Number.isInteger(tag.value) || tag.value < -2147483648 || tag.value > 2147483647) {
|
|
25694
25843
|
throw new MineRenderError(`Sponge schematic ${name} must be an int`);
|
|
25695
25844
|
}
|
|
25696
25845
|
return tag.value;
|
|
25697
25846
|
}
|
|
25698
|
-
function
|
|
25847
|
+
function compound2(tag, name) {
|
|
25699
25848
|
if (tag?.type !== "compound" || !tag.value || typeof tag.value !== "object" || Array.isArray(tag.value)) {
|
|
25700
25849
|
throw new MineRenderError(`Sponge schematic ${name} must be a compound`);
|
|
25701
25850
|
}
|
|
@@ -25716,7 +25865,7 @@ function compoundList2(tags, name) {
|
|
|
25716
25865
|
}
|
|
25717
25866
|
throw new MineRenderError(`Sponge schematic ${name} must be a compound list`);
|
|
25718
25867
|
}
|
|
25719
|
-
function
|
|
25868
|
+
function blockState2(state) {
|
|
25720
25869
|
const match = /^((?:[a-z0-9_.-]+:)?[a-z0-9_./-]+)(?:\[([^\[\]]*)\])?$/.exec(state);
|
|
25721
25870
|
if (!match) throw new MineRenderError(`Invalid Sponge schematic block state ${state}`);
|
|
25722
25871
|
const properties = {};
|
|
@@ -25733,7 +25882,7 @@ function entityData(entity, version2) {
|
|
|
25733
25882
|
const id = entity.Id;
|
|
25734
25883
|
if (id?.type !== "string" || !id.value) throw new MineRenderError("Sponge schematic entity Id must be a nonempty string");
|
|
25735
25884
|
const { Id, Pos, ...extra } = entity;
|
|
25736
|
-
const value = version2 === 2 ? extra : entity.Data === void 0 ? {} : { ...
|
|
25885
|
+
const value = version2 === 2 ? extra : entity.Data === void 0 ? {} : { ...compound2(entity.Data, "entity Data") };
|
|
25737
25886
|
value.id = { type: "string", value: id.value.includes(":") ? id.value : `minecraft:${id.value}` };
|
|
25738
25887
|
return value;
|
|
25739
25888
|
}
|
|
@@ -26965,8 +27114,8 @@ var MineRenderScene = class _MineRenderScene extends Scene4 {
|
|
|
26965
27114
|
* Set `options.initialState` to choose block properties such as `facing` or `axis`.
|
|
26966
27115
|
* Use the returned object's `setPosition` method to move all of its model parts.
|
|
26967
27116
|
*/
|
|
26968
|
-
async addBlock(
|
|
26969
|
-
return this.addSceneObject(
|
|
27117
|
+
async addBlock(blockState3, options, parent = this) {
|
|
27118
|
+
return this.addSceneObject(blockState3, () => new BlockObject(blockState3, options), options, parent);
|
|
26970
27119
|
}
|
|
26971
27120
|
/**
|
|
26972
27121
|
* Loads a skin and adds an initialized player model.
|
|
@@ -29022,8 +29171,8 @@ async function abortable2(promise, signal) {
|
|
|
29022
29171
|
}
|
|
29023
29172
|
}
|
|
29024
29173
|
var AnvilWorldSource = class {
|
|
29025
|
-
constructor(
|
|
29026
|
-
this.readRegion =
|
|
29174
|
+
constructor(readRegion2, options = {}) {
|
|
29175
|
+
this.readRegion = readRegion2;
|
|
29027
29176
|
this.regions = /* @__PURE__ */ new Map();
|
|
29028
29177
|
this.pending = /* @__PURE__ */ new Map();
|
|
29029
29178
|
this.cachedBytes = 0;
|
|
@@ -29178,18 +29327,18 @@ var SectionModels = class {
|
|
|
29178
29327
|
if (!Number.isInteger(maxAtlasSize) || maxAtlasSize < 1) throw new RangeError("maxAtlasSize must be a positive integer");
|
|
29179
29328
|
}
|
|
29180
29329
|
/** Returns a cube template, or `undefined` when the block requires an individual render object. */
|
|
29181
|
-
async get(
|
|
29182
|
-
if (!
|
|
29183
|
-
let states = this.states.get(
|
|
29184
|
-
if (!states) this.states.set(
|
|
29330
|
+
async get(blockState3, properties = {}) {
|
|
29331
|
+
if (!blockState3.variants || blockState3.multipart) return void 0;
|
|
29332
|
+
let states = this.states.get(blockState3);
|
|
29333
|
+
if (!states) this.states.set(blockState3, states = /* @__PURE__ */ new Map());
|
|
29185
29334
|
const key = JSON.stringify(Object.entries(properties).sort(([a], [b]) => a.localeCompare(b)));
|
|
29186
|
-
const prepared = await cached(states, key, () => this.prepare(
|
|
29335
|
+
const prepared = await cached(states, key, () => this.prepare(blockState3, properties));
|
|
29187
29336
|
if (!prepared) return void 0;
|
|
29188
29337
|
return prepared.templates.get(BlockStateResolver.choose(prepared.variants));
|
|
29189
29338
|
}
|
|
29190
|
-
async prepare(
|
|
29191
|
-
const state = { ...await BlockStateResolver.defaults(
|
|
29192
|
-
const groups = BlockStateResolver.matching(
|
|
29339
|
+
async prepare(blockState3, properties) {
|
|
29340
|
+
const state = { ...await BlockStateResolver.defaults(blockState3), ...properties };
|
|
29341
|
+
const groups = BlockStateResolver.matching(blockState3, state);
|
|
29193
29342
|
if (groups.length !== 1) return void 0;
|
|
29194
29343
|
const variants = groups[0];
|
|
29195
29344
|
const choices = Array.isArray(variants) ? variants : [variants];
|
|
@@ -29201,7 +29350,7 @@ var SectionModels = class {
|
|
|
29201
29350
|
const atlas = await UVMapper.getAtlas(model);
|
|
29202
29351
|
const rotation = BlockStateResolver.rotation(variant);
|
|
29203
29352
|
if (!atlas || atlas.hasAnimation || !ModelCulling.isOpaqueFullCube(atlas) || atlas.image.width > this.maxAtlasSize || atlas.image.height > this.maxAtlasSize || ModelCulling.toLocalMask(63, rotation) !== 63) return void 0;
|
|
29204
|
-
const tints = await BlockTints.get(
|
|
29353
|
+
const tints = await BlockTints.get(blockState3.key, state, model);
|
|
29205
29354
|
let models = this.models.get(model);
|
|
29206
29355
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
29207
29356
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
@@ -29908,10 +30057,10 @@ var Chunk = class _Chunk {
|
|
|
29908
30057
|
if (resolutions.has(key)) continue;
|
|
29909
30058
|
const stored = { type: block.type, properties: block.properties ? { ...block.properties } : void 0 };
|
|
29910
30059
|
const resolved = (async () => {
|
|
29911
|
-
const
|
|
29912
|
-
const perBlock = !
|
|
29913
|
-
if (!perBlock) await this.sectionModels.get(
|
|
29914
|
-
return { blockState:
|
|
30060
|
+
const blockState3 = await BlockStates.get(AssetKey.parse("blockstates", stored.type));
|
|
30061
|
+
const perBlock = !blockState3 || !this.sectionModels || !!getFluidKind(blockState3.key, stored.properties) || !!(blockState3.key && BlockEntities.entry(await BlockEntities.getIndex(blockState3.key.root), blockState3.key.toNamespacedString()));
|
|
30062
|
+
if (!perBlock) await this.sectionModels.get(blockState3, stored.properties);
|
|
30063
|
+
return { blockState: blockState3, perBlock };
|
|
29915
30064
|
})();
|
|
29916
30065
|
resolutions.set(key, resolved);
|
|
29917
30066
|
void resolved.catch(() => void 0);
|
|
@@ -29936,17 +30085,17 @@ var Chunk = class _Chunk {
|
|
|
29936
30085
|
if (!readBlock) continue;
|
|
29937
30086
|
const stored = readBlock();
|
|
29938
30087
|
const key = ChunkData.paletteKey(stored);
|
|
29939
|
-
const { blockState:
|
|
29940
|
-
if (!
|
|
30088
|
+
const { blockState: blockState3, perBlock } = await resolutions.get(key);
|
|
30089
|
+
if (!blockState3) {
|
|
29941
30090
|
this.data.set(index, void 0);
|
|
29942
30091
|
continue;
|
|
29943
30092
|
}
|
|
29944
|
-
const template = perBlock ? void 0 : await this.sectionModels.get(
|
|
30093
|
+
const template = perBlock ? void 0 : await this.sectionModels.get(blockState3, stored.properties);
|
|
29945
30094
|
if (template) {
|
|
29946
30095
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
29947
30096
|
this.meshDirty = true;
|
|
29948
30097
|
} else {
|
|
29949
|
-
object3 = await this.scene.addBlock(
|
|
30098
|
+
object3 = await this.scene.addBlock(blockState3, {
|
|
29950
30099
|
mergeMeshes: true,
|
|
29951
30100
|
instanceMeshes: true,
|
|
29952
30101
|
maxInstanceCount: 2e3,
|
|
@@ -30311,6 +30460,7 @@ export {
|
|
|
30311
30460
|
InstanceManager,
|
|
30312
30461
|
InstanceReference,
|
|
30313
30462
|
ItemTints,
|
|
30463
|
+
LitematicaParser,
|
|
30314
30464
|
MapControls,
|
|
30315
30465
|
Materials,
|
|
30316
30466
|
Meshes,
|