@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
94 lines (93 loc) • 3.12 kB
JavaScript
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.SlabBlockTrait = void 0;
const ContentTraits_1 = require("./ContentTraits");
/**
* Slab geometry definition.
* A single half-height cube (16×8×16 in pixel units).
*/
const SLAB_GEOMETRY = {
format_version: "1.21.40",
"minecraft:geometry": [
{
description: {
identifier: "geometry.slab",
texture_width: 16,
texture_height: 16,
},
bones: [
{
name: "body",
pivot: [0, 0, 0],
cubes: [
{
origin: [-8, 0, -8],
size: [16, 8, 16],
uv: {
north: { uv: [0, 8], uv_size: [16, 8] },
south: { uv: [0, 8], uv_size: [16, 8] },
east: { uv: [0, 8], uv_size: [16, 8] },
west: { uv: [0, 8], uv_size: [16, 8] },
up: { uv: [0, 0], uv_size: [16, 16] },
down: { uv: [0, 0], uv_size: [16, 16] },
},
},
],
},
],
},
],
};
/**
* Slab - half-height block.
* Uses the minecraft:placement_position trait with minecraft:vertical_half
* to automatically handle top/bottom placement based on where the player clicks.
*/
class SlabBlockTrait extends ContentTraits_1.BlockContentTrait {
get id() {
return "slab";
}
getData(_config) {
return {
id: "slab",
displayName: "Slab",
description: "Half-height block with top/bottom placement",
category: "placement",
components: {
"minecraft:geometry": "geometry.slab",
"minecraft:collision_box": {
origin: [-8, 0, -8],
size: [16, 8, 16],
},
"minecraft:selection_box": {
origin: [-8, 0, -8],
size: [16, 8, 16],
},
},
minecraftTraits: {
"minecraft:placement_position": {
enabled_states: ["minecraft:vertical_half"],
},
},
geometryFiles: [
{
path: "models/blocks/slab.geo.json",
content: SLAB_GEOMETRY,
},
],
permutations: [
{
condition: "q.block_state('minecraft:vertical_half') == 'top'",
components: {
"minecraft:transformation": {
translation: [0, 0.5, 0],
},
},
},
],
};
}
}
exports.SlabBlockTrait = SlabBlockTrait;