tutorial:blockentity
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorial:blockentity [2024/08/26 08:11] – [Connecting the block entity and the block] solidblock | tutorial:blockentity [2025/12/05 16:43] (current) – redirect to docs cassiancc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ~~REDIRECT> | ||
| + | |||
| ====== Adding a BlockEntity ====== | ====== Adding a BlockEntity ====== | ||
| Line 29: | Line 31: | ||
| [...] | [...] | ||
| | | ||
| - | public static final DemoBlock DEMO_BLOCK = register(" | + | |
| + | // public static final DemoBlock DEMO_BLOCK = register(" | ||
| + | |||
| + | // For version 1.21.2 and later | ||
| + | public static final DemoBlock DEMO_BLOCK = register(" | ||
| | | ||
| [...] | [...] | ||
| Line 43: | Line 49: | ||
| public static final BlockEntityType< | public static final BlockEntityType< | ||
| " | " | ||
| - | BlockEntityType.Builder.create(DemoBlockEntity:: | + | |
| + | FabricBlockEntityTypeBuilder.create(DemoBlockEntity:: | ||
| ); | ); | ||
| | | ||
| Line 68: | Line 75: | ||
| For old versions, if you cannot access '' | For old versions, if you cannot access '' | ||
| - | The block entity type defines that only the '' | + | The block entity type defines that only the '' |
| > **Note:** Like other blocks, the block also needs a block model and an item model, and may also need a loot table, see [[blocks]] for how to create them. As for loot tables, [[blockentity_sync_itemstack|subsequent tutorials]] will cover how to improve the loot tables to include block entity data. | > **Note:** Like other blocks, the block also needs a block model and an item model, and may also need a loot table, see [[blocks]] for how to create them. As for loot tables, [[blockentity_sync_itemstack|subsequent tutorials]] will cover how to improve the loot tables to include block entity data. | ||
| Line 118: | Line 125: | ||
| And in your '' | And in your '' | ||
| <code java DemoBlockEntity.java> | <code java DemoBlockEntity.java> | ||
| - | public class DemoBlockEntity extends BlockEntity { | + | public class DemoBlockEntity extends BlockEntity |
| [...] | [...] | ||
| | | ||
tutorial/blockentity.1724659918.txt.gz · Last modified: 2024/08/26 08:11 by solidblock