Class UBlockEntityContainerMenu<T extends net.minecraft.world.level.block.entity.BlockEntity>

java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu

public abstract class UBlockEntityContainerMenu<T extends net.minecraft.world.level.block.entity.BlockEntity> extends UContainerMenu
  • Field Details

    • playerInventory

      protected final net.minecraft.world.entity.player.Inventory playerInventory
    • blockEntity

      protected final T extends net.minecraft.world.level.block.entity.BlockEntity blockEntity
  • Constructor Details

    • UBlockEntityContainerMenu

      public UBlockEntityContainerMenu(net.minecraft.world.inventory.MenuType<?> menuType, int containerId, net.minecraft.world.entity.player.Inventory playerInventory, T blockEntity)
      This is the server constructor. The method init(LogicalSide) is called.
      Parameters:
      menuType - Menu type
      containerId - Container id
      playerInventory - Player inventory
      blockEntity - Block entity
    • UBlockEntityContainerMenu

      public UBlockEntityContainerMenu(net.minecraft.world.inventory.MenuType<?> menuType, int containerId, net.minecraft.world.entity.player.Inventory playerInventory, T blockEntity, boolean callInit)
      This is the server constructor.
      Parameters:
      menuType - Menu type
      containerId - Container id
      playerInventory - Player inventory
      blockEntity - Block entity
      callInit - If the constructor should call init(LogicalSide)
    • UBlockEntityContainerMenu

      public UBlockEntityContainerMenu(net.minecraft.world.inventory.MenuType<?> menuType, int containerId, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.network.FriendlyByteBuf byteBuf)
      This is the client constructor. This methods reads the block entity pos from the supplied FriendlyByteBuf and tries to get the block entity at the client side. The block pos must be the first entry in the buffer! The method init(LogicalSide) is called.
      Parameters:
      menuType - Menu type
      containerId - Container id
      playerInventory - Player inventory
      byteBuf - Initial menu data (specified with NetworkHooks.openScreen(net.minecraft.server.level.ServerPlayer, net.minecraft.world.MenuProvider, java.util.function.Consumer))
    • UBlockEntityContainerMenu

      public UBlockEntityContainerMenu(net.minecraft.world.inventory.MenuType<?> menuType, int containerId, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.network.FriendlyByteBuf byteBuf, boolean callInit)
      This is the client constructor. This methods reads the block entity pos from the supplied FriendlyByteBuf and tries to get the block entity at the client side. The block pos must be the first entry in the buffer!
      Parameters:
      menuType - Menu type
      containerId - Container id
      playerInventory - Player inventory
      byteBuf - Initial menu data (specified with NetworkHooks.openScreen(net.minecraft.server.level.ServerPlayer, net.minecraft.world.MenuProvider, java.util.function.Consumer))
      callInit - If the constructor should call init(LogicalSide)
  • Method Details

    • init

      protected abstract void init(net.minecraftforge.fml.LogicalSide side)
      Is called after the server and client constructor. If you want to use your own fields in the init method, set the last constructor boolean to false and then call this method in all constructors of the implementing class.
      Parameters:
      side - Logical side this method is called on
    • getBlockEntity

      public T getBlockEntity()
      Gets the block entity
      Returns:
      Block entity associated with this menu