zh_cn:tutorial:blockentity
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| zh_cn:tutorial:blockentity [2024/10/27 15:00] – 更新 solidblock | zh_cn:tutorial:blockentity [2025/04/01 12:20] (current) – [方块实体刻] solidblock | ||
|---|---|---|---|
| Line 30: | Line 30: | ||
| [...] | [...] | ||
| | | ||
| - | public static final DemoBlock DEMO_BLOCK = register(" | + | |
| + | // public static final DemoBlock DEMO_BLOCK = register(" | ||
| + | |||
| + | // 对于 1.21.2 及之后的版本 | ||
| + | public static final DemoBlock DEMO_BLOCK = register(" | ||
| | | ||
| [...] | [...] | ||
| Line 44: | Line 48: | ||
| public static final BlockEntityType< | public static final BlockEntityType< | ||
| " | " | ||
| - | // 对于 1.21.2 | + | |
| - | // 请将 `BlockEntityType.Builder` 替换为 `FabricBlockEntityTypeBuilder`。 | + | |
| - | | + | |
| ); | ); | ||
| | | ||
| Line 71: | Line 75: | ||
| 对于旧版本,如果无法访问 '' | 对于旧版本,如果无法访问 '' | ||
| - | 这个方块实体类型定义了只有 '' | + | 这个方块实体类型定义了只有 '' |
| > **注意:**和其他方块一样,这个方块也需要方块模型和物品模型,可能也需要战利品表,关于如何创建请参见 [[blocks]]。对于战利品表,有[[blockentity_sync_itemstac|后续教程]]会提到如何改进战利品表表以包含方块实体数据。 | > **注意:**和其他方块一样,这个方块也需要方块模型和物品模型,可能也需要战利品表,关于如何创建请参见 [[blocks]]。对于战利品表,有[[blockentity_sync_itemstac|后续教程]]会提到如何改进战利品表表以包含方块实体数据。 | ||
| Line 121: | Line 125: | ||
| 在你的 '' | 在你的 '' | ||
| <code java DemoBlockEntity.java> | <code java DemoBlockEntity.java> | ||
| - | public class DemoBlockEntity extends BlockEntity { | + | public class DemoBlockEntity extends BlockEntity |
| [...] | [...] | ||
| | | ||
| - | public static void tick(World world, BlockPos pos, BlockState state, DemoBlockEntity | + | |
| + | | ||
| [...] | [...] | ||
| } | } | ||
zh_cn/tutorial/blockentity.1730041252.txt.gz · Last modified: 2024/10/27 15:00 by solidblock