手冊:Minecraft:block (模式)/1.19.70

出自Minecraft基岩版开发Wiki

模式[編輯]

基礎模式
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"
      }
    }
  }
}