“that are near the sea"是定语从句,修饰前面的先行词"towns“的,是句子的地点状语;而"which had been hung in the streets the night before"是另一个从句,是修饰前面的"the tiny lanterns"的,是句子的主语.
其实你把复杂的东西去掉看这个句子的主干就是:
In towns,the tiny lanterns are placed into the water when the festival is over.(时间状语从句)
再把修饰成分加上就是你原来的句子了.
不知道我说的是否清楚?