完整版BedrockWiki镜像!
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Project Setup
|
||||
category: Guide
|
||||
description: How to setup your project
|
||||
title: 项目设置
|
||||
category: 指南
|
||||
description: 如何设置您的项目
|
||||
nav_order: 4
|
||||
prefix: '4. '
|
||||
mentions:
|
||||
@@ -24,91 +24,94 @@ mentions:
|
||||
- lescx
|
||||
---
|
||||
|
||||
## The com.mojang folder
|
||||
# 项目设置
|
||||
|
||||
The `com.mojang` folder is a special folder where Minecraft stores data (Addons, Worlds, Player info...). Minecraft understands this location, and all files we access or create will be placed somewhere in this folder!
|
||||
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
|
||||
|
||||
You should create a shortcut to the `com.mojang` folder on your Desktop or on your mobile device, so you can easily access it at any time. The exact location of the `com.mojang` folder will depend on your device OS.
|
||||
## com.mojang 文件夹
|
||||
|
||||
`com.mojang` 文件夹是Minecraft存储数据(附加包、世界、玩家信息等)的特殊位置。Minecraft能够识别这个路径,所有我们访问或创建的文件都将存放在这个文件夹中!
|
||||
|
||||
建议您在桌面或移动设备上创建`com.mojang`文件夹的快捷方式以便快速访问。该文件夹的具体位置因设备操作系统而异。
|
||||
|
||||
### Windows
|
||||
|
||||
_Tip: You can type %appdata% into the searchbar to jump directly into the 'C:\Users\USERNAME\AppData\' folder._
|
||||
_提示:在搜索栏输入%appdata%可直接跳转至'C:\Users\用户名\AppData\'目录_
|
||||
|
||||
`C:\Users\USERNAME\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\LocalState\games\com.mojang`
|
||||
|
||||
### Android
|
||||
|
||||
Android 11 or older: `Phone > games > com.mojang`
|
||||
Android 11及更早版本:`手机存储 > games > com.mojang`
|
||||
|
||||
Android 12 and newer: `Phone > Android > data > com.mojang.minecraftpe > files > games > com.mojang`
|
||||
Android 12及更新版本:`手机存储 > Android > data > com.mojang.minecraftpe > files > games > com.mojang`
|
||||
|
||||
### ChromeOS
|
||||
|
||||
Before you can see the `com.mojang` in your files, make sure to change the `File Storage Location` to `External` in your Minecraft Settings:
|
||||
在访问`com.mojang`文件夹前,需先在Minecraft设置中将`文件存储位置`更改为`外部`:
|
||||
|
||||
- Go to `Minecraft Settings`.
|
||||
- Navigate to `Settings > General > Storage`.
|
||||
- Change the `File Storage Location` to `External`.
|
||||
1. 进入`Minecraft设置`
|
||||
2. 导航至`设置 > 通用 > 存储`
|
||||
3. 将`文件存储位置`改为`外部`
|
||||
|
||||
After that you can access the `com.mojang` folder in your Android Subsystem:
|
||||
|
||||
`My Files > Play Files > Android > data > com.mojang.minecraftpe > files > games > com.mojang`
|
||||
设置完成后可通过以下路径访问:
|
||||
`我的文件 > Play文件 > Android > data > com.mojang.minecraftpe > files > games > com.mojang`
|
||||
|
||||
### iOS
|
||||
|
||||
`My iDevice > Minecraft > games > com.mojang`
|
||||
`我的设备 > Minecraft > games > com.mojang`
|
||||
|
||||
### Development Packs
|
||||
### 开发包
|
||||
|
||||
We will develop our addon in `development_behavior_packs` and `development_resource_packs`. When you make changes within these folders, you can _exit and re-enter a world with the packs applied_, to automatically reload the content. This allows you to quickly test your addon without reloading Minecraft.
|
||||
我们将在`development_behavior_packs`和`development_resource_packs`中开发附加包。在这些文件夹中修改内容后,只需_退出并重新进入已应用该包的世界_即可自动重载内容,无需重启Minecraft即可快速测试修改。
|
||||
|
||||
`resource_packs` and `behavior_packs` on the other hand contain stable addons, including those imported via `.mcpack`. We can ignore these folders for now.
|
||||
`resource_packs`和`behavior_packs`文件夹用于存放稳定版附加包(包括通过`.mcpack`导入的包),开发时可暂时忽略这些目录。
|
||||
|
||||
## Your Workspace
|
||||
## 您的工作区
|
||||
|
||||
:::tip
|
||||
Project setup is different for android and other platforms. Consider looking into our guide for android platforms.
|
||||
Android平台的项目设置与其他平台有所不同,建议参考我们的Android专用指南。
|
||||
:::
|
||||
|
||||
<BButton
|
||||
link="./project-setup-android"
|
||||
color=blue
|
||||
>Android guide</BButton>
|
||||
>Android指南</BButton>
|
||||
|
||||
:::tip
|
||||
In this guide, BP refers to the folder you created in `development_behavior_packs` ("the behavior pack"), and RP refers to the folder you created in `development_resource_packs` ("the resource pack")
|
||||
本指南中:
|
||||
- BP指在`development_behavior_packs`中创建的文件夹(行为包)
|
||||
- RP指在`development_resource_packs`中创建的文件夹(资源包)
|
||||
:::
|
||||
|
||||
First of all, you will need to create the proper folders in suitable locations and set up your workspace.
|
||||
_The remainder of this guide assumes you are using VSCode. You may also follow along with other editors._
|
||||
首先需要在适当位置创建文件夹并建立工作区。_本指南后续步骤默认使用VSCode,您也可以使用其他编辑器。_
|
||||
|
||||
Let's create your first add-on workspace in Visual Studio Code now.
|
||||
现在让我们在VSCode中创建第一个附加包工作区:
|
||||
|
||||
1. Open VSCode (_Visual Studio Code, the code editor_)
|
||||
2. Create a folder named "`your_pack_name_RP`" in `development_resource_packs`. **I'll refer to this folder as `RP`**
|
||||
3. Create a folder "`your_pack_name_BP`" in `development_behavior_packs`. **I'll refer to this folder as `BP`**.
|
||||
4. Go to `File > Add folder to workspace...` and choose `BP`. Do the same with `RP`.
|
||||
5. Press `File > Save Workspace as...` to save the workspace file to your Desktop. Whenever you're working on your addon, all you have to do is open the workspace by double-clicking, and you will get quick access to both BP and RP folders.
|
||||
1. 打开VSCode(Visual Studio Code代码编辑器)
|
||||
2. 在`development_resource_packs`中创建名为"`your_pack_name_RP`"的文件夹(以下简称`RP`)
|
||||
3. 在`development_behavior_packs`中创建名为"`your_pack_name_BP`"的文件夹(以下简称`BP`)
|
||||
4. 通过`文件 > 将文件夹添加到工作区...`依次添加`BP`和`RP`
|
||||
5. 使用`文件 > 将工作区另存为...`将工作区文件保存到桌面。后续开发时只需双击打开该工作区文件,即可快速访问BP和RP文件夹
|
||||
|
||||
## BP Manifest
|
||||
## BP清单文件
|
||||
|
||||
:::tip
|
||||
In this guide, you will often be instructed to create files with specific names, placed in specific folders. If the folder doesn't exist yet, please create it!
|
||||
本指南中会频繁要求您在特定路径创建指定文件。如果目标文件夹不存在,请先创建!
|
||||
:::
|
||||
|
||||
:::warning
|
||||
Wrongly named files/folders is a common source of errors. Please check your work carefully against the examples.
|
||||
文件名/文件夹名错误是常见问题来源,请仔细核对示例。
|
||||
:::
|
||||
|
||||
The manifest is a file that identifies your pack to Minecraft. Every pack has one manifest. A folder with a correctly formatted manifest will show up in Minecraft, and we consider this the "minimal" pack before we can add additional content.
|
||||
清单文件(manifest)是Minecraft识别附加包的核心文件。每个包都必须包含一个格式正确的清单文件,这是附加包能被识别的最低要求。
|
||||
|
||||
Manifest files are written in `json`. If this isn't familiar to you, you can learn more about json [here](/understanding-json).
|
||||
清单文件使用`json`格式编写。如需了解json格式,请参考[此文档](/understanding-json)。
|
||||
|
||||
First, create a new file in your BP folder by right-clicking on the folder and selecting `New File`. Call the file `manifest.json`. To begin, you can copy paste the following code into the file.
|
||||
在BP文件夹中右键新建文件,命名为`manifest.json`。初始内容可复制以下代码:
|
||||
|
||||
<CodeHeader>BP/manifest.json</CodeHeader>
|
||||
|
||||
```json
|
||||
::: code-group
|
||||
```json [BP/manifest.json]
|
||||
{
|
||||
"format_version": 2,
|
||||
"header": {
|
||||
@@ -127,40 +130,36 @@ First, create a new file in your BP folder by right-clicking on the folder and s
|
||||
]
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
### Manifest Explained
|
||||
### 清单文件解析
|
||||
|
||||
- "`format_version`" defines what version of manifest syntax you are using. Version 2 is the most recent stable version; use it.
|
||||
- `format_version` 指定清单语法版本,推荐使用最新稳定版2
|
||||
- `name` 定义行为包名称,`description` 为游戏内显示的描述。使用"代码形式"定义以便后续本地化,详见[文本与翻译](/wiki/concepts/text-and-translations)
|
||||
- `UUID` 字段至关重要,下文将详细说明
|
||||
- `version` 控制附加包版本号。当设备上已安装旧版本时,新版会自动覆盖旧版。若仅在`development_*_packs`中使用且用于私人世界,可不更新版本号
|
||||
- `min_engine_version` 指定兼容的最低Minecraft客户端版本
|
||||
- `modules` 中`type`设为`data`表明这是行为包
|
||||
|
||||
- "`name`" is the name of your behavior pack. "`description`" will show up under it in-game. We are defining these files in "code form" so we can translate them later into other languages. For more information about localization, look [here](/concepts/text-and-translations).
|
||||
### UUID详解
|
||||
|
||||
- The "`UUID`" field is **essential**, and will be discussed in more detail below.
|
||||
UUID(通用唯一识别码)是Minecraft识别附加包的核心标识,格式示例:`5c830391-0937-44d6-9774-406de66b6984`
|
||||
|
||||
- "`version`" defines the version of your add-on. When you import an add-on with a newer version on a device with an older version installed, the more recent version will overwrite the older one. You don't need to change the version if you have the add-on in `development_*_packs` folders and only use them on private worlds.
|
||||
**禁止重复使用相同UUID**。您可以通过以下方式生成:
|
||||
- [在线生成器](https://www.uuidgenerator.net/version4)
|
||||
- VSCode用户可安装[此扩展](https://marketplace.visualstudio.com/items?itemName=netcorext.uuid-generator)
|
||||
- 专业工具如_bridge._会自动生成
|
||||
|
||||
- "`min_engine_version`" defines the minimum Minecraft client version that'll be able to read your add-on.
|
||||
|
||||
- In "`modules`", the "`type`" is defined to be "`data`". This makes your pack a _Behavior Pack_.
|
||||
|
||||
### UUID Explained
|
||||
|
||||
A UUID (_Universally Unique Identifier_) identifies your pack for other programs (in this case, Minecraft) to read. It looks something like this: `5c830391-0937-44d6-9774-406de66b6984`
|
||||
|
||||
**NEVER USE THE SAME UUID TWICE.** You can generate your own UUIDs [here](https://www.uuidgenerator.net/version4) or, if you use VSCode, you can install [this](https://marketplace.visualstudio.com/items?itemName=netcorext.uuid-generator) extension. Many other tools like _bridge._ generate UUIDS automatically. Every manifest file uses two different UUIDs.
|
||||
|
||||
To ensure that your add-on will work correctly you should generate two new UUID's which you will paste into the BP `manifest.json` file, at each `"..."`. When you are finished, it should look something like this:
|
||||
每个清单文件需要两个不同的UUID,分别填入`header.uuid`和`modules[0].uuid`。正确示例如下:
|
||||
|
||||
`"uuid": "5c830391-0937-44d6-9774-406de66b6984"`
|
||||
|
||||
## RP Manifest
|
||||
## RP清单文件
|
||||
|
||||
The next step is to create the `manifest.json` for the RP. The format for a resource-pack manifest is nearly identical to a BP manifests except that the `type` is `resources`, which marks the pack as a _Resource Pack_.
|
||||
资源包清单文件格式与行为包相似,主要区别在于`type`需设为`resources`:
|
||||
|
||||
Copy the following code into your newly created `RP/manifest.json` and insert your own UUIDs.
|
||||
|
||||
<CodeHeader>RP/manifest.json</CodeHeader>
|
||||
|
||||
```json
|
||||
::: code-group
|
||||
```json [RP/manifest.json]
|
||||
{
|
||||
"format_version": 2,
|
||||
"header": {
|
||||
@@ -179,90 +178,93 @@ Copy the following code into your newly created `RP/manifest.json` and insert yo
|
||||
]
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
## Pack Icon
|
||||
## 包图标
|
||||
|
||||
The pack icon is an image file which identifies how your addon will look in-game. If you have a low-resolution square image, you can use it. Otherwise, download and use this example icon:
|
||||
包图标是附加包在游戏内的展示图片。建议使用低分辨率正方形图片,或下载以下示例图标:
|
||||
|
||||
<WikiImage src="/assets/images/guide/project-setup/pack_icon.png" alt="Pack Icon" pixelated/>
|
||||
<WikiImage src="/assets/images/guide/project-setup/pack_icon.png" alt="包图标" pixelated/>
|
||||
|
||||
<BButton
|
||||
link="/assets/images/guide/project-setup/pack_icon.png" download
|
||||
color=default
|
||||
>Download Image</BButton>
|
||||
>下载图片</BButton>
|
||||
|
||||
You should place a copy of your desired image into both the RP and the BP. The image needs to be named `pack_icon.png`
|
||||
将图片文件分别放入RP和BP文件夹,并命名为`pack_icon.png`
|
||||
|
||||
## Language Files
|
||||
## 语言文件
|
||||
|
||||
The last thing to do is setup language support for your addon. You will need to create a language file for both the RP and the BP. You can learn more about how Minecraft handles localization [here](/concepts/text-and-translations).
|
||||
最后需要为附加包设置语言支持。需为RP和BP分别创建语言文件,详见[本地化系统](/wiki/concepts/text-and-translations)。
|
||||
|
||||
<CodeHeader>RP/texts/en_US.lang</CodeHeader>
|
||||
|
||||
```json
|
||||
pack.name=Wiki Resource Pack
|
||||
pack.description=A Ghostly Guide
|
||||
::: code-group
|
||||
```json [RP/texts/en_US.lang]
|
||||
pack.name=Wiki资源包
|
||||
pack.description=幽灵指南
|
||||
```
|
||||
:::
|
||||
|
||||
<CodeHeader>BP/texts/en_US.lang</CodeHeader>
|
||||
|
||||
```json
|
||||
pack.name=Wiki Behavior Pack
|
||||
pack.description=A Ghostly Guide
|
||||
::: code-group
|
||||
```json [BP/texts/en_US.lang]
|
||||
pack.name=Wiki行为包
|
||||
pack.description=幽灵指南
|
||||
```
|
||||
:::
|
||||
|
||||
<CodeHeader>RP/texts/languages.json</CodeHeader>
|
||||
|
||||
```json
|
||||
::: code-group
|
||||
```json [RP/texts/languages.json]
|
||||
["en_US"]
|
||||
```
|
||||
:::
|
||||
|
||||
<CodeHeader>BP/texts/languages.json</CodeHeader>
|
||||
|
||||
```json
|
||||
::: code-group
|
||||
```json [BP/texts/languages.json]
|
||||
["en_US"]
|
||||
```
|
||||
:::
|
||||
|
||||
## Checking your Work
|
||||
## 验证成果
|
||||
|
||||
If you have done everything correctly, your packs should show up in Minecraft now! If you don't see your pack, you should follow the [troubleshooting guide.](/troubleshooting)
|
||||
完成上述步骤后,您的附加包应已出现在游戏中!如果未显示,请参考[问题排查指南](/troubleshooting)。
|
||||
|
||||

|
||||
|
||||
## Turn on Content Log
|
||||
## 启用内容日志
|
||||
|
||||
:::warning
|
||||
Content log is the most useful tool you have for debugging your addons. Please do not skip this step.
|
||||
内容日志是调试附加包最重要的工具,请务必启用。
|
||||
:::
|
||||
|
||||

|
||||
|
||||
Content Log is an extremely important debugging tool, which you should always have on.
|
||||
内容日志是至关重要的调试工具,建议始终保持开启:
|
||||
|
||||
Turn on both content log settings in `settings > creator`. This will show you any errors in your add-on when you enter a world with it applied. You can open the content log GUI in-game by pressing `ctrl+h` or by pressing `Content Log History` in the creator settings panel. Learn more about the content log [here](/guide/troubleshooting).
|
||||
1. 在`设置 > 创作者`中启用全部内容日志选项
|
||||
2. 应用附加包进入世界后,任何错误都会显示在日志中
|
||||
3. 游戏内按`ctrl+h`或通过创作者设置面板打开日志界面
|
||||
|
||||
## Creating your testing world
|
||||
了解更多内容日志信息请访问[问题排查指南](/wiki/guide/troubleshooting)。
|
||||
|
||||
Now we create a world to test your new add-on!
|
||||
## 创建测试世界
|
||||
|
||||
1. Click "**Create new world**";
|
||||
|
||||
2. Ensure that the following settings are set.
|
||||
现在让我们创建测试世界:
|
||||
|
||||
1. 点击"**创建新世界**"
|
||||
2. 确保以下设置:
|
||||

|
||||

|
||||
|
||||
3. Now activate your behavior pack, and your resource pack. You can do this by selecting the packs, and clicking 'apply'.
|
||||
|
||||
4. Now click '**Create**'!
|
||||
3. 激活行为包和资源包(选中后点击'应用')
|
||||
4. 点击"**创建**"!
|
||||
|
||||
---
|
||||
|
||||
## Your progress so far
|
||||
## 当前进度
|
||||
|
||||
**Here is how your project should look, after completing this page:**
|
||||
**完成本页面后的项目结构:**
|
||||
|
||||
Remember that in future, we will represent `com.mojang/development_behavior_packs/guide_RP/` as `RP`, and `com.mojang/development_behavior_packs/guide_BP/` as `BP`.
|
||||
后续指南中将使用简写:
|
||||
- `com.mojang/development_behavior_packs/guide_RP/` 简写为 `RP`
|
||||
- `com.mojang/development_behavior_packs/guide_BP/` 简写为 `BP`
|
||||
|
||||
<FolderView :paths="[
|
||||
'com.mojang/development_resource_packs/guide_RP/manifest.json',
|
||||
@@ -275,26 +277,26 @@ Remember that in future, we will represent `com.mojang/development_behavior_pack
|
||||
'com.mojang/development_behavior_packs/guide_BP/texts/languages.json',
|
||||
]"></FolderView>
|
||||
|
||||
## What you have learned
|
||||
## 知识总结
|
||||
|
||||
:::tip What you have learned:
|
||||
:::tip 已掌握内容:
|
||||
|
||||
- What the com.mojang folder is, where it is and what folders it contains
|
||||
- How to setup your workspace
|
||||
- What a `manifest.json` file is
|
||||
- How to use UUIDs
|
||||
- How to create an icon for your addon
|
||||
- What a `.lang` file is
|
||||
- com.mojang文件夹的作用与位置
|
||||
- 工作区设置方法
|
||||
- manifest.json文件的作用
|
||||
- UUID的使用规范
|
||||
- 附加包图标创建
|
||||
- .lang文件的作用
|
||||
|
||||
:::
|
||||
|
||||
## Your progress so far
|
||||
## 进度追踪
|
||||
|
||||
<Checklist>
|
||||
|
||||
- [x] Setup your pack
|
||||
- [ ] Create a custom item
|
||||
- [ ] Create a custom entity
|
||||
- [ ] Create the entity's loot, spawn rules and a custom recipe
|
||||
- [x] 完成基础设置
|
||||
- [ ] 创建自定义物品
|
||||
- [ ] 创建自定义实体
|
||||
- [ ] 配置实体战利品、生成规则与合成配方
|
||||
|
||||
</Checklist>
|
||||
</Checklist>
|
||||
Reference in New Issue
Block a user