tutorial:containers
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:containers [2020/02/27 13:46] – typo mkpoli | tutorial:containers [2020/02/27 16:34] – adjusment mkpoli | ||
---|---|---|---|
Line 3: | Line 3: | ||
==== Block and BlockItem ==== | ==== Block and BlockItem ==== | ||
- | First we need to create Block and register it as well as its BlockItem. | + | First we need to create |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 84: | Line 84: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | You may refer to other tutorials to modify the appearance and other properties of the Block by adding models or adjusting rendering later. | ||
==== BlockEntity ==== | ==== BlockEntity ==== | ||
- | BlockEntities are used for managing container inventories. Actually, it implements Inventory interface. | + | BlockEntity is used for managing container inventories. Actually, it implements Inventory interface. It is required to save and load the inventory. |
<code java [enable_line_numbers=" | <code java [enable_line_numbers=" | ||
Line 252: | Line 254: | ||
[...] | [...] | ||
ContainerProviderRegistry.INSTANCE.registerFactory(BIGGER_CHEST, | ContainerProviderRegistry.INSTANCE.registerFactory(BIGGER_CHEST, | ||
- | final BlockEntity blockEntity | + | final World world = player.world; |
- | return((BiggerChestBlockEntity) blockEntity).createContainer(syncId, player.inventory); | + | final BlockPos pos = buf.readBlockPos(); |
+ | return | ||
}); | }); | ||
} | } | ||
Line 265: | Line 268: | ||
</ | </ | ||
- | ==== Orgnizing | + | ==== Organizing |
After all the steps, you should have your ExampleMod Class and ExampleClientMod Class as such: | After all the steps, you should have your ExampleMod Class and ExampleClientMod Class as such: | ||
tutorial/containers.txt · Last modified: 2022/05/27 15:57 by solidblock