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

@@ -71,9 +71,11 @@
if (blockstate1 == p_46606_) {
if (blockstate != blockstate1) {
this.m_6550_(p_46605_, blockstate, blockstate1);
@@ -226,8 +_,6 @@
@@ -225,9 +_,8 @@
}
this.m_6559_(p_46605_, blockstate, blockstate1);
+ p_46606_.onBlockStateChange(this, p_46605_, blockstate);
}
-
- return true;
@@ -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.
*