There is 'type' of entity. And it must be one of existing types. And your entity will derive behaviour of that type.
And treefarm's custom gui doesn't open 'onclick'. When you click you open standard chest gui, which is 'type' of treefarm field entities.
To open custom gui you have to click with item in hand, which is only possible to handle for chests.
Treefarm doesn't consume energy. Because chest doesn't consume energy. And you can't add energy.
If there is a way to make an entity that consumes electricity and can have custom gui simply on click, then tell me pls.
ATM there are only two types I'm aware of that do not have standard gui - lamp and pump. But energy consumption of lamp depends on time of day.
So the only one that remains is pump with no pipe connectors.
But you can't handle clicks on it.
For entities that consume fuel everything is even worse. You can't have fuel slots AND custom gui in one piece.
And what exactly do you mean with 'action_period_ticks' property
and 'onentityaction' event that is called every action_period_ticks?
For example you want to make a 'treecutter' machine that cuts one tree (in radius of operation) every 2 seconds.
Right now you have to:
1) handle creation and destruction of treecutters to maintain list of existing enitities just for the sake of 2.
2) in ongametick you need to iterate over all treecutters, check their operation time and subtract energy for treecutters that are actually working.
What would make this much easier - define:
action_period_ticks=120,
in definition of treecutter.
Than install onentityaction handler that is called for every active treecutter one every 2 seconds.
Or every 4 seconds if energy satisfaction is 50%.
Probably for this to work properly there should be some kind of operation mode.
operating - onentityaction is called and entity consumes energy
idle - onentityaction is called, but entity doesn't consume energy (except for drain).
nonoperating - neither onentityaction is called nor energy is consumed