Hi, I'm trying to set (reset) a blockstate after a certain amount of ticks. I can't seem to find any examples on how ticks are used in general.
The below method is for an item. If a block is clicked with the item, it changes the block to another one. I want to implement a timer that resets this block to its original state.
@Override
public InteractionResult useOn(UseOnContext pContext) {
if (!pContext.getLevel().isClientSide()) {
BlockPos positionClicked = pContext.getClickedPos();
BlockState originalBlockState = pContext.getLevel().getBlockState(positionClicked);
pContext.getLevel().setBlock(pContext.getClickedPos(), Blocks.PUMPKIN.defaultBlockState(), 3);
// TODO reset to originalBlock after ticks (e.g. 10 seconds)
}
return super.useOn(pContext);
}
A little code snippet or a pointer to a few examples would be very helfpful.