diff --git a/docs/blockentities/container.md b/docs/blockentities/container.md index c8e59085..4b07dda7 100644 --- a/docs/blockentities/container.md +++ b/docs/blockentities/container.md @@ -259,7 +259,7 @@ public class MyBackpackContainer extends SimpleContainer { And voilĂ , you have created an item-backed container! Call `new MyBackpackContainer(stack)` to create a container for a menu or other use case. :::warning -Be aware that `Menu`s that directly interface with `Container`s must `#copy()` their `ItemStack`s when modifying them, as otherwise the immutability contract on data components is broken. To do this, NeoForge provides the `StackCopySlot` class for you. +Be aware that menus that directly interface with `Container`s must `#copy()` their `ItemStack`s when modifying them, as otherwise the immutability contract on data components is broken. To do this, NeoForge provides the `StackCopySlot` class for you. ::: ## `Container`s on `Entity`s diff --git a/docs/blockentities/index.md b/docs/blockentities/index.md index 5e1ff510..66fe2b0f 100644 --- a/docs/blockentities/index.md +++ b/docs/blockentities/index.md @@ -30,16 +30,14 @@ public static final DeferredRegister> BLOCK_ENTITY_TYPES = public static final Supplier> MY_BLOCK_ENTITY = BLOCK_ENTITY_TYPES.register( "my_block_entity", - // The block entity type, created using a builder. - () -> BlockEntityType.Builder.of( + // The block entity type. + () -> new BlockEntityType<>( // The supplier to use for constructing the block entity instances. MyBlockEntity::new, // A vararg of blocks that can have this block entity. // This assumes the existence of the referenced blocks as DeferredBlocks. MyBlocks.MY_BLOCK_1.get(), MyBlocks.MY_BLOCK_2.get() ) - // Build using null; vanilla does some datafixer shenanigans with the parameter that we don't need. - .build(null) ); ``` @@ -54,7 +52,7 @@ public class MyBlockEntity extends BlockEntity { ``` :::info -The reason for this rather confusing setup process is that `BlockEntityType.Builder#of` expects a `BlockEntityType.BlockEntitySupplier`, which is basically a `BiFunction`. As such, having a constructor we can directly reference using `::new` is highly beneficial. However, we also need to provide the constructed block entity type to the default and only constructor of `BlockEntity`, so we need to pass references around a bit. +The reason for this rather confusing setup process is that `BlockEntityType` expects a `BlockEntityType.BlockEntitySupplier`, which is basically a `BiFunction`. As such, having a constructor we can directly reference using `::new` is highly beneficial. However, we also need to provide the constructed block entity type to the default and only constructor of `BlockEntity`, so we need to pass references around a bit. ::: Finally, we need to modify the block class associated with the block entity. This means that we will not be able to attach block entities to simple instances of `Block`, instead, we need a subclass: @@ -75,7 +73,7 @@ public class MyEntityBlock extends Block implements EntityBlock { } ``` -And then, you of course need to use this class as the type in your block registration: +And then, you of course need to use this class as the type in your [block registration][blockreg]: ```java public static final DeferredBlock MY_BLOCK_1 = @@ -232,6 +230,7 @@ It is important that you do safety checks, as the `BlockEntity` might already be ::: [block]: ../blocks/index.md +[blockreg]: ../blocks/index.md#basic-blocks [blockstate]: ../blocks/states.md [dataattachments]: ../datastorage/attachments.md [nbt]: ../datastorage/nbt.md