User Tools

Site Tools


tutorial:blockentity

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:blockentity [2020/02/09 12:46]
juuz mapping update
tutorial:blockentity [2020/03/30 20:43] (current)
draylar
Line 36: Line 36:
 </​code>​ </​code>​
  
-Once your ''​BlockEntityType''​ has been created and registered ​as seen above, you can simply implement ​''​BlockEntityProvider'' ​in your ''​Block'' ​class:+==== Connecting a Block Entity to a Block ==== 
 + 
 +Once your ''​BlockEntityType''​ has been created and registered, you'll need a block that is associated with it. You can do this by implementing ​''​BlockEntityProvider'' ​and overriding ​''​createBlockEntity''​. Each time your block is placed, your Block Entity will spawn alongside it.
  
 <code java> <code java>
-@Override +public class MyBlock extends Block implements BlockEntityProvider { 
-public BlockEntity createBlockEntity(BlockView blockView) { + 
-   ​return new DemoBlockEntity();​+   ​[...] 
 + 
 +   @Override 
 +   ​public BlockEntity createBlockEntity(BlockView blockView) { 
 +      return new DemoBlockEntity();​ 
 +   }
 } }
 </​code>​ </​code>​
tutorial/blockentity.1581252366.txt.gz · Last modified: 2020/02/09 12:46 by juuz