Add callback after a BlockState was changed and the neighbors were updated (#8686)

This commit is contained in:
Dennis C authored and GitHub committed 2022-06-27 20:21:34 -07:00
1 parent d578d8f6df
commit 2ab3d9b8a3
3 files changed
+31 -1

No files matched your search

@@ -845,6 +845,19 @@ public interface IForgeBlock
return true;
}
/**
* Called after the {@link BlockState} at the given {@link BlockPos} was changed and neighbors were updated.
* This method is called on the server and client side.
* Modifying the level is disallowed in this method.
* Useful for calculating additional data based on the new state and the neighbor's reactions to the state change.
*
* @param level The level the state was modified in
* @param pos The blocks position in the level
* @param oldState The previous state of the block at the given position, may be a different block than this one
* @param newState The new state of the block at the given position
*/
default void onBlockStateChange(LevelReader level, BlockPos pos, BlockState oldState, BlockState newState) { }
/**
* Returns whether the block can be hydrated by a fluid.
*
@@ -688,6 +688,21 @@ public interface IForgeBlockState
return self().getBlock().supportsExternalFaceHiding(self());
}
/**
* Called after the {@link BlockState} at the given {@link BlockPos} was changed and neighbors were updated.
* This method is called on the server and client side.
* Modifying the level is disallowed in this method.
* Useful for calculating additional data based on the new state and the neighbor's reactions to the state change.
*
* @param level The level the state was modified in
* @param pos The blocks position in the level
* @param oldState The previous state of the block at the given position, may be a different block than this one
*/
default void onBlockStateChange(LevelReader level, BlockPos pos, BlockState oldState)
{
self().getBlock().onBlockStateChange(level, pos, oldState, self());
}
/**
* Returns whether the block can be hydrated by a fluid.
*