手册:minecraft:block

来自Minecraft基岩版开发Wiki
模式 方块 > minecraft:block
minecraft:block
模式
所属域
1.19.70
  • 1.19.40
  • 0.0.0
加入版本
?

minecraft:block用于定义方块。

模式[编辑]

基础模式
block:
object "minecraft:block"
{
    block_description "description"
    block_permutations "permutations" : opt
    block_components "components" : opt
    block_events "events" : opt
}
描述
block_description:
object
{
    string "identifier"
    object "menu_category" : opt
    {
        enumerated_value "category"<"construction", "nature", "equipment", "items", "none", "custom"> : opt // “custom”仅中国版支持
        string "group" : opt
        bool "is_hidden_in_commands" : opt
    }
    object "properties" : opt
    {
        array "<block state name>"<1,16>
        {
            int "<any array element>"
            string "<any array element>"
            bool "<any array element>"
        }
        object "<block state name>"
        {
            array "values"<1,16>
            {
                int "<any array element>"
                string "<any array element>"
                bool "<any array element>"
            }
            object "values"
            {
                int "min" : opt
                int "max" : opt
            }
        }
    }
    bool "register_to_creative_menu" : opt // 仅中国版支持
    enumerated_value "material_type"<"air", "dirt", "wood", "stone", "metal", "water", "lava", "leaves", "plant", "replaceable_plant", "sponge", "cloth", "bed", "fire", "sand", "decoration", "glass", "explosive", "ice", "packed_ice", "top_snow", "snow", "cactus", "clay", "vegetable", "portal", "cake", "web", "redstone_wire", "carpet", "buildable_glass", "slime", "piston", "allow", "deny", "nether_wart", "stone_decoration", "bubble", "egg", "barrier", "decoration_flammable", "surface_type_total"> : opt // 仅中国版支持
    enumerated_value "base_block"<"mob_spawner", "portal", "custom_crop_block", "custom_heavy_block", "liquid", "flowing_liquid"> : opt // 仅中国版支持
    string "category" : opt // 仅中国版支持
    string "micro_size" : opt // 仅中国版支持
}
置换
block_permutations:
array
{
    object "<any array element>"
    {
        molang "condition"
        block_components "components"
    }
}
组件
block_components:
object
{
    some_component "<any block component>" : opt
}
事件
block_events:
object
{
    definition_event "<event name>" : opt
}
事件定义
definition_event:
object
{
    float "weight" : opt
    molang "condition" : opt
    array "randomize"
    {
        definition_event "<any array element>"
    }
    array "sequence"
    {
        definition_event "<any array element>"
    }
    definition_trigger "trigger" : opt
    event_response "<any event responce>" : opt
}
触发器定义
definition_trigger:
string // 在特定情况下引擎逻辑将允许直接传入一个事件名,比如定义事件中便允许传入
object
{
    string "event"
    enumerated_value "target"<"self", "other", "player", "target", "parent", "baby", "block", "damager", "holder", "item">
}

升级[编辑]

描述

1.19.40--/-->1.19.70:无升级

  • properties字段所定义的内容发挥功能不再需要实验性玩法
置换

1.19.60--/-->1.19.70:无升级

  • 整个字段被加载不再需要实验性玩法。
  • 整个字段所定义的内容发挥功能不再需要实验性玩法。
  • <any array element>/condition将只支持字符串类型的Molang表达式。

结构[编辑]

  • *minecraft:block:方块模式标识符。
    • *description:描述。
      • *identifier:设置方块的赋命名空间标识符
      •  menu_category:设置创造模式物品栏分类与分组。
        •  category:设置分类。可填constructionnatureequipmentitemsnonecustom,默认值为none
        •  group:设置分组,默认无分组。
        •  is_hidden_in_commands:设置方块是否在命令中隐藏。默认值为false
      •  properties:设置方块状态。
        •  <block_state_name>:设置一个方块状态,键名为状态名。数组内元素可以是整数、字符串或布尔值,最多包含16个元素。
        • ……
      •  register_to_creative_menu‌ ‌[仅中国版]:设置是否将方块注册到创造模式物品栏中。
      •  material_type‌ ‌[仅中国版]:设置方块材料类型。可填airdirtwoodstonemetalwaterlavaleavesplantreplaceable_plantspongeclothbedfiresanddecorationglassexplosiveicepacked_icetop_snowsnowcactusclayvegetableportalcakewebredstone_wirecarpetbuildable_glassslimepistonallowdenynether_wartstone_decorationbubbleeggbarrierdecoration_flammablesurface_type_total
      •  base_block‌ ‌[仅中国版]:设置方块的基方块,可填mob_spawnerportalcustom_crop_blockcustom_heavy_blockliquidflowing_liquid
      •  category‌ ‌[仅中国版]:设置中国版创造模式物品栏分类。
      •  micro_size‌ ‌[仅中国版]:设置微缩方块的尺寸,格式为<x> <y> <z>,默认值为1 1 1
    •  permutations:置换。
      •  <index>:一个方块置换。
        • *condition:置换条件。仅支持字符串形式的Molang表达式,其中查询函数仅支持使用query.block_property
        • *components:当条件成立时方块额外具有的组件。
          •  <component_name>:一个方块组件。
          • ……
    •  components:组件与标签。
      •  <component_name>:一个方块组件。
      • ……
    •  events:事件。

示例[编辑]

{
  "format_version": "1.19.70",
  "minecraft:block": {
    "description": {
      "identifier": "example:test",
      "menu_category": {
        "category": "construction",
        "group": "itemGroup.name.wool",
        "is_hidden_in_commands": false
      },
      "properties": {
        "example:int": [ 0, 1, 2 ],
        "example:string": [ "red", "green", "blue" ],
        "example:bool": [ false, true ]
      }
    },
    "permutations": [
      {
        "condition": "query.block_property('example:bool') == false",
        "components": {
          "minecraft:light_emission": 0
        }
      },
      {
        "condition": "query.block_property('example:bool') == true",
        "components": {
          "minecraft:light_emission": 15
        }
      }
    ],
    "components": {
      "minecraft:unit_cube": {},
      "minecraft:on_interact": {
        "event": "example:event"
      }
    },
    "events": {
      "example:event": {
        "run_command": "say HelloWorld"
      }
    }
  }
}

历史[编辑]

基岩版
??加入了minecraft:block
1.15.0?移除了register_to_creative_menu字段。
??description中添加了Template:Properties字段,用于为方块添加属性。
1.19.301.19.30.20description中添加了menu_category字段,其中包含categorygroup两个参数,分别用于控制方块在创造模式物品栏中的分类和分组。
1.19.401.19.40.21menu_category字段添加了is_hidden_in_commands参数,用于控制方块是否在命令中可用。
取消对minecraft:direction属性的数据驱动,凡是以“minecraft”为命名空间的属性都会导致内容日志报错。
??properties字段重命名为states
?description中添加了traits字段,用于为方块添加原版状态。

漏洞[编辑]

关于minecraft:block的漏洞在国际版中由漏洞追踪器维护,请在此报告漏洞。