Class ChiseledBookShelfBlockEntity

All Implemented Interfaces:
Clearable, Container, IAttachmentHolder, IBlockEntityExtension

public class ChiseledBookShelfBlockEntity extends BlockEntity implements Container
  • Field Details

    • MAX_BOOKS_IN_STORAGE

      public static final int MAX_BOOKS_IN_STORAGE
      See Also:
    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • items

      private final NonNullList<ItemStack> items
    • lastInteractedSlot

      private int lastInteractedSlot
  • Constructor Details

    • ChiseledBookShelfBlockEntity

      public ChiseledBookShelfBlockEntity(BlockPos pos, BlockState state)
  • Method Details

    • updateState

      private void updateState(int slot)
    • loadAdditional

      protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries)
      Overrides:
      loadAdditional in class BlockEntity
    • saveAdditional

      protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries)
      Overrides:
      saveAdditional in class BlockEntity
    • count

      public int count()
    • clearContent

      public void clearContent()
      Specified by:
      clearContent in interface Clearable
    • getContainerSize

      public int getContainerSize()
      Specified by:
      getContainerSize in interface Container
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Container
    • getItem

      public ItemStack getItem(int slot)
      Returns the stack in the given slot.
      Specified by:
      getItem in interface Container
    • removeItem

      public ItemStack removeItem(int slot, int amount)
      Removes up to a specified number of items from an inventory slot and returns them in a new stack.
      Specified by:
      removeItem in interface Container
    • removeItemNoUpdate

      public ItemStack removeItemNoUpdate(int slot)
      Removes a stack from the given slot and returns it.
      Specified by:
      removeItemNoUpdate in interface Container
    • setItem

      public void setItem(int slot, ItemStack stack)
      Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
      Specified by:
      setItem in interface Container
    • canTakeItem

      public boolean canTakeItem(Container target, int slot, ItemStack stack)
      Returns true if the given stack can be extracted into the target inventory.
      Specified by:
      canTakeItem in interface Container
      Parameters:
      target - the container into which the item should be extracted
      slot - the slot from which to extract the item
      stack - the item to extract
      Returns:
      true if the given stack can be extracted into the target inventory
    • getMaxStackSize

      public int getMaxStackSize()
      Specified by:
      getMaxStackSize in interface Container
    • stillValid

      public boolean stillValid(Player player)
      Don't rename this method to canInteractWith due to conflicts with Container
      Specified by:
      stillValid in interface Container
    • canPlaceItem

      public boolean canPlaceItem(int slot, ItemStack stack)
      Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For guis use Slot.isItemValid
      Specified by:
      canPlaceItem in interface Container
    • getLastInteractedSlot

      public int getLastInteractedSlot()
    • applyImplicitComponents

      protected void applyImplicitComponents(BlockEntity.DataComponentInput componentInput)
      Overrides:
      applyImplicitComponents in class BlockEntity
    • collectImplicitComponents

      protected void collectImplicitComponents(DataComponentMap.Builder components)
      Overrides:
      collectImplicitComponents in class BlockEntity
    • removeComponentsFromTag

      public void removeComponentsFromTag(CompoundTag tag)
      Overrides:
      removeComponentsFromTag in class BlockEntity