Changes

524 bytes removed ,  18:01, 20 September 2022
no edit summary
Line 4: Line 4:     
== Creating a <code>BlockEntity</code> ==
 
== Creating a <code>BlockEntity</code> ==
  −
In order to create a <code>BlockEntity</code> you need to extend the <code>BlockEntity</code> class. To register it, listen for the appropriate registry event and create a <code>BlockEntityType</code>:
  −
<syntaxhighlight lang="java">
  −
@SubscribeEvent
  −
public static void registerTE(RegistryEvent.Register<BlockEntityType<?>> evt) {
  −
  BlockEntityType<?> type = BlockEntityType.Builder.of(supplier, validBlocks).build(null);
  −
  type.setRegistryName("examplemod", "mybe");
  −
  evt.getRegistry().register(type);
  −
}
  −
</syntaxhighlight>
   
You can also use a <code>DeferredRegister</code> instead.
 
You can also use a <code>DeferredRegister</code> instead.
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
11

edits