Troughs as an animal attractor and lag reducer
A block entity
The trough block in a large area simply acts as an animal attractor. Simple enough. Maybe you can change the animal type attracted with your bait of choice. You can check it once in a while and see if a biome appropriate animal appeared.
Its real purpose however is when placed in a confined area, it makes animals free roam only the area the trough is confined to.
This entity maps out the boundaries of the pasture around it- figuring out what blocks in its vicinity are unreachable due to walls, fences, fence gates, and etc in the way. It reevaluates this area just once in a while as opposed to several times a second. Presumably it would just check an x by y area and map out irregularly shaped pastures within its range, and not meticulously map out gargantuan spaces.
Whilst within range of a trough, animals defer to its assessment of what blocks are reachable and will only path to reachable blocks, rather than each animal in a fenced off area constantly attempting to path to areas outside of the fenced in area; pushing their head against the fence and running countless calculations per second on how to reach the unreachable block they've chosen.
As a result, animals behave with a simulation of contentment with their enclosure and don't obsessively stare at a particular unreachable block, then update their paths the moment a fence gate is opened, and mosh pit toward it to reach their chosen destination. Instead remaining in an area where they can reach the trough.
This may also remove lag caused by large numbers of animals in the presence of a frequently updating block such as a piston pushing a block back and forth, provided the block changes are happening outside the reach of the trough?
Likewise, you can stock it with meat and finally allow cats and dogs to free roam without following you everywhere
The trough doesn't necessarily need to deplete its stock of food over time since auto breeding animals would be the logical result of that, but i could see auto breeding being another application if the trough prevents overcrowding based on # of animals vs space, and you somehow flag the trough to breed the animals (honey? Potions? Maybe higher grade food like hay bales instead of wheat; maybe golden apples/carrots to breed horses/pigs).
The player of course, needs to know none of this lag reduction stuff to understand intuitively that a trough attracts animals to keeps them from trying to escape, and lets their dog roam their house without following them into caves and dying.
If anyone knows the coding of this game well enough to tell if mapping out an interior space would be just as laggy as dozens of animals trying to map their way out of one, or if it's be smarter to forego the trough in favor of animals just recognizing they're in a group and doing this themselves, lmk.