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/bundle.js
CHANGED
|
@@ -21996,8 +21996,8 @@ var MineRender = (() => {
|
|
|
21996
21996
|
}
|
|
21997
21997
|
}
|
|
21998
21998
|
}
|
|
21999
|
-
function vertexAttribPointer(index, size, type, normalized, stride, offset,
|
|
22000
|
-
if (
|
|
21999
|
+
function vertexAttribPointer(index, size, type, normalized, stride, offset, integer4) {
|
|
22000
|
+
if (integer4 === true) {
|
|
22001
22001
|
gl.vertexAttribIPointer(index, size, type, stride, offset);
|
|
22002
22002
|
} else {
|
|
22003
22003
|
gl.vertexAttribPointer(index, size, type, normalized, stride, offset);
|
|
@@ -22024,7 +22024,7 @@ var MineRender = (() => {
|
|
|
22024
22024
|
const buffer2 = attribute.buffer;
|
|
22025
22025
|
const type = attribute.type;
|
|
22026
22026
|
const bytesPerElement = attribute.bytesPerElement;
|
|
22027
|
-
const
|
|
22027
|
+
const integer4 = type === gl.INT || type === gl.UNSIGNED_INT || geometryAttribute.gpuType === IntType;
|
|
22028
22028
|
if (geometryAttribute.isInterleavedBufferAttribute) {
|
|
22029
22029
|
const data = geometryAttribute.data;
|
|
22030
22030
|
const stride = data.stride;
|
|
@@ -22050,7 +22050,7 @@ var MineRender = (() => {
|
|
|
22050
22050
|
normalized,
|
|
22051
22051
|
stride * bytesPerElement,
|
|
22052
22052
|
(offset + size / programAttribute.locationSize * i4) * bytesPerElement,
|
|
22053
|
-
|
|
22053
|
+
integer4
|
|
22054
22054
|
);
|
|
22055
22055
|
}
|
|
22056
22056
|
} else {
|
|
@@ -22075,7 +22075,7 @@ var MineRender = (() => {
|
|
|
22075
22075
|
normalized,
|
|
22076
22076
|
size * bytesPerElement,
|
|
22077
22077
|
size / programAttribute.locationSize * i4 * bytesPerElement,
|
|
22078
|
-
|
|
22078
|
+
integer4
|
|
22079
22079
|
);
|
|
22080
22080
|
}
|
|
22081
22081
|
}
|
|
@@ -106553,6 +106553,7 @@ ${shader.fragmentShader}`.replace(
|
|
|
106553
106553
|
InstanceManager: () => InstanceManager,
|
|
106554
106554
|
InstanceReference: () => InstanceReference,
|
|
106555
106555
|
ItemTints: () => ItemTints,
|
|
106556
|
+
LitematicaParser: () => LitematicaParser,
|
|
106556
106557
|
MapControls: () => MapControls,
|
|
106557
106558
|
Materials: () => Materials,
|
|
106558
106559
|
Meshes: () => Meshes,
|
|
@@ -111368,46 +111369,46 @@ property list uchar int vertex_index
|
|
|
111368
111369
|
}
|
|
111369
111370
|
var BlockStateResolver = class {
|
|
111370
111371
|
/** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
|
|
111371
|
-
static async defaults(
|
|
111372
|
-
const defaults =
|
|
111372
|
+
static async defaults(blockState3) {
|
|
111373
|
+
const defaults = blockState3.key ? await BlockStates.getDefaultState(blockState3.key) : void 0;
|
|
111373
111374
|
const state = {};
|
|
111374
111375
|
if (defaults && Object.keys(defaults).length > 0) {
|
|
111375
111376
|
for (const key in defaults) state[key] = defaults[key].default;
|
|
111376
|
-
} else if (
|
|
111377
|
-
const variant = Object.keys(
|
|
111377
|
+
} else if (blockState3.variants) {
|
|
111378
|
+
const variant = Object.keys(blockState3.variants)[0];
|
|
111378
111379
|
if (variant) {
|
|
111379
111380
|
for (const property of variant.split(",")) {
|
|
111380
111381
|
const [key, value] = property.split("=");
|
|
111381
111382
|
state[key] = value;
|
|
111382
111383
|
}
|
|
111383
111384
|
}
|
|
111384
|
-
} else if (
|
|
111385
|
-
const condition =
|
|
111385
|
+
} else if (blockState3.multipart) {
|
|
111386
|
+
const condition = blockState3.multipart.map((part) => part.when).find((when) => when !== void 0 && Object.values(when).every((value) => typeof value === "string"));
|
|
111386
111387
|
for (const [key, value] of Object.entries(condition ?? {})) state[key] = value.split("|")[0];
|
|
111387
111388
|
}
|
|
111388
111389
|
return state;
|
|
111389
111390
|
}
|
|
111390
111391
|
/** Selects matching models. Supply `choose` to control selection within each alternatives array. */
|
|
111391
|
-
static select(
|
|
111392
|
-
return this.matching(
|
|
111392
|
+
static select(blockState3, state, choose = this.choose) {
|
|
111393
|
+
return this.matching(blockState3, state).map(choose);
|
|
111393
111394
|
}
|
|
111394
111395
|
/** Returns matching model groups before choosing weighted alternatives. */
|
|
111395
|
-
static matching(
|
|
111396
|
+
static matching(blockState3, state) {
|
|
111396
111397
|
const out = [];
|
|
111397
|
-
if (
|
|
111398
|
-
if (Object.keys(
|
|
111399
|
-
out.push(
|
|
111398
|
+
if (blockState3.variants) {
|
|
111399
|
+
if (Object.keys(blockState3.variants).length === 1 && "" in blockState3.variants) {
|
|
111400
|
+
out.push(blockState3.variants[""]);
|
|
111400
111401
|
} else {
|
|
111401
|
-
for (const variantKey in
|
|
111402
|
+
for (const variantKey in blockState3.variants) {
|
|
111402
111403
|
const matches = variantKey.split(",").every((property) => {
|
|
111403
111404
|
const [key, value] = property.split("=");
|
|
111404
111405
|
return `${state[key]}` === `${value}`;
|
|
111405
111406
|
});
|
|
111406
|
-
if (matches) out.push(
|
|
111407
|
+
if (matches) out.push(blockState3.variants[variantKey]);
|
|
111407
111408
|
}
|
|
111408
111409
|
}
|
|
111409
|
-
} else if (
|
|
111410
|
-
for (const part of
|
|
111410
|
+
} else if (blockState3.multipart) {
|
|
111411
|
+
for (const part of blockState3.multipart) {
|
|
111411
111412
|
if (part.apply && (!part.when || matchesCondition(part.when, state))) {
|
|
111412
111413
|
out.push(part.apply);
|
|
111413
111414
|
}
|
|
@@ -111546,9 +111547,9 @@ property list uchar int vertex_index
|
|
|
111546
111547
|
init_FluidGeometry();
|
|
111547
111548
|
init_Entities();
|
|
111548
111549
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
111549
|
-
constructor(
|
|
111550
|
+
constructor(blockState3, options) {
|
|
111550
111551
|
super(options);
|
|
111551
|
-
this.blockState =
|
|
111552
|
+
this.blockState = blockState3;
|
|
111552
111553
|
this.isBlockObject = true;
|
|
111553
111554
|
this._previousState = {};
|
|
111554
111555
|
this._state = {};
|
|
@@ -111944,6 +111945,158 @@ property list uchar int vertex_index
|
|
|
111944
111945
|
init_buffer2();
|
|
111945
111946
|
init_process2();
|
|
111946
111947
|
|
|
111948
|
+
// src/model/multiblock/LitematicaParser.ts
|
|
111949
|
+
init_dirname();
|
|
111950
|
+
init_buffer2();
|
|
111951
|
+
init_process2();
|
|
111952
|
+
init_MineRenderError();
|
|
111953
|
+
var LitematicaParser = class {
|
|
111954
|
+
/**
|
|
111955
|
+
* Parses decoded NBT, preserving subregion placement and omitting air.
|
|
111956
|
+
* Later entries in regions replace earlier cells, including with air.
|
|
111957
|
+
* Size encloses all region bounds; positions retain the schematic origin.
|
|
111958
|
+
* Metadata and scheduled ticks are not imported. Named regions can be placed individually.
|
|
111959
|
+
*/
|
|
111960
|
+
static async parse(nbt) {
|
|
111961
|
+
const tags = nbt.value;
|
|
111962
|
+
const version3 = integer2(tags.Version, "Version");
|
|
111963
|
+
if (version3 < 5 || version3 > 7) throw new MineRenderError(`Unsupported Litematica version ${version3}; expected 5, 6, or 7`);
|
|
111964
|
+
const dataVersion = tags.MinecraftDataVersion === void 0 ? void 0 : integer2(tags.MinecraftDataVersion, "MinecraftDataVersion");
|
|
111965
|
+
const blocks = /* @__PURE__ */ new Map();
|
|
111966
|
+
const regions = [];
|
|
111967
|
+
const min = [Infinity, Infinity, Infinity];
|
|
111968
|
+
const max2 = [-Infinity, -Infinity, -Infinity];
|
|
111969
|
+
for (const [name2, tag] of Object.entries(compound(tags.Regions, "Regions"))) {
|
|
111970
|
+
const region = readRegion(compound(tag, `region ${name2}`), name2, dataVersion, blocks);
|
|
111971
|
+
regions.push(region);
|
|
111972
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
111973
|
+
const start = minimum(region.position[axis], region.signedSize[axis]);
|
|
111974
|
+
min[axis] = Math.min(min[axis], start);
|
|
111975
|
+
max2[axis] = Math.max(max2[axis], start + region.size[axis]);
|
|
111976
|
+
}
|
|
111977
|
+
}
|
|
111978
|
+
return {
|
|
111979
|
+
size: regions.length ? min.map((value, axis) => max2[axis] - value) : [0, 0, 0],
|
|
111980
|
+
blocks: [...blocks.values()],
|
|
111981
|
+
entities: regions.flatMap((region) => region.entities ?? []),
|
|
111982
|
+
dataVersion,
|
|
111983
|
+
regions
|
|
111984
|
+
};
|
|
111985
|
+
}
|
|
111986
|
+
};
|
|
111987
|
+
function readRegion(tags, name2, dataVersion, combined) {
|
|
111988
|
+
const position = blockPosition(compound(tags.Position, `region ${name2} Position`));
|
|
111989
|
+
const signedSize = blockPosition(compound(tags.Size, `region ${name2} Size`));
|
|
111990
|
+
if (signedSize.some((value) => value === 0)) throw new MineRenderError(`Litematica region ${name2} dimensions must be nonzero`);
|
|
111991
|
+
const size = signedSize.map(Math.abs);
|
|
111992
|
+
const min = position.map((value, axis) => minimum(value, signedSize[axis]));
|
|
111993
|
+
const [width, height, length] = size;
|
|
111994
|
+
const volume = width * height * length;
|
|
111995
|
+
const palette = compounds(tags.BlockStatePalette, "BlockStatePalette").map(blockState);
|
|
111996
|
+
if (!palette.length) throw new MineRenderError(`Litematica region ${name2} has no block palette`);
|
|
111997
|
+
const bits2 = Math.max(2, Math.ceil(Math.log2(palette.length)));
|
|
111998
|
+
if (!Number.isSafeInteger(volume * bits2)) throw new MineRenderError(`Litematica region ${name2} volume is too large`);
|
|
111999
|
+
const packed = tags.BlockStates;
|
|
112000
|
+
const expected = Math.ceil(volume * bits2 / 64);
|
|
112001
|
+
if (packed?.type !== "longArray" || !Array.isArray(packed.value) || packed.value.length !== expected) {
|
|
112002
|
+
throw new MineRenderError(`Litematica region ${name2} BlockStates must contain ${expected} longs`);
|
|
112003
|
+
}
|
|
112004
|
+
const words = packed.value.map((pair) => {
|
|
112005
|
+
if (!Array.isArray(pair) || pair.length !== 2 || !pair.every((value) => Number.isInteger(value) && value >= -2147483648 && value <= 4294967295)) {
|
|
112006
|
+
throw new MineRenderError(`Litematica region ${name2} has an invalid BlockStates long`);
|
|
112007
|
+
}
|
|
112008
|
+
return [pair[0] >>> 0, pair[1] >>> 0];
|
|
112009
|
+
});
|
|
112010
|
+
const blockEntities = /* @__PURE__ */ new Map();
|
|
112011
|
+
for (const tile of compounds(tags.TileEntities, "TileEntities")) {
|
|
112012
|
+
const pos = blockPosition(tile);
|
|
112013
|
+
if (pos.some((value2, axis) => value2 < 0 || value2 >= size[axis])) {
|
|
112014
|
+
throw new MineRenderError(`Litematica region ${name2} block entity is outside its dimensions`);
|
|
112015
|
+
}
|
|
112016
|
+
const index = pos[0] + pos[2] * width + pos[1] * width * length;
|
|
112017
|
+
if (blockEntities.has(index)) throw new MineRenderError(`Duplicate Litematica block entity at index ${index}`);
|
|
112018
|
+
const value = { ...tile };
|
|
112019
|
+
for (const [axis, key] of ["x", "y", "z"].entries()) value[key] = { type: "int", value: pos[axis] + min[axis] };
|
|
112020
|
+
blockEntities.set(index, { type: "compound", value });
|
|
112021
|
+
}
|
|
112022
|
+
const blocks = [];
|
|
112023
|
+
const mask = 2 ** bits2 - 1;
|
|
112024
|
+
for (let index = 0; index < volume; index++) {
|
|
112025
|
+
const word = Math.floor(index * bits2 / 64);
|
|
112026
|
+
const shift = index * bits2 % 64;
|
|
112027
|
+
const [high, low] = words[word];
|
|
112028
|
+
let value = shift < 32 ? low >>> shift : high >>> shift - 32;
|
|
112029
|
+
if (shift < 32 && shift + bits2 > 32) value |= high << 32 - shift;
|
|
112030
|
+
if (shift + bits2 > 64) value |= words[word + 1][1] << 64 - shift;
|
|
112031
|
+
const id = (value & mask) >>> 0;
|
|
112032
|
+
const state = palette[id];
|
|
112033
|
+
if (!state) throw new MineRenderError(`Litematica region ${name2} palette index ${id} does not exist`);
|
|
112034
|
+
const pos = [
|
|
112035
|
+
index % width + min[0],
|
|
112036
|
+
Math.floor(index / (width * length)) + min[1],
|
|
112037
|
+
Math.floor(index / width) % length + min[2]
|
|
112038
|
+
];
|
|
112039
|
+
const key = pos.join(",");
|
|
112040
|
+
if (["minecraft:air", "minecraft:cave_air", "minecraft:void_air"].includes(state.type)) {
|
|
112041
|
+
combined.delete(key);
|
|
112042
|
+
continue;
|
|
112043
|
+
}
|
|
112044
|
+
const block = { type: state.type, properties: { ...state.properties }, position: pos, nbt: blockEntities.get(index) };
|
|
112045
|
+
blocks.push(block);
|
|
112046
|
+
combined.set(key, block);
|
|
112047
|
+
}
|
|
112048
|
+
const entities = compounds(tags.Entities, "Entities").map((entity) => {
|
|
112049
|
+
const pos = entity.Pos;
|
|
112050
|
+
if (pos?.type !== "list" || pos.value.type !== "double" || pos.value.value.length !== 3 || !pos.value.value.every(Number.isFinite)) {
|
|
112051
|
+
throw new MineRenderError(`Litematica region ${name2} entity Pos must contain three doubles`);
|
|
112052
|
+
}
|
|
112053
|
+
const absolute = pos.value.value.map((value2, axis) => value2 + position[axis]);
|
|
112054
|
+
const value = { ...entity, Pos: { type: "list", value: { type: "double", value: [...absolute] } } };
|
|
112055
|
+
return { position: absolute, nbt: { type: "compound", value } };
|
|
112056
|
+
});
|
|
112057
|
+
return { name: name2, position, signedSize, size, blocks, entities, dataVersion };
|
|
112058
|
+
}
|
|
112059
|
+
function minimum(position, size) {
|
|
112060
|
+
return position + Math.min(0, size + 1);
|
|
112061
|
+
}
|
|
112062
|
+
function integer2(tag, name2) {
|
|
112063
|
+
if (tag?.type !== "int" || !Number.isInteger(tag.value) || tag.value < -2147483648 || tag.value > 2147483647) {
|
|
112064
|
+
throw new MineRenderError(`Litematica ${name2} must be an int`);
|
|
112065
|
+
}
|
|
112066
|
+
return tag.value;
|
|
112067
|
+
}
|
|
112068
|
+
function compound(tag, name2) {
|
|
112069
|
+
if (tag?.type !== "compound" || !tag.value || typeof tag.value !== "object" || Array.isArray(tag.value)) {
|
|
112070
|
+
throw new MineRenderError(`Litematica ${name2} must be a compound`);
|
|
112071
|
+
}
|
|
112072
|
+
return tag.value;
|
|
112073
|
+
}
|
|
112074
|
+
function blockPosition(tags) {
|
|
112075
|
+
return ["x", "y", "z"].map((axis) => integer2(tags[axis], axis));
|
|
112076
|
+
}
|
|
112077
|
+
function compounds(tag, name2) {
|
|
112078
|
+
if (tag === void 0) return [];
|
|
112079
|
+
if (tag.type === "list" && Array.isArray(tag.value.value)) {
|
|
112080
|
+
if (tag.value.value.length === 0) return [];
|
|
112081
|
+
if (tag.value.type === "compound") return tag.value.value;
|
|
112082
|
+
}
|
|
112083
|
+
throw new MineRenderError(`Litematica ${name2} must be a compound list`);
|
|
112084
|
+
}
|
|
112085
|
+
function blockState(tags) {
|
|
112086
|
+
const name2 = tags.Name;
|
|
112087
|
+
if (name2?.type !== "string" || !/^(?:[a-z0-9_.-]+:)?[a-z0-9_./-]+$/.test(name2.value)) {
|
|
112088
|
+
throw new MineRenderError("Litematica palette entry must have a block Name");
|
|
112089
|
+
}
|
|
112090
|
+
const properties = {};
|
|
112091
|
+
if (tags.Properties !== void 0) {
|
|
112092
|
+
for (const [key, tag] of Object.entries(compound(tags.Properties, "block Properties"))) {
|
|
112093
|
+
if (tag?.type !== "string") throw new MineRenderError("Litematica block properties must be strings");
|
|
112094
|
+
Object.defineProperty(properties, key, { value: tag.value, enumerable: true, writable: true, configurable: true });
|
|
112095
|
+
}
|
|
112096
|
+
}
|
|
112097
|
+
return { type: name2.value.includes(":") ? name2.value : `minecraft:${name2.value}`, properties };
|
|
112098
|
+
}
|
|
112099
|
+
|
|
111947
112100
|
// src/model/multiblock/MultiBlockStructure.ts
|
|
111948
112101
|
init_dirname();
|
|
111949
112102
|
init_buffer2();
|
|
@@ -113755,12 +113908,12 @@ property list uchar int vertex_index
|
|
|
113755
113908
|
* Biomes and metadata are not imported, and DataVersion does not trigger migration.
|
|
113756
113909
|
*/
|
|
113757
113910
|
static async parse(nbt) {
|
|
113758
|
-
const tags = nbt.value.Schematic === void 0 ? nbt.value :
|
|
113759
|
-
const version3 =
|
|
113911
|
+
const tags = nbt.value.Schematic === void 0 ? nbt.value : compound2(nbt.value.Schematic, "Schematic");
|
|
113912
|
+
const version3 = integer3(tags.Version, "Version");
|
|
113760
113913
|
if (version3 !== 2 && version3 !== 3) {
|
|
113761
113914
|
throw new MineRenderError(`Unsupported Sponge schematic version ${version3}; expected 2 or 3`);
|
|
113762
113915
|
}
|
|
113763
|
-
const dataVersion =
|
|
113916
|
+
const dataVersion = integer3(tags.DataVersion, "DataVersion");
|
|
113764
113917
|
const size = ["Width", "Height", "Length"].map((name2) => {
|
|
113765
113918
|
const tag = tags[name2];
|
|
113766
113919
|
if (tag?.type !== "short" || !Number.isInteger(tag.value) || tag.value < -32768 || tag.value > 65535 || tag.value === 0) {
|
|
@@ -113770,19 +113923,19 @@ property list uchar int vertex_index
|
|
|
113770
113923
|
});
|
|
113771
113924
|
const offset = tags.Offset === void 0 ? [0, 0, 0] : intPosition(tags.Offset, "Offset");
|
|
113772
113925
|
const blocks = [];
|
|
113773
|
-
const container = version3 === 2 ? tags : tags.Blocks === void 0 ? void 0 :
|
|
113926
|
+
const container = version3 === 2 ? tags : tags.Blocks === void 0 ? void 0 : compound2(tags.Blocks, "Blocks");
|
|
113774
113927
|
if (container) {
|
|
113775
113928
|
const paletteTag = container.Palette;
|
|
113776
113929
|
if (!paletteTag) throw new MineRenderError("Sponge schematic requires a local Palette; global block IDs are not supported");
|
|
113777
113930
|
const palette = /* @__PURE__ */ new Map();
|
|
113778
|
-
const paletteMax = version3 === 2 && tags.PaletteMax !== void 0 ?
|
|
113931
|
+
const paletteMax = version3 === 2 && tags.PaletteMax !== void 0 ? integer3(tags.PaletteMax, "PaletteMax") : void 0;
|
|
113779
113932
|
if (paletteMax !== void 0 && paletteMax <= 0) throw new MineRenderError("Sponge schematic PaletteMax must be positive");
|
|
113780
|
-
for (const [state, tag] of Object.entries(
|
|
113781
|
-
const id =
|
|
113933
|
+
for (const [state, tag] of Object.entries(compound2(paletteTag, "Palette"))) {
|
|
113934
|
+
const id = integer3(tag, "Palette index");
|
|
113782
113935
|
if (id < 0 || palette.has(id) || paletteMax !== void 0 && id >= paletteMax) {
|
|
113783
113936
|
throw new MineRenderError(`Invalid or duplicate Sponge schematic palette index ${id}`);
|
|
113784
113937
|
}
|
|
113785
|
-
palette.set(id,
|
|
113938
|
+
palette.set(id, blockState2(state));
|
|
113786
113939
|
}
|
|
113787
113940
|
const [width, height, length] = size;
|
|
113788
113941
|
const volume = width * height * length;
|
|
@@ -113848,13 +114001,13 @@ property list uchar int vertex_index
|
|
|
113848
114001
|
return { size, blocks, entities, dataVersion };
|
|
113849
114002
|
}
|
|
113850
114003
|
};
|
|
113851
|
-
function
|
|
114004
|
+
function integer3(tag, name2) {
|
|
113852
114005
|
if (tag?.type !== "int" || !Number.isInteger(tag.value) || tag.value < -2147483648 || tag.value > 2147483647) {
|
|
113853
114006
|
throw new MineRenderError(`Sponge schematic ${name2} must be an int`);
|
|
113854
114007
|
}
|
|
113855
114008
|
return tag.value;
|
|
113856
114009
|
}
|
|
113857
|
-
function
|
|
114010
|
+
function compound2(tag, name2) {
|
|
113858
114011
|
if (tag?.type !== "compound" || !tag.value || typeof tag.value !== "object" || Array.isArray(tag.value)) {
|
|
113859
114012
|
throw new MineRenderError(`Sponge schematic ${name2} must be a compound`);
|
|
113860
114013
|
}
|
|
@@ -113875,7 +114028,7 @@ property list uchar int vertex_index
|
|
|
113875
114028
|
}
|
|
113876
114029
|
throw new MineRenderError(`Sponge schematic ${name2} must be a compound list`);
|
|
113877
114030
|
}
|
|
113878
|
-
function
|
|
114031
|
+
function blockState2(state) {
|
|
113879
114032
|
const match = /^((?:[a-z0-9_.-]+:)?[a-z0-9_./-]+)(?:\[([^\[\]]*)\])?$/.exec(state);
|
|
113880
114033
|
if (!match) throw new MineRenderError(`Invalid Sponge schematic block state ${state}`);
|
|
113881
114034
|
const properties = {};
|
|
@@ -113892,7 +114045,7 @@ property list uchar int vertex_index
|
|
|
113892
114045
|
const id = entity.Id;
|
|
113893
114046
|
if (id?.type !== "string" || !id.value) throw new MineRenderError("Sponge schematic entity Id must be a nonempty string");
|
|
113894
114047
|
const { Id, Pos, ...extra } = entity;
|
|
113895
|
-
const value = version3 === 2 ? extra : entity.Data === void 0 ? {} : { ...
|
|
114048
|
+
const value = version3 === 2 ? extra : entity.Data === void 0 ? {} : { ...compound2(entity.Data, "entity Data") };
|
|
113896
114049
|
value.id = { type: "string", value: id.value.includes(":") ? id.value : `minecraft:${id.value}` };
|
|
113897
114050
|
return value;
|
|
113898
114051
|
}
|
|
@@ -115156,8 +115309,8 @@ property list uchar int vertex_index
|
|
|
115156
115309
|
* Set `options.initialState` to choose block properties such as `facing` or `axis`.
|
|
115157
115310
|
* Use the returned object's `setPosition` method to move all of its model parts.
|
|
115158
115311
|
*/
|
|
115159
|
-
async addBlock(
|
|
115160
|
-
return this.addSceneObject(
|
|
115312
|
+
async addBlock(blockState3, options, parent = this) {
|
|
115313
|
+
return this.addSceneObject(blockState3, () => new BlockObject(blockState3, options), options, parent);
|
|
115161
115314
|
}
|
|
115162
115315
|
/**
|
|
115163
115316
|
* Loads a skin and adds an initialized player model.
|
|
@@ -119240,8 +119393,8 @@ gl_FragDepth=readDepth(vUv);
|
|
|
119240
119393
|
}
|
|
119241
119394
|
}
|
|
119242
119395
|
var AnvilWorldSource = class {
|
|
119243
|
-
constructor(
|
|
119244
|
-
this.readRegion =
|
|
119396
|
+
constructor(readRegion2, options = {}) {
|
|
119397
|
+
this.readRegion = readRegion2;
|
|
119245
119398
|
this.regions = /* @__PURE__ */ new Map();
|
|
119246
119399
|
this.pending = /* @__PURE__ */ new Map();
|
|
119247
119400
|
this.cachedBytes = 0;
|
|
@@ -119410,18 +119563,18 @@ gl_FragDepth=readDepth(vUv);
|
|
|
119410
119563
|
if (!Number.isInteger(maxAtlasSize) || maxAtlasSize < 1) throw new RangeError("maxAtlasSize must be a positive integer");
|
|
119411
119564
|
}
|
|
119412
119565
|
/** Returns a cube template, or `undefined` when the block requires an individual render object. */
|
|
119413
|
-
async get(
|
|
119414
|
-
if (!
|
|
119415
|
-
let states = this.states.get(
|
|
119416
|
-
if (!states) this.states.set(
|
|
119566
|
+
async get(blockState3, properties = {}) {
|
|
119567
|
+
if (!blockState3.variants || blockState3.multipart) return void 0;
|
|
119568
|
+
let states = this.states.get(blockState3);
|
|
119569
|
+
if (!states) this.states.set(blockState3, states = /* @__PURE__ */ new Map());
|
|
119417
119570
|
const key = JSON.stringify(Object.entries(properties).sort(([a4], [b4]) => a4.localeCompare(b4)));
|
|
119418
|
-
const prepared = await cached(states, key, () => this.prepare(
|
|
119571
|
+
const prepared = await cached(states, key, () => this.prepare(blockState3, properties));
|
|
119419
119572
|
if (!prepared) return void 0;
|
|
119420
119573
|
return prepared.templates.get(BlockStateResolver.choose(prepared.variants));
|
|
119421
119574
|
}
|
|
119422
|
-
async prepare(
|
|
119423
|
-
const state = { ...await BlockStateResolver.defaults(
|
|
119424
|
-
const groups = BlockStateResolver.matching(
|
|
119575
|
+
async prepare(blockState3, properties) {
|
|
119576
|
+
const state = { ...await BlockStateResolver.defaults(blockState3), ...properties };
|
|
119577
|
+
const groups = BlockStateResolver.matching(blockState3, state);
|
|
119425
119578
|
if (groups.length !== 1) return void 0;
|
|
119426
119579
|
const variants = groups[0];
|
|
119427
119580
|
const choices = Array.isArray(variants) ? variants : [variants];
|
|
@@ -119433,7 +119586,7 @@ gl_FragDepth=readDepth(vUv);
|
|
|
119433
119586
|
const atlas = await UVMapper.getAtlas(model);
|
|
119434
119587
|
const rotation = BlockStateResolver.rotation(variant);
|
|
119435
119588
|
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;
|
|
119436
|
-
const tints = await BlockTints.get(
|
|
119589
|
+
const tints = await BlockTints.get(blockState3.key, state, model);
|
|
119437
119590
|
let models = this.models.get(model);
|
|
119438
119591
|
if (!models) this.models.set(model, models = /* @__PURE__ */ new Map());
|
|
119439
119592
|
const key = JSON.stringify([rotation.x, rotation.y, rotation.z, variant.uvlock, tints]);
|
|
@@ -120148,10 +120301,10 @@ gl_FragDepth=readDepth(vUv);
|
|
|
120148
120301
|
if (resolutions.has(key)) continue;
|
|
120149
120302
|
const stored = { type: block.type, properties: block.properties ? { ...block.properties } : void 0 };
|
|
120150
120303
|
const resolved = (async () => {
|
|
120151
|
-
const
|
|
120152
|
-
const perBlock = !
|
|
120153
|
-
if (!perBlock) await this.sectionModels.get(
|
|
120154
|
-
return { blockState:
|
|
120304
|
+
const blockState3 = await BlockStates.get(AssetKey.parse("blockstates", stored.type));
|
|
120305
|
+
const perBlock = !blockState3 || !this.sectionModels || !!getFluidKind(blockState3.key, stored.properties) || !!(blockState3.key && BlockEntities.entry(await BlockEntities.getIndex(blockState3.key.root), blockState3.key.toNamespacedString()));
|
|
120306
|
+
if (!perBlock) await this.sectionModels.get(blockState3, stored.properties);
|
|
120307
|
+
return { blockState: blockState3, perBlock };
|
|
120155
120308
|
})();
|
|
120156
120309
|
resolutions.set(key, resolved);
|
|
120157
120310
|
void resolved.catch(() => void 0);
|
|
@@ -120176,17 +120329,17 @@ gl_FragDepth=readDepth(vUv);
|
|
|
120176
120329
|
if (!readBlock) continue;
|
|
120177
120330
|
const stored = readBlock();
|
|
120178
120331
|
const key = ChunkData.paletteKey(stored);
|
|
120179
|
-
const { blockState:
|
|
120180
|
-
if (!
|
|
120332
|
+
const { blockState: blockState3, perBlock } = await resolutions.get(key);
|
|
120333
|
+
if (!blockState3) {
|
|
120181
120334
|
this.data.set(index, void 0);
|
|
120182
120335
|
continue;
|
|
120183
120336
|
}
|
|
120184
|
-
const template = perBlock ? void 0 : await this.sectionModels.get(
|
|
120337
|
+
const template = perBlock ? void 0 : await this.sectionModels.get(blockState3, stored.properties);
|
|
120185
120338
|
if (template) {
|
|
120186
120339
|
this.sectionBlocks.set(index, { index, template, cullMask: 0 });
|
|
120187
120340
|
this.meshDirty = true;
|
|
120188
120341
|
} else {
|
|
120189
|
-
object3 = await this.scene.addBlock(
|
|
120342
|
+
object3 = await this.scene.addBlock(blockState3, {
|
|
120190
120343
|
mergeMeshes: true,
|
|
120191
120344
|
instanceMeshes: true,
|
|
120192
120345
|
maxInstanceCount: 2e3,
|