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 int
viewerCount
-
Constructor Summary
Constructors Constructor Description ChestStateManager()
-
Method Summary
Modifier and Type Method Description void
closeChest(PlayerEntity playerEntity, World world, BlockPos blockPos, BlockState blockState)
private int
getInRangeViewerCount(World world, BlockPos pos)
int
getViewerCount()
protected abstract boolean
isPlayerViewing(PlayerEntity player)
Determines whether the given player is currently viewing this chest.protected abstract void
onChestClosed(World world, BlockPos pos, BlockState state)
Run when this chest closes (when the viewer count reaches zero).protected abstract void
onChestOpened(World world, BlockPos pos, BlockState state)
Run when this chest is opened (when the viewer count becomes nonzero).protected abstract void
onInteracted(World world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount)
Run when a player interacts with this chest.void
openChest(PlayerEntity playerEntity, World world, BlockPos blockPos, BlockState blockState)
private static void
scheduleBlockTick(World world, BlockPos pos, BlockState state)
void
updateViewerCount(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
-