Class ScreenHandler

java.lang.Object
net.minecraft.screen.ScreenHandler
Direct Known Subclasses:
AbstractRecipeScreenHandler, BeaconScreenHandler, BrewingStandScreenHandler, CartographyTableScreenHandler, CreativeInventoryScreen.CreativeScreenHandler, EnchantmentScreenHandler, ForgingScreenHandler, Generic3x3ContainerScreenHandler, GenericContainerScreenHandler, GrindstoneScreenHandler, HopperScreenHandler, HorseScreenHandler, LecternScreenHandler, LoomScreenHandler, MerchantScreenHandler, ShulkerBoxScreenHandler, StonecutterScreenHandler

public abstract class ScreenHandler
extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • canUse

      protected static boolean canUse​(ScreenHandlerContext context, PlayerEntity player, Block block)
    • getType

      public ScreenHandlerType<?> getType()
    • checkSize

      protected static void checkSize​(Inventory inventory, int expectedSize)
      Checks that the size of the provided inventory is at least as large as the expectedSize.
      Throws:
      IllegalArgumentException - if the inventory size is smaller than expectedSize
    • checkDataCount

      protected static void checkDataCount​(PropertyDelegate data, int expectedCount)
      Checks that the size of the data is at least as large as the expectedCount.
      Throws:
      IllegalArgumentException - if the data has a smaller size than expectedCount
    • addSlot

      protected Slot addSlot​(Slot slot)
    • addProperty

      protected Property addProperty​(Property property)
    • addProperties

      protected void addProperties​(PropertyDelegate propertyDelegate)
    • addListener

      public void addListener​(ScreenHandlerListener listener)
    • removeListener

      @Environment(CLIENT) public void removeListener​(ScreenHandlerListener listener)
    • getStacks

      public DefaultedList<ItemStack> getStacks()
    • sendContentUpdates

      public void sendContentUpdates()
      Sends updates to listeners if any properties or slot stacks have changed.
    • onButtonClick

      public boolean onButtonClick​(PlayerEntity player, int id)
    • getSlot

      public Slot getSlot​(int index)
    • transferSlot

      public ItemStack transferSlot​(PlayerEntity player, int index)
    • onSlotClick

      public ItemStack onSlotClick​(int int2, int int3, SlotActionType actionType, PlayerEntity playerEntity)
      Performs a slot click. This can behave in many different ways depending mainly on the action type.
      Parameters:
      actionType - The type of slot click. Check the docs for each SlotActionType value for details
      Returns:
      The stack that was clicked on before anything changed, used mostly for verifying that the client and server are in sync
    • method_30010

      private ItemStack method_30010​(int int2, int int3, SlotActionType slotActionType, PlayerEntity playerEntity)
    • canStacksCombine

      public static boolean canStacksCombine​(ItemStack first, ItemStack second)
    • canInsertIntoSlot

      public boolean canInsertIntoSlot​(ItemStack stack, Slot slot)
    • close

      public void close​(PlayerEntity player)
    • dropInventory

      protected void dropInventory​(PlayerEntity player, World world, Inventory inventory)
    • onContentChanged

      public void onContentChanged​(Inventory inventory)
    • setStackInSlot

      public void setStackInSlot​(int slot, ItemStack stack)
    • updateSlotStacks

      @Environment(CLIENT) public void updateSlotStacks​(List<ItemStack> stacks)
    • setProperty

      public void setProperty​(int id, int value)
    • getNextActionId

      @Environment(CLIENT) public short getNextActionId​(PlayerInventory playerInventory)
    • isNotRestricted

      public boolean isNotRestricted​(PlayerEntity player)
    • setPlayerRestriction

      public void setPlayerRestriction​(PlayerEntity player, boolean unrestricted)
    • canUse

      public abstract boolean canUse​(PlayerEntity player)
    • insertItem

      protected boolean insertItem​(ItemStack stack, int startIndex, int endIndex, boolean fromLast)
    • unpackQuickCraftButton

      public static int unpackQuickCraftButton​(int quickCraftData)
    • unpackQuickCraftStage

      public static int unpackQuickCraftStage​(int quickCraftData)
    • packQuickCraftData

      @Environment(CLIENT) public static int packQuickCraftData​(int quickCraftStage, int buttonId)
    • shouldQuickCraftContinue

      public static boolean shouldQuickCraftContinue​(int stage, PlayerEntity player)
    • endQuickCraft

      protected void endQuickCraft()
    • canInsertItemIntoSlot

      public static boolean canInsertItemIntoSlot​(@Nullable Slot slot, ItemStack stack, boolean allowOverflow)
    • calculateStackSize

      public static void calculateStackSize​(Set<Slot> slots, int mode, ItemStack stack, int stackSize)
    • canInsertIntoSlot

      public boolean canInsertIntoSlot​(Slot slot)
    • calculateComparatorOutput

      public static int calculateComparatorOutput​(@Nullable BlockEntity entity)
    • calculateComparatorOutput

      public static int calculateComparatorOutput​(@Nullable Inventory inventory)