Package net.minecraft.block.entity
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 Summary
Fields Modifier and Type Field Description private intviewerCount -
Constructor Summary
Constructors Constructor Description ChestStateManager() -
Method Summary
Modifier and Type Method Description voidcloseChest(PlayerEntity playerEntity, World world, BlockPos blockPos, BlockState blockState)private intgetInRangeViewerCount(World world, BlockPos pos)intgetViewerCount()protected abstract booleanisPlayerViewing(PlayerEntity player)Determines whether the given player is currently viewing this chest.protected abstract voidonChestClosed(World world, BlockPos pos, BlockState state)Run when this chest closes (when the viewer count reaches zero).protected abstract voidonChestOpened(World world, BlockPos pos, BlockState state)Run when this chest is opened (when the viewer count becomes nonzero).protected abstract voidonInteracted(World world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount)Run when a player interacts with this chest.voidopenChest(PlayerEntity playerEntity, World world, BlockPos blockPos, BlockState blockState)private static voidscheduleBlockTick(World world, BlockPos pos, BlockState state)voidupdateViewerCount(World world, BlockPos pos, BlockState state)
-
Field Details
-
viewerCount
private int viewerCount
-
-
Constructor Details
-
ChestStateManager
public ChestStateManager()
-
-
Method Details
-
onChestOpened
Run when this chest is opened (when the viewer count becomes nonzero). -
onChestClosed
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
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
-
updateViewerCount
-
getViewerCount
public int getViewerCount() -
scheduleBlockTick
-