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 pPos, BlockState pState)
  • Method Details

    • updateState

      private void updateState(int pSlot)
    • loadAdditional

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

      protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries)
      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 pSlot)
      Returns the stack in the given slot.
      Specified by:
      getItem in interface Container
    • removeItem

      public ItemStack removeItem(int pSlot, int pAmount)
      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 pSlot)
      Removes a stack from the given slot and returns it.
      Specified by:
      removeItemNoUpdate in interface Container
    • setItem

      public void setItem(int pSlot, ItemStack pStack)
      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 pTarget, int pSlot, ItemStack pStack)
      Returns true if the given stack can be extracted into the target inventory.
      Specified by:
      canTakeItem in interface Container
      Parameters:
      pTarget - the container into which the item should be extracted
      pSlot - the slot from which to extract the item
      pStack - 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 pPlayer)
      Don't rename this method to canInteractWith due to conflicts with Container
      Specified by:
      stillValid in interface Container
    • canPlaceItem

      public boolean canPlaceItem(int pSlot, ItemStack pStack)
      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 pComponentInput)
      Overrides:
      applyImplicitComponents in class BlockEntity
    • collectImplicitComponents

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

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