162. Idols Under Trees, In Houses, On Stones
Avodas Kochavim 8:4
Let’s say that an idol is placed under a tree. It is prohibited to derive benefit from the tree so long as the idol is under it. When the idol is removed, it becomes permitted to benefit from it again. This is because the tree was not itself the thing being worshipped.
If a non-Jew erects a building with the intention that the building will be worshipped, or if someone bows down to a building that was already erected, it becomes forbidden to derive benefit from that building. If a building that was already erected gets plastered and decorated for the sake of idolatry, if it is to such an extent that it is considered a new entity, then all the additions must be removed and it is forbidden to derive benefit from them as they were made with the intention of being worshipped. It remains permitted to benefit from the rest of the building.
If an idol was placed in a house, it is prohibited to benefit from the house as long as the idol is inside it. When the idol is removed, the house becomes permitted again. Similarly, one may not derive benefit from a stone that was quarried from a mountain with the intention to worship it. If the stone was already quarried and it was decorated in order to be worshipped, the new additions must be removed and it is prohibited to derive benefit from them. This is true if the stone itself was decorated and it goes without saying that it applies if a decoration was added to it. One may, however, derive benefit from the rest of the stone.
Avodas Kochavim 8:5
If an idol is placed on a stone, one may not derive benefit from the stone as long as the idol is there. Once it is removed, the stone becomes permitted again.
If someone’s house is located adjacent to an idolatrous temple and it collapses, he is not permitted to rebuild it. Rather, he must move the wall of his home four cubits into his property, then he may rebuild. The empty space between his house and the idolatrous temple may not be left vacant for the idol’s use; the homeowner should fill it with thorns or trash.
If a wall is shared by a homeowner and an idolatrous temple, it should be treated as belonging to them equally. The homeowner may derive benefit from his half but not from the half belonging to the idolatrous temple. It is likewise prohibited to derive benefit from the wall's stones, beams, and dirt.