Class ChestStateManager

java.lang.Object
net.minecraft.block.entity.ChestStateManager

public abstract class ChestStateManager
extends Object
Handles the viewer count for chest-like block entities.
  • Field Details

    • viewerCount

      private int viewerCount
  • Constructor Details

    • ChestStateManager

      public ChestStateManager()
  • Method Details

    • onChestOpened

      protected abstract void onChestOpened​(World world, BlockPos pos, BlockState state)
      Run when this chest is opened (when the viewer count becomes nonzero).
    • onChestClosed

      protected abstract void onChestClosed​(World world, BlockPos pos, BlockState state)
      Run when this chest closes (when the viewer count reaches zero).
    • onInteracted

      protected abstract void onInteracted​(World world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount)
      Run when a player interacts with this chest.
    • isPlayerViewing

      protected abstract boolean isPlayerViewing​(PlayerEntity player)
      Determines whether the given player is currently viewing this chest.
    • openChest

      public void openChest​(PlayerEntity playerEntity, World world, BlockPos blockPos, BlockState blockState)
    • closeChest

      public void closeChest​(PlayerEntity playerEntity, World world, BlockPos blockPos, BlockState blockState)
    • getInRangeViewerCount

      private int getInRangeViewerCount​(World world, BlockPos pos)
    • updateViewerCount

      public void updateViewerCount​(World world, BlockPos pos, BlockState state)
    • getViewerCount

      public int getViewerCount()
    • scheduleBlockTick

      private static void scheduleBlockTick​(World world, BlockPos pos, BlockState state)