配置 VSC 开发环境
游戏加载包路径
以 windows 系统为例,游戏加载的包在
%localappdata%\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang路径下。其中在这个路径下的
development_resource_packs和development_behavior_packs中的文件夹在每次重启存档的时候都会重新加载
使用 Visual Studio Code 和 npm
- Visual Studio Code 简称VSC,是一个代码编辑器,并且推荐安装 Blockception’s Minecraft Bedrock Development 扩展
- npm 为 node.js 工具,NPM为软件包管理器,可以在 https://nodejs.org/ 处下载安装
使用 VSC 和 npm 开发
- 前往这个网站下载模板包 Minecraft Creator Tools
- 解压缩此安装包到当前路径下
- 在当前路径运行 powershell 等命令行终端工具
- 运行
npm i来安装所需要的节点工具和库 - 然后可以使用
code .来快捷打开VSC - 可以使用
npm run local-deploy快速将写好的文件转移到游戏开发目录下
npm 其他命令
- 扫描代码错误可以使用
npx just-scripts lint - 自动修复错误
npx just-scripts lint --fix - 生成 .mcaddon 文件
npx just-scripts mcaddon
方块
description
"identifier"
- 用于定义方块的标识符,
:前面为命名空间,不能为 minecraft; 后半为方块名
"menu_category"
components
"minecraft:breathability" 透气性
- 值类型 String
solid不可呼吸air可呼吸
设定方块是否可以呼吸,如果省略默认为不可呼吸
"minecraft:crafting_table" 将方块变为合成台
- 值类型 Object
crafting_tags?table_name映射?
此组件仅支持 recipe_shaped 和 recipe_shapeless 类型的配方,而不支持 recipe_furnace 或 recipe_brewing_mix 等其他配方
"minecraft:geometry" 方块模型
-
值类型 String
"minecraft:geometry.full_block"默认的完全方块"minecraft:geometry.cross"交叉方块?
-
值类型 Object
bone_visibiltyobject,包含列表。用于指定模型文件中的骨骼/块是否可见cullingString,渲染方块时候要使用的block_culling.json文件culliing_layerString,?identifierString,模型标识符uv_lockBoolean / String Array,?
"minecraft:item_visual" 手持样式
- 值类型 Object
geometry同"minecraft:geometry"material_instances同"minecraft:material_instances"
该组件用于设定手持该方块时的贴图以及模型
"minecraft:flammable" 可燃性
-
值类型 Boolean
true使用默认值,可燃false方块不可燃
-
值类型 Object
catch_chance_modifierInteger,默认值为5 影响该方块在岩浆等附近着火的概率。越大月容易着火destroy_chance_modifierInteger,默认为20 影响该方块在着火时被火焰摧毁的概率。越大越容易被火烧毁
若省略此组件,则火焰无法从附近方块传导,但是可以直接被点燃
"minecraft:friction" 摩擦力
- 值类型 十进制 默认值为0.4,可设定范围(0.0, 0.9)
影响实体在方块上的移动速度,值越大,摩擦力越大
"minecraft:display_name" 显示名
- 值类型 String
方块的显示名称,即方块的默认名
"minecraft:destructible_by_explosion" 抗暴性
- 值类型 Boolean / Object
explosin_resistance十进制数字,默认值为0 (该值越大抗暴能力越强)
"minecraft:collision_box" 碰撞箱
-
值类型 Boolean
true可碰撞false不可碰撞
-
值类型 Object
origin类型为 Vector[a, b, c] 默认值为 [-8.0, 0,0, -8.0]size类型为 Vector[a, b, c] 默认值为 [16.0, 16,0, 16.0]
关于
origin和size
- Minimal position of the bounds of the collision box. “origin” is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive.
- Size of each side of the collision box. Size is specified as [x, y, z]. “origin” + “size” must be in the range (-8, 0, -8) to (8, 16, 8), inclusive.
"minecraft:selection_box" 选中箱
-
值类型 Boolean
true可碰撞false不可碰撞
-
值类型Object
-
origin类型为 Vector[a, b, c] 默认值为 [-8.0, 0,0, -8.0] -
size类型为 Vector[a, b, c] 默认值为 [16.0, 16,0, 16.0]
-
关于
origin和size
- Minimal position of the bounds of the collision box. “origin” is specified as [x, y, z] and must be in the range (-8, 0, -8) to (8, 16, 8), inclusive.
- Size of each side of the collision box. Size is specified as [x, y, z]. “origin” + “size” must be in the range (-8, 0, -8) to (8, 16, 8), inclusive.
"minecraft:map_color" 地图渲染色
- 值类型 Object
color以#RRGGBB格式的十六进制值或者是 (0, 255) 的 [R, G, B] 数组tint_method可选值,色调乘以颜色
- 若省略该组件,则该方块将不会显示在地图上
- 关于
tint_methodoften refers to the “rain” and “temperature” of the biome the block is placed in to compute the tint. Supported tint methods are “none”, “default_foliage”, “birch_foliage”, “evergreen_foliage”, “dry_foliage”, “grass” and “water”
"minecraft:movable" 可移动
-
值类型 Object
-
movement_type方块被活塞等另一个方块推动时的反应 (必填)-
"push_pull"默认值,该方块将会被活塞推拉 -
"push"只会被活塞拉动 -
"popped"被活塞移动时会被摧毁 -
"immovable"不受活塞影响
-
-
-
sticky当被活塞等另一个方块推动时,此方块周围的方块-
"same"移动时将移动与此方块相邻快 -
"none"默认值,不会移动相邻的方块
-
"minecraft:placement_filter" 放置方块规则
- 值类型 Object
allowed_faces类型 Array,描述此方块可以放置在下面属性指定的方块的那些面block_filter类型 Array,描述可以在那些方块上放置此方块的列表-
"name"方块名称 -
"states"方块状态 -
"tags"使用 Molang 查询的条件
-
可以指定 “up”, “down”, “north”, “south”, “east”, “west”, “side”, “all”. Limited to 6 faces.
"minecraft:light_dampening" 透光性
- 值类型 Integer 默认值 15
用于表示光线穿过方块时候的阻尼。值越大透光性越弱
"minecraft:light_emission" 亮度
- 值类型 Integer 默认值 0
方块所发出的亮度,范围 (0, 15)
"minecraft:material_instances" 材质渲染
- 值类型 Object
可以通过材质实例对象分配给以下任何面:
"up","down","north","south","east","west","*"
"*"为方块所有面
材质实例
ambient_occlusion是否启用环境光遮挡。若为true则在方块周围和旁边创建阴影。也可以使用浮点数来控制face_dimmingShould this material be dimmed by the direction it’s facing? 布尔值isotropic是否需要随机化UV?render_method值类型 String"opaque"默认值,不允许透明度以及半透明"double_sided"完全禁用背面删除?"blend"用于彩色玻璃方块等,允许透明度和半透明"alpha_test"用于向原版玻璃这样的方块。不允许半透明,仅允许完全不透明或者完全透明的纹理。还会禁用背面删除
texture材质名称,在资源包texture/terrain_texture.json中定义tint_method方块色调
方块色调有
“none”, “default_foliage”, “birch_foliage”, “evergreen_foliage”, “dry_foliage”, “grass” and “water”
默认值 none
"minecraft:liquid_detection" 检测液体
- 值类型 Object
can_contain_liquid检测方块是否可以含有液体。默认值falseliquid_type可以含液体的类型,默认为wateron_liquid_touches方块对流水的反应-
blocking默认值,会阻止液体流动 -
broken方块会被液体摧毁 -
popped方块被摧毁并生成其物品状态 -
no_reaction方块不受影响(液体穿过方块) stops_liquid_folowing_from_direction当方块含有液体时控制液体不能从哪个方向流出
-
if
no_reactionis set for theon_liquid_touchesfield. Can be a list of the following directions:"up","down","north","south","east","west". The default is an empty list; this means that liquid can flow out of all directions by default.
"minecraft:loot" 战利品/掉落
- 值类型 Path_String
战利品定义文件相对于行为包的路径
"minecraft:destructible_by_mining" 挖掘速度
-
值类型 Boolean
true花费默认时间可以摧毁false不可摧毁
-
值类型 Object
item_specific_speeds用于描述特定工具等针对该方块摧毁速度的项目组 类型为 Array-
destroy_speed必填,使用对应工具等对方块的破坏速度 -
item必填,针对项目的筛选 seconds_to_destory十进制数字,默认为0 数值越高挖掘时间越长
-
"minecraft:destruction_particles" 破坏粒子
- 值类型 Object
"minecraft:transformation" 变形
- 值类型 Object
"minecraft:redstone_conductivity" 红石属性
- 值类型 Object
allows_wire_to_step_down指定红石线路是否可以在方块上下阶梯。默认为trueredstone_conductor是否可以由红石提供动力,默认为false
"minecraft:custom_components" 脚本事件列表
- 值类型 Array
设定自定义脚本名称的列表。以绑定到方块上方便执行
物品
配方
战利品
生态系
description
"identifier"
- 用于定义方块的标识符,
:前面为命名空间,不能为 minecraft ; 后半为生态名
components
"minecraft:replace_biomes" 替换生态系
- 值类型 Object
"minecraft:climate" 气候
- 值类型 Object
"minecraft:overworld_generation_rules" 实例化
- 值类型 Object
"minecraft:overworld_height" 地形高度噪点参数
- 值类型 Object
"minecraft:surface_builder" 地形材质
- 值类型 Object
"minecraft:tags" 标签
- 值类型 Object