Class ItemInventoryContainer<I extends net.minecraft.world.item.Item>

java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
org.cyclops.cyclopscore.inventory.container.ContainerExtended
org.cyclops.cyclopscore.inventory.container.ItemInventoryContainer<I>
Type Parameters:
I - The item instance.
All Implemented Interfaces:
IContainerButtonClickAcceptorServer<ContainerExtended>, IValueNotifiable, IValueNotifier

public abstract class ItemInventoryContainer<I extends net.minecraft.world.item.Item> extends ContainerExtended
A container for an item. Implementations of this class will typically have two constructors, which will look something like this:
     // Called by the client-side screen factory
     public MyContainer(int id, PlayerInventory inventory, FriendlyByteBuf packetBuffer) {
         this(id, inventory, readItemIndex(packetBuffer), readHand(packetBuffer));
     }

     // Called by the server-side container provider
     public MyContainer(int id, PlayerInventory inventory, int itemIndex, Hand hand) {
         super(RegistryEntries.CONTAINER_MY, id, inventory, itemIndex, hand);
     }
 
  • Field Details

    • item

      protected I extends net.minecraft.world.item.Item item
    • itemLocation

      protected ItemLocation itemLocation
  • Constructor Details

    • ItemInventoryContainer

      public ItemInventoryContainer(@Nullable net.minecraft.world.inventory.MenuType<?> type, int id, net.minecraft.world.entity.player.Inventory inventory, ItemLocation itemLocation)
      Make a new instance.
      Parameters:
      type - The container type.
      id - The container id.
      inventory - The player inventory.
      itemLocation - The item location.
  • Method Details

    • readItemIndex

      public static int readItemIndex(net.minecraft.network.FriendlyByteBuf packetBuffer)
    • readHand

      public static net.minecraft.world.InteractionHand readHand(net.minecraft.network.FriendlyByteBuf packetBuffer)
    • getItem

      public I getItem()
      Get the item instance.
      Returns:
      The item.
    • stillValid

      public boolean stillValid(net.minecraft.world.entity.player.Player player)
      Specified by:
      stillValid in class net.minecraft.world.inventory.AbstractContainerMenu
    • getItemStack

      public net.minecraft.world.item.ItemStack getItemStack(net.minecraft.world.entity.player.Player player)
    • createNewSlot

      protected net.minecraft.world.inventory.Slot createNewSlot(net.minecraft.world.Container inventory, int index, int x, int y)
      Overrides:
      createNewSlot in class ContainerExtended
    • clicked

      public void clicked(int slotId, int arg, net.minecraft.world.inventory.ClickType clickType, net.minecraft.world.entity.player.Player player)
      Overrides:
      clicked in class ContainerExtended