Interface MenuSyncedBlockEntity
- All Superinterfaces:
net.minecraft.world.inventory.MenuConstructor
,net.minecraft.world.MenuProvider
public interface MenuSyncedBlockEntity
extends net.minecraft.world.MenuProvider
Implement this in you block entity when it should synchronize initial values when a player opens the container
-
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.inventory.AbstractContainerMenu
createMenu
(int containerId, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.world.entity.player.Player player) Used to create a menu on the server sidevoid
handleInitialMenuDataFromServer
(net.minecraft.network.FriendlyByteBuf byteBuf) The collected data for the initial menu opening is received here on the client side.void
sendInitialMenuDataToClient
(net.minecraft.network.FriendlyByteBuf byteBuf) Collect data here that should be sent to the client side when the menu will be opened.Methods inherited from interface net.minecraft.world.MenuProvider
getDisplayName
-
Method Details
-
sendInitialMenuDataToClient
void sendInitialMenuDataToClient(net.minecraft.network.FriendlyByteBuf byteBuf) Collect data here that should be sent to the client side when the menu will be opened. The method will only be called automatically ifEntityBlockProvider.openMenu(net.minecraft.world.level.Level, net.minecraft.core.BlockPos, Player, boolean)
is used for opening the menu.
The data will be received on the client side in this method:handleInitialMenuDataFromServer(FriendlyByteBuf)
- Parameters:
byteBuf
- Data to be send to the client
-
handleInitialMenuDataFromServer
void handleInitialMenuDataFromServer(net.minecraft.network.FriendlyByteBuf byteBuf) The collected data for the initial menu opening is received here on the client side. The method will only be called ifUBlockEntityContainerMenu
is used as a base class for the menu or an equivalent implementation is used.
The data is sent from the server side here:sendInitialMenuDataToClient(FriendlyByteBuf)
- Parameters:
byteBuf
- Received data from the server
-
createMenu
net.minecraft.world.inventory.AbstractContainerMenu createMenu(int containerId, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.world.entity.player.Player player) Used to create a menu on the server side- Specified by:
createMenu
in interfacenet.minecraft.world.inventory.MenuConstructor
-