tutorial:blockentity
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:blockentity [2022/08/08 04:13] – [Registering your BlockEntity] solidblock | tutorial:blockentity [2024/06/13 08:47] – update deprecated BlockEntity method s1lverposting | ||
---|---|---|---|
Line 3: | Line 3: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | A BlockEntity is primarily used to store data within blocks. Before creating one, you will need a [[tutorial: | + | A BlockEntity is primarily used to store data within blocks. Before creating one, you will need a [[tutorial: |
===== Creating a BlockEntity ===== | ===== Creating a BlockEntity ===== | ||
Line 19: | Line 19: | ||
Please ensure that the constructor only takes the two parameters, otherwise the method reference '' | Please ensure that the constructor only takes the two parameters, otherwise the method reference '' | ||
- | You can simply add variables | + | Block entities support a variety of methods |
===== Registering your BlockEntity ===== | ===== Registering your BlockEntity ===== | ||
Line 29: | Line 28: | ||
<code java> | <code java> | ||
public static final BlockEntityType< | public static final BlockEntityType< | ||
- | | + | |
new Identifier(" | new Identifier(" | ||
- | | + | |
); | ); | ||
</ | </ | ||
Line 57: | Line 56: | ||
If you want to store any data in your '' | If you want to store any data in your '' | ||
- | '' | + | '' |
Knowing this, the example below demonstrates saving an integer from your '' | Knowing this, the example below demonstrates saving an integer from your '' | ||
Line 94: | Line 93: | ||
</ | </ | ||
- | Once you have implemented the '' | + | Once you have implemented the '' |
===== Sync data from server to client ===== | ===== Sync data from server to client ===== | ||
- | The data is read in the server world usually. Most data are not needed by the client, for example, your client does not need to know what's in the chest or furnace, until you open the GUI. But for some block entities, such as signs and banners, you have to inform the client of the data of the block entity, for example, for renderering. | + | The data is read in the server world usually. Most data are not needed by the client, for example, your client does not need to know what's in the chest or furnace, until you open the GUI. But for some block entities, such as signs and banners, you have to inform the client of the data of the block entity, for example, for rendering. |
For version 1.17.1 and below, implement '' | For version 1.17.1 and below, implement '' |
tutorial/blockentity.txt · Last modified: 2024/06/13 08:56 by s1lverposting