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:06] – [Registering your BlockEntity] solidblock | tutorial:blockentity [2022/12/16 02:14] – [Registering your BlockEntity] solidblock | ||
---|---|---|---|
Line 17: | Line 17: | ||
</ | </ | ||
- | Below will show you how to create | + | Please ensure that the constructor only takes the two parameters, otherwise the method reference '' |
You can simply add variables to this barebone class or implement interfaces such as '' | You can simply add variables to this barebone class or implement interfaces such as '' | ||
Line 23: | Line 23: | ||
===== Registering your BlockEntity ===== | ===== Registering your BlockEntity ===== | ||
- | Once you have created the '' | + | Once you have created the '' |
- | The '' | + | The '' |
<code java> | <code java> | ||
public static final BlockEntityType< | public static final BlockEntityType< | ||
- | | + | |
new Identifier(" | new Identifier(" | ||
FabricBlockEntityTypeBuilder.create(DemoBlockEntity:: | FabricBlockEntityTypeBuilder.create(DemoBlockEntity:: | ||
Line 35: | Line 35: | ||
</ | </ | ||
- | The block entity | + | The block entity |
==== Connecting a Block Entity to a Block ==== | ==== Connecting a Block Entity to a Block ==== | ||
Line 57: | Line 57: | ||
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 117: | Line 117: | ||
===== Block Entity Ticking ===== | ===== Block Entity Ticking ===== | ||
- | 1.17 has added static ticking, where before you'd implement the '' | + | 1.17 has added static ticking, where before you'd implement the '' |
Line 133: | Line 133: | ||
return checkType(type, | return checkType(type, | ||
} | } | ||
+ | } | ||
</ | </ | ||
- | And in your '' | + | And in your '' |
<code java> | <code java> | ||
public class DemoBlockEntity extends BlockEntity { | public class DemoBlockEntity extends BlockEntity { |
tutorial/blockentity.txt · Last modified: 2023/09/20 19:18 by haykam