Fix #1584 (ClassCastException in tile entity)

I think it is fixed for all tile entity.