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/browser/index.mjs
CHANGED
|
@@ -23192,46 +23192,46 @@ function matchesCondition(condition, state) {
|
|
|
23192
23192
|
}
|
|
23193
23193
|
var BlockStateResolver = class {
|
|
23194
23194
|
/** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
|
|
23195
|
-
static async defaults(
|
|
23196
|
-
const defaults =
|
|
23195
|
+
static async defaults(blockState3) {
|
|
23196
|
+
const defaults = blockState3.key ? await BlockStates.getDefaultState(blockState3.key) : void 0;
|
|
23197
23197
|
const state = {};
|
|
23198
23198
|
if (defaults && Object.keys(defaults).length > 0) {
|
|
23199
23199
|
for (const key in defaults) state[key] = defaults[key].default;
|
|
23200
|
-
} else if (
|
|
23201
|
-
const variant = Object.keys(
|
|
23200
|
+
} else if (blockState3.variants) {
|
|
23201
|
+
const variant = Object.keys(blockState3.variants)[0];
|
|
23202
23202
|
if (variant) {
|
|
23203
23203
|
for (const property of variant.split(",")) {
|
|
23204
23204
|
const [key, value] = property.split("=");
|
|
23205
23205
|
state[key] = value;
|
|
23206
23206
|
}
|
|
23207
23207
|
}
|
|
23208
|
-
} else if (
|
|
23209
|
-
const condition =
|
|
23208
|
+
} else if (blockState3.multipart) {
|
|
23209
|
+
const condition = blockState3.multipart.map((part) => part.when).find((when) => when !== void 0 && Object.values(when).every((value) => typeof value === "string"));
|
|
23210
23210
|
for (const [key, value] of Object.entries(condition ?? {})) state[key] = value.split("|")[0];
|
|
23211
23211
|
}
|
|
23212
23212
|
return state;
|
|
23213
23213
|
}
|
|
23214
23214
|
/** Selects matching models. Supply `choose` to control selection within each alternatives array. */
|
|
23215
|
-
static select(
|
|
23216
|
-
return this.matching(
|
|
23215
|
+
static select(blockState3, state, choose = this.choose) {
|
|
23216
|
+
return this.matching(blockState3, state).map(choose);
|
|
23217
23217
|
}
|
|
23218
23218
|
/** Returns matching model groups before choosing weighted alternatives. */
|
|
23219
|
-
static matching(
|
|
23219
|
+
static matching(blockState3, state) {
|
|
23220
23220
|
const out = [];
|
|
23221
|
-
if (
|
|
23222
|
-
if (Object.keys(
|
|
23223
|
-
out.push(
|
|
23221
|
+
if (blockState3.variants) {
|
|
23222
|
+
if (Object.keys(blockState3.variants).length === 1 && "" in blockState3.variants) {
|
|
23223
|
+
out.push(blockState3.variants[""]);
|
|
23224
23224
|
} else {
|
|
23225
|
-
for (const variantKey in
|
|
23225
|
+
for (const variantKey in blockState3.variants) {
|
|
23226
23226
|
const matches = variantKey.split(",").every((property) => {
|
|
23227
23227
|
const [key, value] = property.split("=");
|
|
23228
23228
|
return `${state[key]}` === `${value}`;
|
|
23229
23229
|
});
|
|
23230
|
-
if (matches) out.push(
|
|
23230
|
+
if (matches) out.push(blockState3.variants[variantKey]);
|
|
23231
23231
|
}
|
|
23232
23232
|
}
|
|
23233
|
-
} else if (
|
|
23234
|
-
for (const part of
|
|
23233
|
+
} else if (blockState3.multipart) {
|
|
23234
|
+
for (const part of blockState3.multipart) {
|
|
23235
23235
|
if (part.apply && (!part.when || matchesCondition(part.when, state))) {
|
|
23236
23236
|
out.push(part.apply);
|
|
23237
23237
|
}
|
|
@@ -23359,9 +23359,9 @@ init_ModelCulling();
|
|
|
23359
23359
|
init_FluidGeometry();
|
|
23360
23360
|
init_Entities();
|
|
23361
23361
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
23362
|
-
constructor(
|
|
23362
|
+
constructor(blockState3, options) {
|
|
23363
23363
|
super(options);
|
|
23364
|
-
this.blockState =
|
|
23364
|
+
this.blockState = blockState3;
|
|
23365
23365
|
this.isBlockObject = true;
|
|
23366
23366
|
this._previousState = {};
|
|
23367
23367
|
this._state = {};
|
|
@@ -23749,6 +23749,155 @@ function isBlockObject(obj) {
|
|
|
23749
23749
|
init_FluidGeometry();
|
|
23750
23750
|
init_FluidModelObject();
|
|
23751
23751
|
|
|
23752
|
+
// src/model/multiblock/LitematicaParser.ts
|
|
23753
|
+
init_MineRenderError();
|
|
23754
|
+
var LitematicaParser = class {
|
|
23755
|
+
/**
|
|
23756
|
+
* Parses decoded NBT, preserving subregion placement and omitting air.
|
|
23757
|
+
* Later entries in regions replace earlier cells, including with air.
|
|
23758
|
+
* Size encloses all region bounds; positions retain the schematic origin.
|
|
23759
|
+
* Metadata and scheduled ticks are not imported. Named regions can be placed individually.
|
|
23760
|
+
*/
|
|
23761
|
+
static async parse(nbt) {
|
|
23762
|
+
const tags = nbt.value;
|
|
23763
|
+
const version2 = integer2(tags.Version, "Version");
|
|
23764
|
+
if (version2 < 5 || version2 > 7) throw new MineRenderError(`Unsupported Litematica version ${version2}; expected 5, 6, or 7`);
|
|
23765
|
+
const dataVersion = tags.MinecraftDataVersion === void 0 ? void 0 : integer2(tags.MinecraftDataVersion, "MinecraftDataVersion");
|
|
23766
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
23767
|
+
const regions = [];
|
|
23768
|
+
const min = [Infinity, Infinity, Infinity];
|
|
23769
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
23770
|
+
for (const [name, tag] of Object.entries(compound(tags.Regions, "Regions"))) {
|
|
23771
|
+
const region = readRegion(compound(tag, `region ${name}`), name, dataVersion, blocks);
|
|
23772
|
+
regions.push(region);
|
|
23773
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
23774
|
+
const start = minimum(region.position[axis], region.signedSize[axis]);
|
|
23775
|
+
min[axis] = Math.min(min[axis], start);
|
|
23776
|
+
max[axis] = Math.max(max[axis], start + region.size[axis]);
|
|
23777
|
+
}
|
|
23778
|
+
}
|
|
23779
|
+
return {
|
|
23780
|
+
size: regions.length ? min.map((value, axis) => max[axis] - value) : [0, 0, 0],
|
|
23781
|
+
blocks: [...blocks.values()],
|
|
23782
|
+
entities: regions.flatMap((region) => region.entities ?? []),
|
|
23783
|
+
dataVersion,
|
|
23784
|
+
regions
|
|
23785
|
+
};
|
|
23786
|
+
}
|
|
23787
|
+
};
|
|
23788
|
+
function readRegion(tags, name, dataVersion, combined) {
|
|
23789
|
+
const position = blockPosition(compound(tags.Position, `region ${name} Position`));
|
|
23790
|
+
const signedSize = blockPosition(compound(tags.Size, `region ${name} Size`));
|
|
23791
|
+
if (signedSize.some((value) => value === 0)) throw new MineRenderError(`Litematica region ${name} dimensions must be nonzero`);
|
|
23792
|
+
const size = signedSize.map(Math.abs);
|
|
23793
|
+
const min = position.map((value, axis) => minimum(value, signedSize[axis]));
|
|
23794
|
+
const [width, height, length] = size;
|
|
23795
|
+
const volume = width * height * length;
|
|
23796
|
+
const palette = compounds(tags.BlockStatePalette, "BlockStatePalette").map(blockState);
|
|
23797
|
+
if (!palette.length) throw new MineRenderError(`Litematica region ${name} has no block palette`);
|
|
23798
|
+
const bits = Math.max(2, Math.ceil(Math.log2(palette.length)));
|
|
23799
|
+
if (!Number.isSafeInteger(volume * bits)) throw new MineRenderError(`Litematica region ${name} volume is too large`);
|
|
23800
|
+
const packed = tags.BlockStates;
|
|
23801
|
+
const expected = Math.ceil(volume * bits / 64);
|
|
23802
|
+
if (packed?.type !== "longArray" || !Array.isArray(packed.value) || packed.value.length !== expected) {
|
|
23803
|
+
throw new MineRenderError(`Litematica region ${name} BlockStates must contain ${expected} longs`);
|
|
23804
|
+
}
|
|
23805
|
+
const words = packed.value.map((pair) => {
|
|
23806
|
+
if (!Array.isArray(pair) || pair.length !== 2 || !pair.every((value) => Number.isInteger(value) && value >= -2147483648 && value <= 4294967295)) {
|
|
23807
|
+
throw new MineRenderError(`Litematica region ${name} has an invalid BlockStates long`);
|
|
23808
|
+
}
|
|
23809
|
+
return [pair[0] >>> 0, pair[1] >>> 0];
|
|
23810
|
+
});
|
|
23811
|
+
const blockEntities = /* @__PURE__ */ new Map();
|
|
23812
|
+
for (const tile of compounds(tags.TileEntities, "TileEntities")) {
|
|
23813
|
+
const pos = blockPosition(tile);
|
|
23814
|
+
if (pos.some((value2, axis) => value2 < 0 || value2 >= size[axis])) {
|
|
23815
|
+
throw new MineRenderError(`Litematica region ${name} block entity is outside its dimensions`);
|
|
23816
|
+
}
|
|
23817
|
+
const index = pos[0] + pos[2] * width + pos[1] * width * length;
|
|
23818
|
+
if (blockEntities.has(index)) throw new MineRenderError(`Duplicate Litematica block entity at index ${index}`);
|
|
23819
|
+
const value = { ...tile };
|
|
23820
|
+
for (const [axis, key] of ["x", "y", "z"].entries()) value[key] = { type: "int", value: pos[axis] + min[axis] };
|
|
23821
|
+
blockEntities.set(index, { type: "compound", value });
|
|
23822
|
+
}
|
|
23823
|
+
const blocks = [];
|
|
23824
|
+
const mask = 2 ** bits - 1;
|
|
23825
|
+
for (let index = 0; index < volume; index++) {
|
|
23826
|
+
const word = Math.floor(index * bits / 64);
|
|
23827
|
+
const shift = index * bits % 64;
|
|
23828
|
+
const [high, low] = words[word];
|
|
23829
|
+
let value = shift < 32 ? low >>> shift : high >>> shift - 32;
|
|
23830
|
+
if (shift < 32 && shift + bits > 32) value |= high << 32 - shift;
|
|
23831
|
+
if (shift + bits > 64) value |= words[word + 1][1] << 64 - shift;
|
|
23832
|
+
const id = (value & mask) >>> 0;
|
|
23833
|
+
const state = palette[id];
|
|
23834
|
+
if (!state) throw new MineRenderError(`Litematica region ${name} palette index ${id} does not exist`);
|
|
23835
|
+
const pos = [
|
|
23836
|
+
index % width + min[0],
|
|
23837
|
+
Math.floor(index / (width * length)) + min[1],
|
|
23838
|
+
Math.floor(index / width) % length + min[2]
|
|
23839
|
+
];
|
|
23840
|
+
const key = pos.join(",");
|
|
23841
|
+
if (["minecraft:air", "minecraft:cave_air", "minecraft:void_air"].includes(state.type)) {
|
|
23842
|
+
combined.delete(key);
|
|
23843
|
+
continue;
|
|
23844
|
+
}
|
|
23845
|
+
const block = { type: state.type, properties: { ...state.properties }, position: pos, nbt: blockEntities.get(index) };
|
|
23846
|
+
blocks.push(block);
|
|
23847
|
+
combined.set(key, block);
|
|
23848
|
+
}
|
|
23849
|
+
const entities = compounds(tags.Entities, "Entities").map((entity) => {
|
|
23850
|
+
const pos = entity.Pos;
|
|
23851
|
+
if (pos?.type !== "list" || pos.value.type !== "double" || pos.value.value.length !== 3 || !pos.value.value.every(Number.isFinite)) {
|
|
23852
|
+
throw new MineRenderError(`Litematica region ${name} entity Pos must contain three doubles`);
|
|
23853
|
+
}
|
|
23854
|
+
const absolute = pos.value.value.map((value2, axis) => value2 + position[axis]);
|
|
23855
|
+
const value = { ...entity, Pos: { type: "list", value: { type: "double", value: [...absolute] } } };
|
|
23856
|
+
return { position: absolute, nbt: { type: "compound", value } };
|
|
23857
|
+
});
|
|
23858
|
+
return { name, position, signedSize, size, blocks, entities, dataVersion };
|
|
23859
|
+
}
|
|
23860
|
+
function minimum(position, size) {
|
|
23861
|
+
return position + Math.min(0, size + 1);
|
|
23862
|
+
}
|
|
23863
|
+
function integer2(tag, name) {
|
|
23864
|
+
if (tag?.type !== "int" || !Number.isInteger(tag.value) || tag.value < -2147483648 || tag.value > 2147483647) {
|
|
23865
|
+
throw new MineRenderError(`Litematica ${name} must be an int`);
|
|
23866
|
+
}
|
|
23867
|
+
return tag.value;
|
|
23868
|
+
}
|
|
23869
|
+
function compound(tag, name) {
|
|
23870
|
+
if (tag?.type !== "compound" || !tag.value || typeof tag.value !== "object" || Array.isArray(tag.value)) {
|
|
23871
|
+
throw new MineRenderError(`Litematica ${name} must be a compound`);
|
|
23872
|
+
}
|
|
23873
|
+
return tag.value;
|
|
23874
|
+
}
|
|
23875
|
+
function blockPosition(tags) {
|
|
23876
|
+
return ["x", "y", "z"].map((axis) => integer2(tags[axis], axis));
|
|
23877
|
+
}
|
|
23878
|
+
function compounds(tag, name) {
|
|
23879
|
+
if (tag === void 0) return [];
|
|
23880
|
+
if (tag.type === "list" && Array.isArray(tag.value.value)) {
|
|
23881
|
+
if (tag.value.value.length === 0) return [];
|
|
23882
|
+
if (tag.value.type === "compound") return tag.value.value;
|
|
23883
|
+
}
|
|
23884
|
+
throw new MineRenderError(`Litematica ${name} must be a compound list`);
|
|
23885
|
+
}
|
|
23886
|
+
function blockState(tags) {
|
|
23887
|
+
const name = tags.Name;
|
|
23888
|
+
if (name?.type !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(name.value)) {
|
|
23889
|
+
throw new MineRenderError("Litematica palette entry must have a block Name");
|
|
23890
|
+
}
|
|
23891
|
+
const properties = {};
|
|
23892
|
+
if (tags.Properties !== void 0) {
|
|
23893
|
+
for (const [key, tag] of Object.entries(compound(tags.Properties, "block Properties"))) {
|
|
23894
|
+
if (tag?.type !== "string") throw new MineRenderError("Litematica block properties must be strings");
|
|
23895
|
+
Object.defineProperty(properties, key, { value: tag.value, enumerable: true, writable: true, configurable: true });
|
|
23896
|
+
}
|
|
23897
|
+
}
|
|
23898
|
+
return { type: name.value.includes(":") ? name.value : `minecraft:${name.value}`, properties };
|
|
23899
|
+
}
|
|
23900
|
+
|
|
23752
23901
|
// src/model/multiblock/SchematicParser.ts
|
|
23753
23902
|
init_MineRenderError();
|
|
23754
23903
|
|
|
@@ -25549,12 +25698,12 @@ var SpongeSchematicParser = class {
|
|
|
25549
25698
|
* Biomes and metadata are not imported, and DataVersion does not trigger migration.
|
|
25550
25699
|
*/
|
|
25551
25700
|
static async parse(nbt) {
|
|
25552
|
-
const tags = nbt.value.Schematic === void 0 ? nbt.value :
|
|
25553
|
-
const version2 =
|
|
25701
|
+
const tags = nbt.value.Schematic === void 0 ? nbt.value : compound2(nbt.value.Schematic, "Schematic");
|
|
25702
|
+
const version2 = integer3(tags.Version, "Version");
|
|
25554
25703
|
if (version2 !== 2 && version2 !== 3) {
|
|
25555
25704
|
throw new MineRenderError(`Unsupported Sponge schematic version ${version2}; expected 2 or 3`);
|
|
25556
25705
|
}
|
|
25557
|
-
const dataVersion =
|
|
25706
|
+
const dataVersion = integer3(tags.DataVersion, "DataVersion");
|
|
25558
25707
|
const size = ["Width", "Height", "Length"].map((name) => {
|
|
25559
25708
|
const tag = tags[name];
|
|
25560
25709
|
if (tag?.type !== "short" || !Number.isInteger(tag.value) || tag.value < -32768 || tag.value > 65535 || tag.value === 0) {
|
|
@@ -25564,19 +25713,19 @@ var SpongeSchematicParser = class {
|
|
|
25564
25713
|
});
|
|
25565
25714
|
const offset = tags.Offset === void 0 ? [0, 0, 0] : intPosition(tags.Offset, "Offset");
|
|
25566
25715
|
const blocks = [];
|
|
25567
|
-
const container = version2 === 2 ? tags : tags.Blocks === void 0 ? void 0 :
|
|
25716
|
+
const container = version2 === 2 ? tags : tags.Blocks === void 0 ? void 0 : compound2(tags.Blocks, "Blocks");
|
|
25568
25717
|
if (container) {
|
|
25569
25718
|
const paletteTag = container.Palette;
|
|
25570
25719
|
if (!paletteTag) throw new MineRenderError("Sponge schematic requires a local Palette; global block IDs are not supported");
|
|
25571
25720
|
const palette = /* @__PURE__ */ new Map();
|
|
25572
|
-
const paletteMax = version2 === 2 && tags.PaletteMax !== void 0 ?
|
|
25721
|
+
const paletteMax = version2 === 2 && tags.PaletteMax !== void 0 ? integer3(tags.PaletteMax, "PaletteMax") : void 0;
|
|
25573
25722
|
if (paletteMax !== void 0 && paletteMax <= 0) throw new MineRenderError("Sponge schematic PaletteMax must be positive");
|
|
25574
|
-
for (const [state, tag] of Object.entries(
|
|
25575
|
-
const id =
|
|
25723
|
+
for (const [state, tag] of Object.entries(compound2(paletteTag, "Palette"))) {
|
|
25724
|
+
const id = integer3(tag, "Palette index");
|
|
25576
25725
|
if (id < 0 || palette.has(id) || paletteMax !== void 0 && id >= paletteMax) {
|
|
25577
25726
|
throw new MineRenderError(`Invalid or duplicate Sponge schematic palette index ${id}`);
|
|
25578
25727
|
}
|
|
25579
|
-
palette.set(id,
|
|
25728
|
+
palette.set(id, blockState2(state));
|
|
25580
25729
|
}
|
|
25581
25730
|
const [width, height, length] = size;
|
|
25582
25731
|
const volume = width * height * length;
|
|
@@ -25642,13 +25791,13 @@ var SpongeSchematicParser = class {
|
|
|
25642
25791
|
return { size, blocks, entities, dataVersion };
|
|
25643
25792
|
}
|
|
25644
25793
|
};
|
|
25645
|
-
function
|
|
25794
|
+
function integer3(tag, name) {
|
|
25646
25795
|
if (tag?.type !== "int" || !Number.isInteger(tag.value) || tag.value < -2147483648 || tag.value > 2147483647) {
|
|
25647
25796
|
throw new MineRenderError(`Sponge schematic ${name} must be an int`);
|
|
25648
25797
|
}
|
|
25649
25798
|
return tag.value;
|
|
25650
25799
|
}
|
|
25651
|
-
function
|
|
25800
|
+
function compound2(tag, name) {
|
|
25652
25801
|
if (tag?.type !== "compound" || !tag.value || typeof tag.value !== "object" || Array.isArray(tag.value)) {
|
|
25653
25802
|
throw new MineRenderError(`Sponge schematic ${name} must be a compound`);
|
|
25654
25803
|
}
|
|
@@ -25669,7 +25818,7 @@ function compoundList2(tags, name) {
|
|
|
25669
25818
|
}
|
|
25670
25819
|
throw new MineRenderError(`Sponge schematic ${name} must be a compound list`);
|
|
25671
25820
|
}
|
|
25672
|
-
function
|
|
25821
|
+
function blockState2(state) {
|
|
25673
25822
|
const match = /^((?:[a-z0-9_.-]+:)?[a-z0-9_./-]+)(?:\[([^\[\]]*)\])?$/.exec(state);
|
|
25674
25823
|
if (!match) throw new MineRenderError(`Invalid Sponge schematic block state ${state}`);
|
|
25675
25824
|
const properties = {};
|
|
@@ -25686,7 +25835,7 @@ function entityData(entity, version2) {
|
|
|
25686
25835
|
const id = entity.Id;
|
|
25687
25836
|
if (id?.type !== "string" || !id.value) throw new MineRenderError("Sponge schematic entity Id must be a nonempty string");
|
|
25688
25837
|
const { Id, Pos, ...extra } = entity;
|
|
25689
|
-
const value = version2 === 2 ? extra : entity.Data === void 0 ? {} : { ...
|
|
25838
|
+
const value = version2 === 2 ? extra : entity.Data === void 0 ? {} : { ...compound2(entity.Data, "entity Data") };
|
|
25690
25839
|
value.id = { type: "string", value: id.value.includes(":") ? id.value : `minecraft:${id.value}` };
|
|
25691
25840
|
return value;
|
|
25692
25841
|
}
|
|
@@ -26915,8 +27064,8 @@ var _MineRenderScene = class _MineRenderScene extends Scene4 {
|
|
|
26915
27064
|
* Set `options.initialState` to choose block properties such as `facing` or `axis`.
|
|
26916
27065
|
* Use the returned object's `setPosition` method to move all of its model parts.
|
|
26917
27066
|
*/
|
|
26918
|
-
async addBlock(
|
|
26919
|
-
return this.addSceneObject(
|
|
27067
|
+
async addBlock(blockState3, options, parent = this) {
|
|
27068
|
+
return this.addSceneObject(blockState3, () => new BlockObject(blockState3, options), options, parent);
|
|
26920
27069
|
}
|
|
26921
27070
|
/**
|
|
26922
27071
|
* Loads a skin and adds an initialized player model.
|
|
@@ -28973,8 +29122,8 @@ async function abortable2(promise, signal) {
|
|
|
28973
29122
|
}
|
|
28974
29123
|
}
|
|
28975
29124
|
var AnvilWorldSource = class {
|
|
28976
|
-
constructor(
|
|
28977
|
-
this.readRegion =
|
|
29125
|
+
constructor(readRegion2, options = {}) {
|
|
29126
|
+
this.readRegion = readRegion2;
|
|
28978
29127
|
this.regions = /* @__PURE__ */ new Map();
|
|
28979
29128
|
this.pending = /* @__PURE__ */ new Map();
|
|
28980
29129
|
this.cachedBytes = 0;
|
|
@@ -29129,18 +29278,18 @@ var SectionModels = class {
|
|
|
29129
29278
|
if (!Number.isInteger(maxAtlasSize) || maxAtlasSize < 1) throw new RangeError("maxAtlasSize must be a positive integer");
|
|
29130
29279
|
}
|
|
29131
29280
|
/** Returns a cube template, or `undefined` when the block requires an individual render object. */
|
|
29132
|
-
async get(
|
|
29133
|
-
if (!
|
|
29134
|
-
let states = this.states.get(
|
|
29135
|
-
if (!states) this.states.set(
|
|
29281
|
+
async get(blockState3, properties = {}) {
|
|
29282
|
+
if (!blockState3.variants || blockState3.multipart) return void 0;
|
|
29283
|
+
let states = this.states.get(blockState3);
|
|
29284
|
+
if (!states) this.states.set(blockState3, states = /* @__PURE__ */ new Map());
|
|
29136
29285
|
const key = JSON.stringify(Object.entries(properties).sort(([a], [b]) => a.localeCompare(b)));
|
|
29137
|
-
const prepared = await cached(states, key, () => this.prepare(
|
|
29286
|
+
const prepared = await cached(states, key, () => this.prepare(blockState3, properties));
|
|
29138
29287
|
if (!prepared) return void 0;
|
|
29139
29288
|
return prepared.templates.get(BlockStateResolver.choose(prepared.variants));
|
|
29140
29289
|
}
|
|
29141
|
-
async prepare(
|
|
29142
|
-
const state = { ...await BlockStateResolver.defaults(
|
|
29143
|
-
const groups = BlockStateResolver.matching(
|
|
29290
|
+
async prepare(blockState3, properties) {
|
|
29291
|
+
const state = { ...await BlockStateResolver.defaults(blockState3), ...properties };
|
|
29292
|
+
const groups = BlockStateResolver.matching(blockState3, state);
|
|
29144
29293
|
if (groups.length !== 1) return void 0;
|
|
29145
29294
|
const variants = groups[0];
|
|
29146
29295
|
const choices = Array.isArray(variants) ? variants : [variants];
|
|
@@ -29152,7 +29301,7 @@ var SectionModels = class {
|
|
|
29152
29301
|
const atlas = await UVMapper.getAtlas(model);
|
|
29153
29302
|
const rotation = BlockStateResolver.rotation(variant);
|
|
29154
29303
|
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;
|
|
29155
|
-
const tints = await BlockTints.get(
|
|
29304
|
+
const tints = await BlockTints.get(blockState3.key, state, model);
|
|
29156
29305
|
let models = this.models.get(model);
|
|
29157
29306
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
29158
29307
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
@@ -29858,10 +30007,10 @@ var Chunk = class _Chunk {
|
|
|
29858
30007
|
if (resolutions.has(key)) continue;
|
|
29859
30008
|
const stored = { type: block.type, properties: block.properties ? { ...block.properties } : void 0 };
|
|
29860
30009
|
const resolved = (async () => {
|
|
29861
|
-
const
|
|
29862
|
-
const perBlock = !
|
|
29863
|
-
if (!perBlock) await this.sectionModels.get(
|
|
29864
|
-
return { blockState:
|
|
30010
|
+
const blockState3 = await BlockStates.get(AssetKey.parse("blockstates", stored.type));
|
|
30011
|
+
const perBlock = !blockState3 || !this.sectionModels || !!getFluidKind(blockState3.key, stored.properties) || !!(blockState3.key && BlockEntities.entry(await BlockEntities.getIndex(blockState3.key.root), blockState3.key.toNamespacedString()));
|
|
30012
|
+
if (!perBlock) await this.sectionModels.get(blockState3, stored.properties);
|
|
30013
|
+
return { blockState: blockState3, perBlock };
|
|
29865
30014
|
})();
|
|
29866
30015
|
resolutions.set(key, resolved);
|
|
29867
30016
|
void resolved.catch(() => void 0);
|
|
@@ -29886,17 +30035,17 @@ var Chunk = class _Chunk {
|
|
|
29886
30035
|
if (!readBlock) continue;
|
|
29887
30036
|
const stored = readBlock();
|
|
29888
30037
|
const key = ChunkData.paletteKey(stored);
|
|
29889
|
-
const { blockState:
|
|
29890
|
-
if (!
|
|
30038
|
+
const { blockState: blockState3, perBlock } = await resolutions.get(key);
|
|
30039
|
+
if (!blockState3) {
|
|
29891
30040
|
this.data.set(index, void 0);
|
|
29892
30041
|
continue;
|
|
29893
30042
|
}
|
|
29894
|
-
const template = perBlock ? void 0 : await this.sectionModels.get(
|
|
30043
|
+
const template = perBlock ? void 0 : await this.sectionModels.get(blockState3, stored.properties);
|
|
29895
30044
|
if (template) {
|
|
29896
30045
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
29897
30046
|
this.meshDirty = true;
|
|
29898
30047
|
} else {
|
|
29899
|
-
object3 = await this.scene.addBlock(
|
|
30048
|
+
object3 = await this.scene.addBlock(blockState3, {
|
|
29900
30049
|
mergeMeshes: true,
|
|
29901
30050
|
instanceMeshes: true,
|
|
29902
30051
|
maxInstanceCount: 2e3,
|
|
@@ -30263,6 +30412,7 @@ export {
|
|
|
30263
30412
|
InstanceManager,
|
|
30264
30413
|
InstanceReference,
|
|
30265
30414
|
ItemTints,
|
|
30415
|
+
LitematicaParser,
|
|
30266
30416
|
MapControls,
|
|
30267
30417
|
Materials,
|
|
30268
30418
|
Meshes,
|