Skip to content

自定义含雪方块 ​

自定义含雪方块允许你的方块被积雪覆盖,类似原版草方块在降雪后表面出现雪层的效果。你需要同时配置 netease:snow_recover_able 和 netease:can_built_over 两个组件来启用此功能,不需要设置 base_block。

前置条件

请先阅读 自定义基础方块 了解方块的注册流程和 JSON 组件体系。含雪方块使用 format_version: "1.10.0",不需要开启实验性玩法。

概述 ​

原版 MC 中,草方块、菌丝、灰化土等方块在降雪时会被一层薄雪覆盖。中国版通过两个组件让自定义方块也具备此能力:

  • netease:snow_recover_able — 控制方块是否能被雪覆盖
  • netease:can_built_over — 控制其他方块能否替换掉雪层(类似原版在雪层上放置方块时雪层消失)

这两个组件必须同时配置才能正常工作。只配置其中一个不会产生含雪效果。

含雪方块适合以下场景:

  • 自定义地表方块(草地、泥土变体)
  • 自定义装饰性方块需要响应天气
  • 需要与原版降雪机制兼容的方块

组件字段 ​

netease:snow_recover_able ​

键类型默认值说明
valuebool—必填,方块是否能被积雪覆盖
json
"netease:snow_recover_able": { "value": true }

netease:can_built_over ​

键类型默认值说明
valuebool—必填,其他方块放置时能否替换此方块上方的雪层
json
"netease:can_built_over": { "value": true }

当 can_built_over 为 true 时,玩家在含雪方块的雪层位置放置其他方块,雪层会被新方块替代。为 false 时,雪层不会被替代,新方块无法放置在雪层位置。

完整示例 ​

自定义含雪地表方块 ​

文件路径:行为包/netease_blocks/custom_grass.json

json
{
    "format_version": "1.10.0",
    "minecraft:block": {
        "description": {
            "identifier": "mymod:custom_grass",
            "register_to_create_menu": true,
            "category": "Nature"
        },
        "components": {
            "minecraft:destroy_time": { "value": 0.6 },
            "minecraft:explosion_resistance": { "value": 0.6 },
            "minecraft:block_light_absorption": { "value": 0 },
            "netease:render_layer": { "value": "alpha" },
            "netease:tier": {
                "digger": "shovel",
                "destroy_special": false
            },
            "netease:snow_recover_able": { "value": true },
            "netease:can_built_over": { "value": true },
            "netease:aabb": {
                "collision": {
                    "min": [0.0, 0.0, 0.0],
                    "max": [0.0, 0.0, 0.0]
                },
                "clip": {
                    "min": [0.0, 0.0, 0.0],
                    "max": [1.0, 0.188, 1.0]
                }
            }
        }
    }
}

AABB 与雪层厚度

示例中 clip 的 max Y 值为 0.188,对应大约 3 像素高度的薄雪层射线检测区域。你可以根据方块的实际外观调整此值。collision 设为零向量表示无物理碰撞(玩家和生物可以穿过雪层),这与原版薄雪层的行为一致。

资源包 — blocks.json ​

文件路径:资源包/blocks.json

json
{
    "mymod:custom_grass": {
        "textures": {
            "up": "mymod:custom_grass_top",
            "down": "mymod:custom_grass_bottom",
            "north": "mymod:custom_grass_side",
            "south": "mymod:custom_grass_side",
            "west": "mymod:custom_grass_side",
            "east": "mymod:custom_grass_side"
        },
        "sound": "grass"
    }
}

资源包 — terrain_texture.json ​

文件路径:资源包/textures/terrain_texture.json

json
{
    "resource_pack_name": "mymod",
    "texture_name": "atlas.terrain",
    "texture_data": {
        "mymod:custom_grass_top": {
            "textures": "textures/blocks/custom_grass_top"
        },
        "mymod:custom_grass_bottom": {
            "textures": "textures/blocks/custom_grass_bottom"
        },
        "mymod:custom_grass_side": {
            "textures": "textures/blocks/custom_grass_side"
        }
    }
}

资源包 — 本地化 ​

文件路径:资源包/texts/zh_CN.lang

tile.mymod:custom_grass.name=自定义草方块

注意事项 ​

兼容性限制

自定义含雪方块与以下功能不兼容,请勿同时使用:

  • 自定义方块实体(netease:block_entity 组件)
  • 自定义刷怪箱(base_block: "mob_spawner")
  • 其他需要方块实体的特殊方块类型

如果你同时配置了含雪组件和方块实体组件,含雪功能将无法正常工作。

降雪覆盖条件 ​

含雪方块的雪层由游戏的降雪机制自动产生,需要满足以下条件:

  • 方块所在区域正在降雪
  • 方块上方为空气
  • 方块的 netease:snow_recover_able 设为 true

雪层移除 ​

雪层会在以下情况被移除:

  • 方块位置附近有足够高的光照等级(类似原版雪的融化机制)
  • 玩家手动破坏雪层
  • 当 netease:can_built_over 为 true 时,玩家在雪层位置放置了新方块

下一步 ​