UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

93 lines (92 loc) 3.44 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); const IBlockBaseTypeData_1 = require("./IBlockBaseTypeData"); class BlockBaseType { _name = ""; data; get icon() { return this.data.ic; } getProperty(name) { if (this.data.properties === undefined) { return undefined; } for (let i = 0; i < this.data.properties.length; i++) { if (this.data.properties[i].name === name) { return this.data.properties[i]; } } throw new Error(); } get isOpaque() { if (this.data.isOpaque !== undefined) { return this.data.isOpaque; } // Shapes that are inherently non-opaque (transparent, partial, or see-through) const nonOpaqueShapes = [ IBlockBaseTypeData_1.BlockShape.fence, IBlockBaseTypeData_1.BlockShape.fenceGate, IBlockBaseTypeData_1.BlockShape.door, IBlockBaseTypeData_1.BlockShape.trapdoor, IBlockBaseTypeData_1.BlockShape.button, IBlockBaseTypeData_1.BlockShape.pressurePlate, IBlockBaseTypeData_1.BlockShape.torch, IBlockBaseTypeData_1.BlockShape.lantern, IBlockBaseTypeData_1.BlockShape.chain, IBlockBaseTypeData_1.BlockShape.ladder, IBlockBaseTypeData_1.BlockShape.rail, IBlockBaseTypeData_1.BlockShape.lever, IBlockBaseTypeData_1.BlockShape.candle, IBlockBaseTypeData_1.BlockShape.endRod, IBlockBaseTypeData_1.BlockShape.glassPaneOrBars, IBlockBaseTypeData_1.BlockShape.billboard, IBlockBaseTypeData_1.BlockShape.carpet, IBlockBaseTypeData_1.BlockShape.crop, IBlockBaseTypeData_1.BlockShape.leaves, IBlockBaseTypeData_1.BlockShape.water, IBlockBaseTypeData_1.BlockShape.redstoneWire, IBlockBaseTypeData_1.BlockShape.sign, IBlockBaseTypeData_1.BlockShape.hangingSign, IBlockBaseTypeData_1.BlockShape.campfire, IBlockBaseTypeData_1.BlockShape.bell, IBlockBaseTypeData_1.BlockShape.hopper, IBlockBaseTypeData_1.BlockShape.brewingStand, IBlockBaseTypeData_1.BlockShape.enchantingTable, IBlockBaseTypeData_1.BlockShape.cauldron, IBlockBaseTypeData_1.BlockShape.dripleaf, ]; // Non-opaque shapes should not hide adjacent faces if (nonOpaqueShapes.includes(this.shape)) { return false; } // Default: solid blocks (custom, unitCube, stairs, slab, wall, anvil, bed, chest, etc.) // are opaque and correctly cull hidden faces between adjacent blocks return true; } get mapColor() { return this.data.mc; } get shape() { // Support both abbreviated (sh) and full (shape) property names const shapeValue = this.data.sh; if (shapeValue === undefined) { return IBlockBaseTypeData_1.BlockShape.custom; } return shapeValue; } get friendlyName() { return this.data.t; } get name() { return this._name; } constructor(name) { this._name = name; this.data = { n: name, }; } } exports.default = BlockBaseType;