Added custom method for updating block state from TileEntity state changes.
This commit is contained in:
@@ -327,4 +327,28 @@ public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock
|
||||
return this.getTileEntity( w, pos );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the BlockState based on the given BlockState while considering the state of the given TileEntity.
|
||||
*
|
||||
* If the given TileEntity is not of the right type for this block, the state is returned unchanged,
|
||||
* this is also the case if the given block state does not belong to this block.
|
||||
*/
|
||||
public final BlockState getTileEntityBlockState(BlockState current, TileEntity te) {
|
||||
if (current.getBlock() != this || !tileEntityClass.isInstance(te)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
return updateBlockStateFromTileEntity(current, tileEntityClass.cast(te));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reimplement this in subclasses to allow tile-entities to update the state of their block when their own
|
||||
* state changes.
|
||||
*
|
||||
* It is guaranteed that te is not-null and the block of the given block state is this exact block instance.
|
||||
*/
|
||||
protected BlockState updateBlockStateFromTileEntity(BlockState currentState, T te) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user