CarrotS 方块

CarrotS 包中的方块定义 · 基于 blocks.json 数据驱动

CarrotS 是长夜项目的一个基础资源包,该项目以此资源包为核心资源构建。 每个方块通过 JSON 配置其属性,包括硬度、透明度、纹理、掉落物、声音等。 所有方块都继承自 CarrotS:default 中的默认值,仅有差别的字段需要显式覆盖。

💡 数据驱动提示: 当某个属性(如 physics.hardness)未在具体方块中定义时,游戏会回退使用 CarrotS:default 中的默认值。这意味着每个方块只需定义与其默认值不同的字段即可。 例如 CarrotS:grass 只覆写了纹理、声音、工具类型和掉落物, 其余十几个属性全部继承自 CarrotS:default

方块列表

目前 CarrotS 中定义了以下方块:

标识键 名称 纹理 硬度 透明 掉落物
CarrotS:air 空气 Air air.png 0.0 (覆写) ✅ 是
CarrotS:grass Grass grass.png 1.0 (继承默认) ["CarrotS:grass_block"]
CarrotS:stone 石头 Stone stone.png 1.0 (继承默认) ["CarrotS:stone_block"]
CarrotS:water Water water.png 0.0 (覆写) ✅ 是 (不掉落)

空气 Air

空气(Air)是构成世界中空白空间的方块。它完全透明,硬度为 0, 碰撞箱为 Empty(无体积),可被替换,物态为气体。 在游戏中不可被选中或破坏。

标识键 CarrotS:air
numeric_id 1
physics.hardness 0.0 (覆写默认 1.0)
physics.transparent true
physics.integrity "Empty" (覆写默认 "A_full")
physics.replaceable true (覆写默认 false)
physics.state_of_matter "gas" (覆写默认 "solid")
sources.texture "air.png" (覆写默认 "missing.png")
sources.map_color "#64b5f6" (覆写默认 "#888888")
其余字段 全部继承自 CarrotS:default

草方块 Grass

草方块(Grass)是覆盖在大多数陆地生物群系表面的方块。 使用锹采集可获得 CarrotS:grass_block 物品。 具有独立的破坏、放置和行走音效。

标识键 CarrotS:grass
numeric_id 2
physics.hardness 1.0 (继承默认)
physics.transparent false (继承默认)
sources.texture "grass.png" (覆写默认)
sources.map_color "#33930E" (覆写默认 "#888888")
sources.sound_break "grass_break" (覆写默认 "block_break")
sources.sound_place "grass_place" (覆写默认 "block_place")
sources.sound_step "grass_step" (覆写默认 "block_step")
interaction.tool_type "shovel" (覆写默认 "empty")
interaction.drops ["CarrotS:grass_block"] (覆写默认 [])
其余字段 全部继承自 CarrotS:default

石头 Stone

石头(Stone)是地下最常见的固体方块。使用镐采集可获得 CarrotS:stone_block 物品。具有独立的破坏、放置和行走音效。

标识键 CarrotS:stone
numeric_id 3
physics.hardness 1.0 (继承默认)
physics.transparent false (继承默认)
sources.texture "stone.png" (覆写默认)
sources.map_color "#969696" (覆写默认 "#888888")
sources.sound_break "stone_break" (覆写默认 "block_break")
sources.sound_place "stone_place" (覆写默认 "block_place")
sources.sound_step "stone_step" (覆写默认 "block_step")
interaction.tool_type "pickaxe" (覆写默认 "empty")
interaction.drops ["CarrotS:stone_block"] (覆写默认 [])
其余字段 全部继承自 CarrotS:default

Water

(Water)是覆盖世界海洋、河流和湖泊的液体方块。 它完全透明,硬度为 0,碰撞箱为 Half_full,可被替换。 行走和跳跃速度减半(0.5 倍率),重力减半。

标识键 CarrotS:water
numeric_id 4
physics.hardness 0.0 (覆写默认 1.0)
physics.transparent true
physics.state_of_matter "liquid" (覆写默认 "solid")
physics.integrity "Half_full" (覆写默认 "A_full")
physics.replaceable true (覆写默认 false)
physics.gravity 0.5 (覆写默认 1.0)
physics.speed_modifier 0.5 (覆写默认 1.0)
physics.jump_modifier 0.5 (覆写默认 1.0)
sources.texture "water.png" (覆写默认 "missing.png")
sources.map_color "#3F76E4" (覆写默认 "#888888")
sources.sound_break "water_splash" (覆写默认 "block_break")
sources.sound_place "water_splash" (覆写默认 "block_place")
sources.sound_step "water_step" (覆写默认 "block_step")
其余字段 全部继承自 CarrotS:default

默认模板 CarrotS:default

CarrotS:default 是一个特殊的条目(numeric_id: 0),它不是可放置的方块, 而是为所有方块提供默认属性值。 当某个方块未定义特定字段时,游戏会回退使用此处的值。

📋 注意: CarrotS:default 仅作为配置模板,在实际游戏中不会出现。
属性路径 默认值 说明
▸ physics — 物理属性
physics.hardness1.0方块硬度,影响挖掘时间和挖掘等级
physics.transparentfalse是否为透明方块(如玻璃、空气)
physics.flammablefalse是否可燃
physics.integrity"A_full"碰撞箱形态,有A_full、Empty、half_full三种值
physics.replaceablefalse是否可被其他方块替换(如空气、水可被替换)
physics.state_of_matter"solid"物态:solid(固体)/ liquid(液体)/ gas(气体)
physics.gravity1.0重力倍率(影响掉落速度等)
physics.speed_modifier1.0角色速度倍率(行走、掉落和游泳等)
physics.jump_modifier1.0跳跃高度倍率
physics.tickablefalse是否每 tick 更新(如植物生长、液体流动)
▸ sources — 视觉 & 声源
sources.texture"missing.png"默认纹理(缺失纹理占位图)
sources.map_color"#888888"地图上显示的颜色(十六进制 RGB)
sources.light_level0自身发光亮度 (0–15)
sources.light_filter15穿过该方块后光线衰减量 (0–15)
sources.sound_break"block_break"破坏方块时的音效
sources.sound_place"block_place"放置方块时的音效
sources.sound_step"block_step"在方块上行走时的音效
▸ interaction — 交互属性
interaction.tool_type"empty"推荐挖掘工具,"empty" = 空手即可
interaction.drops[] (空数组)掉落物列表(物品 ID 数组)。默认不掉落任何物品
interaction.tile_entitynull绑定的 TileEntity(如箱子、熔炉等需存储数据的方块)

默认声音配置

字段名事件声音 ID
sources.sound_break破坏 (break)"block_break"
sources.sound_place放置 (place)"block_place"
sources.sound_step行走 (step)"block_step"

模板示例

以下展示 blocks.json 中各方块的实际 JSON 定义,帮助理解继承覆写机制。

完整默认模板 CarrotS:default

这是所有方块的基础模板,定义了 21 个默认属性值。 每个显式定义的方块只需写出与以下值不同的字段即可。

{ // physics 物理属性组 (10 个字段) "physics": { "hardness": 1.0, // 挖掘硬度 "transparent": false, // 非透明 "flammable": false, // 不可燃 "integrity": "A_full", // 完整碰撞箱 "replaceable": false, // 不可被替换 "state_of_matter": "solid", // 固体 "gravity": 1.0, // 标准重力 "speed_modifier": 1.0, // 标准速度 "jump_modifier": 1.0, // 标准跳跃 "tickable": false // 不需要每 tick 更新 }, // sources 视觉 & 声源组 (7 个字段) "sources": { "texture": "missing.png", // 默认纹理(缺失占位) "map_color": "#888888", // 地图灰色 "light_level": 0, // 不发光 "light_filter": 15, // 完全挡光 "sound_break": "block_break", // 破坏音效 "sound_place": "block_place", // 放置音效 "sound_step": "block_step" // 行走音效 }, // interaction 交互属性组 (3 个字段) "interaction": { "tool_type": "empty", // 空手即可挖掘 "drops": [], // 默认不掉落 "tile_entity": null // 无方块实体 } }

最小覆写示例 CarrotS:grass

草方块只覆写了 6 个字段(纹理、地图色、3 种声音、工具类型、掉落物), 其余 15+ 个属性全部继承自 CarrotS:default

{ "CarrotS:grass": { "sources": { "texture": "grass.png", // 覆写默认纹理 "map_color": "#33930E", // 覆写地图颜色 "sound_break": "grass_break", // 覆写破坏音效 "sound_place": "grass_place", // 覆写放置音效 "sound_step": "grass_step" // 覆写行走音效 }, "interaction": { "tool_type": "shovel", // 推荐用锹挖掘 "drops": ["CarrotS:grass_block"] // 掉落草方块物品 } } }

大量覆写示例 CarrotS:water

水方块覆写了 14 个字段,包括物态、碰撞箱、重力、速度等物理属性, 以及纹理、地图色和全部三种声音。这是目前覆写最多的方块。

{ "CarrotS:water": { "physics": { "hardness": 0.0, // 无硬度 "transparent": true, // 透明 "state_of_matter": "liquid", // 液体 "integrity": "Half_full", // 半格碰撞箱 "replaceable": true, // 可被替换 "gravity": 0.5, // 重力减半 "speed_modifier": 0.5, // 行走减速 "jump_modifier": 0.5 // 跳跃减半 }, "sources": { "texture": "water.png", // 覆写纹理 "map_color": "#3F76E4", // 覆写地图色 "sound_break": "water_splash", // 水花破坏 "sound_place": "water_splash", // 水花放置 "sound_step": "water_step" // 涉水行走 } } }

属性详解

以下按照 blocks.json 的实际结构,分 physicssourcesinteraction 三个分组逐一说明。

name — 名称(顶层字段)

方块的标识名称,位于 JSON 根层级。例如 "air""grass""stone"
CarrotS:defaultname"CarrotS_NONE",表示它仅作为默认模板。

physics — 物理属性组

包含 10 个子字段,控制方块的硬度、透明度、可燃性、碰撞箱、可替换性、物态、重力、速度修正、跳跃修正、tick 更新。

physics.hardness — 硬度

数值越高,挖掘时间越长。计算公式参考 Minecraft:
挖掘时间 = hardness × 1.5 / 工具速度(待确认)。
空气的硬度为 0,可瞬间破坏。

physics.transparent — 透明度

若为 true,则光线可以穿过该方块,且方块侧面不会被渲染(类似玻璃、空气)。
目前只有 CarrotS:air 显式设置了 true

physics.flammable — 可燃性

若为 true,该方块可被火焰点燃并蔓延。目前所有方块均不可燃(默认 false)。

physics.integrity — 完整性

控制方块的碰撞箱与外观形态。"A_full" 表示完整的 1×1×1 方块, "Half_full" 表示半格(如水),"Empty" 表示无碰撞箱(如空气)。 未来可能支持台阶 ("slab")、楼梯 ("stair") 等。

physics.replaceable — 可替换性

若为 true,该方块可被其他方块放置时直接替换(如空气可被任何方块替换, 水可被放置的方块替换)。默认 false,表示固体方块不被替换。

physics.state_of_matter — 物态

物理状态:solid(固体)、liquid(液体)、gas(气体)。影响方块的流动与碰撞行为。

physics.gravity — 重力

该方块的重力倍率,影响掉落中的实体或受重力影响的方块(如沙砾)的下落速度。

physics.speed_modifier — 速度修正

玩家在该方块上行走的速度倍率。1.0 为正常速度。可用来制作减速方块(如蛛网 < 1.0)或加速方块(如冰 > 1.0)。

physics.jump_modifier — 跳跃修正

玩家在该方块上跳跃的高度倍率。1.0 为正常跳跃高度。

physics.tickable — 周期性更新

若为 true,该方块每 tick 会收到更新事件(如植物生长、液体流动)。 默认 false,静态方块不需要 tick。

sources — 视觉 & 声源组

包含 7 个子字段,控制纹理、地图颜色、光照等级、光线过滤、三种声音。

sources.texture — 纹理

方块使用的纹理文件路径(相对于 textures/ 目录)。默认值为 "missing.png"(缺失纹理占位图)。
各方块覆写:grass"grass.png"stone"stone.png"

sources.map_color — 地图颜色

在游戏地图上该方块所呈现的颜色(十六进制 RGB)。例如默认 "#888888" 为灰色。

sources.light_level — 光照等级

方块自身发出的光照强度,范围为 0–15。0 表示不发光。未来发光的方块(如荧石、火把)将使用此属性。

sources.light_filter — 光线过滤

光线穿过该方块后衰减的量,范围为 0–15。默认值 15 表示完全遮挡阳光。 透明方块(如空气、水)应设置较低的值以允许光线透过。

sources.sound_break — 破坏音效

破坏(挖掘)该方块时播放的声音。默认 "block_break"

sources.sound_place — 放置音效

放置该方块时播放的声音。默认 "block_place"

sources.sound_step — 行走音效

玩家在该方块上行走时播放的声音。默认 "block_step"

interaction — 交互属性组

包含 3 个子字段,控制工具类型、掉落物列表、方块实体。

interaction.tool_type — 工具类型

推荐的挖掘工具,"empty" 表示空手即可。未来可能扩展为 "pickaxe"(镐)、"shovel"(锹)、"axe"(斧)等。

interaction.drops — 掉落物

字符串数组,指定方块被破坏后掉落的物品 ID。默认值为空数组 [](不掉落)。
各方块覆写:CarrotS:grass["CarrotS:grass_block"]
CarrotS:stone["CarrotS:stone_block"]

interaction.tile_entity — 方块实体

如果此方块需要存储额外数据(如箱子中的物品、熔炉的进度),则在此指定绑定的 TileEntity 类名。当前所有方块均为 null

未来规划